package message

const (
	ActionConfirmBusinessRoleInvitation = "role_invitation"

	ActionConfirmSourceUserOutbox = "user_outbox"

	ActionConfirmEventCreated = "ConfirmMessageCreated"

	ActionConfirmStatusPending    = "pending"
	ActionConfirmStatusProcessing = "processing"
	ActionConfirmStatusAccepted   = "accepted"
	ActionConfirmStatusRejected   = "rejected"
	ActionConfirmStatusExpired    = "expired"
	ActionConfirmStatusCanceled   = "canceled"
	ActionConfirmStatusFailed     = "failed"

	ActionConfirmActionAccept = "accept"
	ActionConfirmActionReject = "reject"
)

// ActionConfirm 是 IM 操作按钮的后端状态机；App 只能拿 confirm_id 操作，业务参数全部来自这行事实。
type ActionConfirm struct {
	AppCode         string
	ConfirmID       string
	SourceName      string
	SourceEventID   string
	BusinessType    string
	BusinessSubtype string
	BusinessID      string
	SenderUserID    int64
	ReceiverUserID  int64
	MessageText     string
	Status          string
	Action          string
	CommandID       string
	ProcessedAtMS   int64
	LockedBy        string
	LockUntilMS     int64
	ErrorMessage    string
	MetadataJSON    string
	CreatedAtMS     int64
	UpdatedAtMS     int64
}

// ActionConfirmOutbox 是确认消息创建后交给 notice-service 投递 IM 的可靠事件箱。
type ActionConfirmOutbox struct {
	AppCode       string
	EventID       string
	ConfirmID     string
	EventType     string
	Status        string
	WorkerID      string
	LockUntilMS   int64
	RetryCount    int
	NextRetryAtMS int64
	LastError     string
	PayloadJSON   string
	CreatedAtMS   int64
	UpdatedAtMS   int64
}

// RoleInvitationConfirmEvent 是 user_outbox 中 RoleInvitationCreated 的最小投影。
type RoleInvitationConfirmEvent struct {
	SourceEventID      string
	InvitationID       int64
	InvitationType     string
	InviterUserID      int64
	TargetUserID       int64
	AgencyName         string
	Inviter            RoleInvitationUserSnapshot
	Target             RoleInvitationUserSnapshot
	CreatedAtMS        int64
	RawPayloadJSON     string
	ParentBDUserID     int64
	ParentLeaderUserID int64
}

// RoleInvitationUserSnapshot 是生成 IM 展示文案时使用的用户资料快照，不作为权限依据。
type RoleInvitationUserSnapshot struct {
	UserID        int64  `json:"user_id"`
	DisplayUserID string `json:"display_user_id"`
	Username      string `json:"username"`
	Avatar        string `json:"avatar"`
}
