Yimaru-BackEnd/internal/domain/activity_log.go
Yared Yemane 31bd1e3814 Add team member email invitations for admin panel onboarding
Introduces invite, verify, accept, resend, and revoke flows using team_members and invitation tokens, sends the branded invitation template, and requires account activation before team login.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-22 03:43:00 -07:00

108 lines
4.6 KiB
Go

package domain
import (
"encoding/json"
"time"
)
type ActivityAction string
const (
ActionCourseCreated ActivityAction = "COURSE_CREATED"
ActionCourseUpdated ActivityAction = "COURSE_UPDATED"
ActionCourseDeleted ActivityAction = "COURSE_DELETED"
ActionSubCourseCreated ActivityAction = "SUB_COURSE_CREATED"
ActionSubCourseUpdated ActivityAction = "SUB_COURSE_UPDATED"
ActionSubCourseDeleted ActivityAction = "SUB_COURSE_DELETED"
ActionVideoCreated ActivityAction = "VIDEO_CREATED"
ActionVideoUploaded ActivityAction = "VIDEO_UPLOADED"
ActionVideoPublished ActivityAction = "VIDEO_PUBLISHED"
ActionVideoUpdated ActivityAction = "VIDEO_UPDATED"
ActionVideoArchived ActivityAction = "VIDEO_ARCHIVED"
ActionVideoDeleted ActivityAction = "VIDEO_DELETED"
ActionUserCreated ActivityAction = "USER_CREATED"
ActionUserUpdated ActivityAction = "USER_UPDATED"
ActionUserDeleted ActivityAction = "USER_DELETED"
ActionSettingsUpdated ActivityAction = "SETTINGS_UPDATED"
ActionTeamMemberCreated ActivityAction = "TEAM_MEMBER_CREATED"
ActionTeamMemberInvited ActivityAction = "TEAM_MEMBER_INVITED"
ActionTeamMemberUpdated ActivityAction = "TEAM_MEMBER_UPDATED"
ActionTeamMemberDeleted ActivityAction = "TEAM_MEMBER_DELETED"
ActionCategoryCreated ActivityAction = "CATEGORY_CREATED"
ActionCategoryUpdated ActivityAction = "CATEGORY_UPDATED"
ActionCategoryDeleted ActivityAction = "CATEGORY_DELETED"
ActionAdminCreated ActivityAction = "ADMIN_CREATED"
ActionAdminUpdated ActivityAction = "ADMIN_UPDATED"
ActionSubscriptionPlanCreated ActivityAction = "SUBSCRIPTION_PLAN_CREATED"
ActionSubscriptionPlanUpdated ActivityAction = "SUBSCRIPTION_PLAN_UPDATED"
ActionSubscriptionPlanDeleted ActivityAction = "SUBSCRIPTION_PLAN_DELETED"
ActionQuestionCreated ActivityAction = "QUESTION_CREATED"
ActionQuestionUpdated ActivityAction = "QUESTION_UPDATED"
ActionQuestionDeleted ActivityAction = "QUESTION_DELETED"
ActionQuestionSetCreated ActivityAction = "QUESTION_SET_CREATED"
ActionQuestionSetUpdated ActivityAction = "QUESTION_SET_UPDATED"
ActionQuestionSetDeleted ActivityAction = "QUESTION_SET_DELETED"
ActionSubCourseDeactivated ActivityAction = "SUB_COURSE_DEACTIVATED"
ActionIssueCreated ActivityAction = "ISSUE_CREATED"
ActionIssueStatusUpdated ActivityAction = "ISSUE_STATUS_UPDATED"
ActionIssueDeleted ActivityAction = "ISSUE_DELETED"
ActionProgramCreated ActivityAction = "PROGRAM_CREATED"
ActionProgramUpdated ActivityAction = "PROGRAM_UPDATED"
ActionProgramDeleted ActivityAction = "PROGRAM_DELETED"
ActionModuleCreated ActivityAction = "MODULE_CREATED"
ActionModuleUpdated ActivityAction = "MODULE_UPDATED"
ActionModuleDeleted ActivityAction = "MODULE_DELETED"
ActionLessonCreated ActivityAction = "LESSON_CREATED"
ActionLessonUpdated ActivityAction = "LESSON_UPDATED"
ActionLessonDeleted ActivityAction = "LESSON_DELETED"
ActionPracticeCreated ActivityAction = "PRACTICE_CREATED"
ActionPracticeUpdated ActivityAction = "PRACTICE_UPDATED"
ActionPracticeDeleted ActivityAction = "PRACTICE_DELETED"
)
type ResourceType string
const (
ResourceCourse ResourceType = "COURSE"
ResourceSubCourse ResourceType = "SUB_COURSE"
ResourceVideo ResourceType = "VIDEO"
ResourceUser ResourceType = "USER"
ResourceSettings ResourceType = "SETTINGS"
ResourceTeamMember ResourceType = "TEAM_MEMBER"
ResourceCategory ResourceType = "CATEGORY"
ResourceAdmin ResourceType = "ADMIN"
ResourceSubscriptionPlan ResourceType = "SUBSCRIPTION_PLAN"
ResourceQuestion ResourceType = "QUESTION"
ResourceQuestionSet ResourceType = "QUESTION_SET"
ResourceIssue ResourceType = "ISSUE"
ResourceProgram ResourceType = "PROGRAM"
ResourceModule ResourceType = "MODULE"
ResourceLesson ResourceType = "LESSON"
ResourcePractice ResourceType = "PRACTICE"
)
type ActivityLog struct {
ID int64
ActorID *int64
ActorRole *string
Action string
ResourceType string
ResourceID *int64
Message *string
Metadata json.RawMessage
IPAddress *string
UserAgent *string
CreatedAt time.Time
}
type ActivityLogFilter struct {
ActorID *int64
Action *string
ResourceType *string
ResourceID *int64
After *time.Time
Before *time.Time
Limit int32
Offset int32
}