Skip to main content

Generated from package comments and exported declarations. Edit the Go source, not this file.

support

import "codeberg.org/hemanta212/playgo/api/support"

Package support defines conversation and message contracts for player support.

Admin support endpoints use these types to start, list, claim, read, resolve, reopen, and respond to conversations without exposing storage details. Implementations enforce rate limits and append message and read-state changes so operators see one coherent timeline rather than an assembled guess. An admin can create the player's unique conversation before the player messages. Opening an existing conversation preserves its resolution and claim; sending still follows the same audited, idempotent message flow and unread accounting.

Claiming is worth understanding: it marks a conversation as being handled, so two operators do not reply to the same player at once.

This package covers the player-visible conversation only. Decisions about payments, wallets, and providers belong in their own domain commands - a decision recorded only in a support message leaves no audit trail and no ledger effect.

Constants​

Search bounds. A query is folded (lowercased, Latin accents stripped) and its whitespace collapsed before it is measured.

const (
SearchQueryMinRunes = 2
SearchQueryMaxRunes = 100
SearchLimitDefault = 20
SearchLimitMax = 50
ConversationSearchLimitDefault = 50
ConversationSearchLimitMax = 200
)
const MaxImageBytes int64 = 8 * 1024 * 1024

Variables​

var (
ErrInvalidRequest = errors.New("support: invalid request")
ErrNotFound = errors.New("support: not found")
ErrForbidden = errors.New("support: forbidden")
ErrConflict = errors.New("support: conflict")
ErrMessageInProgress = errors.New("support: message still processing")
ErrRateLimited = errors.New("support: rate limited")
ErrConversationResolved = errors.New("support: conversation resolved")
)

type ActionState​

type ActionState struct {
Enabled bool
DisabledReason *DisabledReasonCode
}

type Actions​

type Actions struct {
SendMessage ActionState
MarkRead ActionState
Resolve ActionState
Reopen ActionState
}

type ActorKind​

type ActorKind string
const (
ActorKindUser ActorKind = "user"
ActorKindAdmin ActorKind = "admin"
)

type AdminConversation​

type AdminConversation struct {
PendingActionsCount int64
Conversation
PlayerEmail string
PlayerDisplayName *string
ResolvedByUserID *uuid.UUID
ResolvedByLabel *string
ResolutionNoteText *string
Claim Claim
// LastMessage is nil before the first message.
LastMessage *LastMessagePreview
// Aliases are the player's active aliases, oldest first.
Aliases []PlayerAlias
}

type AdminInboxPage​

type AdminInboxPage struct {
Conversations []AdminConversation
NextCursor *string
}

type AdminInboxQuery​

type AdminInboxQuery struct {
Status *ConversationStatus
Unread *bool
Cursor *string
PerPage int32
}

type AttachmentObject​

type AttachmentObject struct {
Body io.ReadCloser
Size int64
ContentType string
}

type AttachmentStore​

type AttachmentStore interface {
PresignUpload(context.Context, string, string, int64, map[string]string, time.Duration) (string, map[string]string, error)
OpenAttachment(context.Context, string) (AttachmentObject, error)
DeleteAttachment(context.Context, string) error
}

type AttachmentUpload​

type AttachmentUpload struct {
ID uuid.UUID
UploadURL string
Headers map[string]string
ExpiresAt time.Time
}

type AttachmentUploadCommand​

type AttachmentUploadCommand struct {
ActorID uuid.UUID
UploadID uuid.UUID
Filename string
ContentType string
Size int64
Checksum string
}

type Claim​

Claim is the advisory-lock view for an admin support conversation, relative to the requesting admin. It is a lightweight lease and is never persisted as part of conversation versioning.

type Claim struct {
State ClaimState
HolderLabel *string
ExpiresAt *time.Time
}

type ClaimCommand​

type ClaimCommand struct {
ActorID uuid.UUID
ConversationID uuid.UUID
Takeover bool
}

type ClaimState​

ClaimState is the advisory-lock state of an admin support conversation, computed relative to the requesting admin.

type ClaimState string
const (
ClaimStateUnclaimed ClaimState = "unclaimed"
ClaimStateMine ClaimState = "mine"
ClaimStateOther ClaimState = "other"
)

type ContactLinkField​

type ContactLinkField string
const (
ContactFieldMessenger ContactLinkField = "messenger_url"
ContactFieldTelegram ContactLinkField = "telegram_url"
ContactFieldWhatsApp ContactLinkField = "whatsapp_url"
ContactFieldSMS ContactLinkField = "sms_phone"
ContactFieldEmail ContactLinkField = "email"
)

func ContactLinkFields​

func ContactLinkFields() []ContactLinkField

type ContactLinkValidationError​

type ContactLinkValidationError struct {
Field ContactLinkField
Message string
}

func (ContactLinkValidationError) Error​

func (e ContactLinkValidationError) Error() string

func (ContactLinkValidationError) Unwrap​

func (e ContactLinkValidationError) Unwrap() error
type ContactLinks struct {
InappSignupFreeplayCents int64
Version int64
WhatsAppURL string
Email string
MessengerURL string
TelegramURL string
// SMSPhone is nil when no SMS number is set.
SMSPhone *string
}

type Conversation​

type Conversation struct {
ID uuid.UUID
UserID uuid.UUID
Status ConversationStatus
LastMessageSeq *int64
LastMessageAt *time.Time
LastUserMessageAt *time.Time
LastSupportMessageAt *time.Time
UserLastReadSeq *int64
SupportLastReadSeq *int64
UnreadForUser int32
UnreadForSupport int32
Version int64
CreatedAt time.Time
UpdatedAt time.Time
ResolvedAt *time.Time
Actions Actions
Poll PollHint
}

type ConversationMatch​

type ConversationMatch struct {
Message SearchMessage
Snippet Snippet
}

type ConversationResult​

type ConversationResult struct {
Conversation Conversation
Replayed bool
}

type ConversationSearchPage​

ConversationSearchPage lists one conversation's matches newest first. Total counts every match in the conversation, whatever the page.

type ConversationSearchPage struct {
Matches []ConversationMatch
Total int64
NextCursor *string
}

type ConversationSearchQuery​

type ConversationSearchQuery struct {
ConversationID uuid.UUID
Query string
Cursor *string
Limit int32
}

type ConversationStatus​

type ConversationStatus string
const (
ConversationStatusOpen ConversationStatus = "open"
ConversationStatusResolved ConversationStatus = "resolved"
)

func (ConversationStatus) Valid​

func (s ConversationStatus) Valid() bool

type DisabledReasonCode​

type DisabledReasonCode string
const (
DisabledReasonNotAllowed DisabledReasonCode = "not_allowed"
DisabledReasonNoMessages DisabledReasonCode = "no_messages"
DisabledReasonConversationResolved DisabledReasonCode = "conversation_resolved"
DisabledReasonConversationOpen DisabledReasonCode = "conversation_open"
DisabledReasonVersionConflict DisabledReasonCode = "version_conflict"
DisabledReasonRateLimited DisabledReasonCode = "rate_limited"
DisabledReasonConversationClaimed DisabledReasonCode = "conversation_claimed"
)

type EventKind​

type EventKind string
const (
EventConversationCreated EventKind = "conversation_created"
EventMessageCreated EventKind = "message_created"
EventReadAdvanced EventKind = "read_advanced"
EventResolved EventKind = "resolved"
EventReopened EventKind = "reopened"
)

type Highlight​

Highlight is one matched range of a snippet, in UTF-16 code units (the units of a JavaScript string), start inclusive and end exclusive.

type Highlight struct {
Start int
End int
}

type LastMessageKind​

type LastMessageKind string
const (
LastMessageKindText LastMessageKind = "text"
LastMessageKindImage LastMessageKind = "image"
)

func LastMessageKinds​

func LastMessageKinds() []LastMessageKind

LastMessageKinds lists every kind; OpenAPI's SupportLastMessagePreview.kind mirrors it.

type LastMessagePreview​

LastMessagePreview is a conversation's newest message as an inbox row shows it. TextPreview is nil for an image.

type LastMessagePreview struct {
Kind LastMessageKind
TextPreview *string
Sender SenderKind
CreatedAt time.Time
}

type ListMessagesQuery​

type ListMessagesQuery struct {
TypingVersion *uuid.UUID
ActorID uuid.UUID
ConversationID uuid.UUID
BeforeSeq *int64
AfterSeq *int64
AroundSeq *int64
Limit int32
WaitForUpdates bool
}

type MarkReadCommand​

type MarkReadCommand struct {
ActorID uuid.UUID
ConversationID uuid.UUID
Seq int64
}

type Message​

type Message struct {
AttachmentID *uuid.UUID
ID uuid.UUID
ConversationID uuid.UUID
Seq int64
SenderKind SenderKind
SenderUserID *uuid.UUID
PublicSenderLabel string
AdminSenderLabel *string
BodyText string
BodyBytes int32
ClientMessageID *string
CreatedAt time.Time
}

type MessageDirection​

type MessageDirection string
const (
MessageDirectionBefore MessageDirection = "before"
MessageDirectionAfter MessageDirection = "after"
MessageDirectionLatest MessageDirection = "latest"
MessageDirectionAround MessageDirection = "around"
)

type MessagesPage​

type MessagesPage struct {
Typing *Typing
Messages []Message
HasMore bool
HasMoreAfter *bool
}

type NullConversationStatus​

type NullConversationStatus struct {
Status ConversationStatus
Valid bool
}

func NewNullConversationStatus​

func NewNullConversationStatus(status *ConversationStatus) NullConversationStatus

func (*NullConversationStatus) Scan​

func (s *NullConversationStatus) Scan(src any) error

func (NullConversationStatus) Value​

func (s NullConversationStatus) Value() (driver.Value, error)

type PaymentReceiptCommand​

type PaymentReceiptCommand struct {
ActorID, AttachmentID, ReferenceID uuid.UUID
Kind PaymentReceiptKind
}

type PaymentReceiptKind​

PaymentReceiptKind names the payment record shown with the existing support image.

type PaymentReceiptKind string
const (
PaymentReceiptDeposit PaymentReceiptKind = "manual_deposit_claim"
PaymentReceiptWithdrawal PaymentReceiptKind = "payment_withdrawal"
)

type PlayerAlias​

type PlayerAlias struct {
Kind searchapi.AliasKind
Value string
}

type PollHint​

type PollHint struct {
Resource PollResource
ResourceID uuid.UUID
AfterSeq *int64
IntervalMS int
Transport *PollTransport
TimeoutMS *int
}

type PollResource​

type PollResource string
const (
PollResourceSupportConversation PollResource = "support.conversation"
PollResourceAdminSupportInbox PollResource = "admin.support.inbox"
)

type PollTransport​

type PollTransport string
const (
PollTransportShortPoll PollTransport = "short_poll"
PollTransportLongPoll PollTransport = "long_poll"
)

type RateLimitOutcome​

type RateLimitOutcome string
const (
RateLimitOutcomeAllowed RateLimitOutcome = "allowed"
RateLimitOutcomeLimited RateLimitOutcome = "limited"
RateLimitOutcomeDisabled RateLimitOutcome = "disabled"
)

type ReopenCommand​

type ReopenCommand = ResolveCommand

type ResolveCommand​

type ResolveCommand struct {
ActorID uuid.UUID
ConversationID uuid.UUID
ExpectedVersion int64
ResolutionNoteText *string
IdempotencyKey string
}

type SearchField​

SearchField is what a global search hit matched.

type SearchField string
const (
SearchFieldMessage SearchField = "message"
SearchFieldDisplayName SearchField = "display_name"
SearchFieldEmail SearchField = "email"
SearchFieldAlias SearchField = "alias"
)

func SearchFields​

func SearchFields() []SearchField

SearchFields lists every field; OpenAPI's AdminSupportSearchField mirrors it.

type SearchHit​

SearchHit is one global search result. Message is set only when Field is SearchFieldMessage. At orders the hits: the message time, or the conversation's last activity for a player hit.

type SearchHit struct {
ConversationID uuid.UUID
ConversationStatus ConversationStatus
Player SearchPlayer
Field SearchField
Message *SearchMessage
At time.Time
Snippet Snippet
}

type SearchMessage​

type SearchMessage struct {
ID uuid.UUID
Seq int64
SenderKind SenderKind
CreatedAt time.Time
}

type SearchPage​

type SearchPage struct {
Hits []SearchHit
NextCursor *string
}

type SearchPlayer​

type SearchPlayer struct {
ID uuid.UUID
DisplayName *string
Email string
}

type SearchQuery​

type SearchQuery struct {
Query string
Cursor *string
Limit int32
}

type SendAdminMessageCommand​

type SendAdminMessageCommand struct {
AttachmentID *uuid.UUID
ActorID uuid.UUID
ConversationID uuid.UUID
Body string
ClientMessageID *string
IdempotencyKey string
}

type SendMessageResult​

type SendMessageResult struct {
Conversation Conversation
Message Message
Replayed bool
}

type SendPlayerMessageCommand​

type SendPlayerMessageCommand struct {
AttachmentID *uuid.UUID
ActorID uuid.UUID
UserID uuid.UUID
Body string
ClientMessageID *string
IdempotencyKey string
}

type SenderKind​

type SenderKind string
const (
SenderKindUser SenderKind = "user"
SenderKindSupport SenderKind = "support"
SenderKindSystem SenderKind = "system"
)

type Snippet​

Snippet is a plain-text excerpt with typed match ranges; it is never markup. TruncatedStart and TruncatedEnd say that the original text continues before or after the excerpt.

type Snippet struct {
Text string
Highlights []Highlight
TruncatedStart bool
TruncatedEnd bool
}

type Typing​

MessagesPage is a window of messages, oldest first. HasMore says more messages exist in the direction the page was read (older for latest and before_seq, newer for after_seq; older for around_seq). HasMoreAfter is set only for an around_seq window and says newer messages exist.

type Typing struct {
Label string
ExpiresInMS int
Version uuid.UUID
}

Generated by gomarkdoc