domain

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Id        AttachmentId   `json:"id,omitempty"`
	Board     BoardShortName `json:"board,omitempty"`
	ThreadId  ThreadId       `json:"thread_id,omitempty"`
	MessageId MsgId          `json:"message_id,omitempty"`
	FileId    FileId         `json:"file_id,omitempty"`
	File      *File          `json:"file,omitempty"` // Optional: populated when fetching with file details
}

Attachment represents an attachment linking a message to a file

type AttachmentId

type AttachmentId = int64

type Attachments

type Attachments = []*Attachment

Attachments is a slice of attachments

type BlacklistEntry

type BlacklistEntry struct {
	UserId        UserId
	BlacklistedAt time.Time
	Reason        string
	BlacklistedBy UserId
}

type Board

type Board struct {
	BoardMetadata
	Threads []*Thread
	Page    int `json:"page,omitempty"`
}

type BoardCreationData

type BoardCreationData struct {
	Name          BoardName      `json:"name" validate:"required"`
	ShortName     BoardShortName `json:"short_name" validate:"required"`
	AllowedEmails *Emails        `json:"allowed_emails,omitempty"`
}

to iterate thru layers: handler -> service -> storage

type BoardMetadata

type BoardMetadata struct {
	Name                BoardName
	ShortName           BoardShortName
	CreatedAt           time.Time
	LastActivityAt      time.Time
	AllowedEmailDomains []string // nil means public board, non-empty means corporate board
}

type BoardName

type BoardName = string

type BoardShortName

type BoardShortName = string

type ConfirmationData

type ConfirmationData struct {
	EmailHash            []byte // Email hash for lookup
	PasswordHash         Password
	ConfirmationCodeHash string
	Expires              time.Time
}

type Credentials

type Credentials struct {
	Email    Email
	Password Password
}

type Email

type Email = string

type Emails

type Emails = pq.StringArray

type File

type File struct {
	FileCommonMetadata         // Sanitized file metadata
	Id                 FileId  `json:"id,omitempty"`                 // Database ID
	FilePath           string  `json:"file_path,omitempty"`          // Full path on disk
	OriginalFilename   string  `json:"original_filename,omitempty"`  // User's uploaded filename (before sanitization)
	OriginalMimeType   string  `json:"original_mime_type,omitempty"` // MIME type before sanitization (always present)
	ThumbnailPath      *string `json:"thumbnail_path,omitempty"`     // Path to generated thumbnail (images only)
}

File represents a file stored in the system

func (*File) MediaURL

func (f *File) MediaURL() string

MediaURL returns the public URL for serving this file.

func (*File) ThumbnailURL

func (f *File) ThumbnailURL() string

ThumbnailURL returns the public URL for the thumbnail, or empty string if none.

type FileCommonMetadata

type FileCommonMetadata struct {
	Filename    string `json:"filename,omitempty"`
	SizeBytes   int64  `json:"size_bytes,omitempty"`
	MimeType    string `json:"mime_type,omitempty"`
	ImageWidth  *int   `json:"image_width,omitempty"`
	ImageHeight *int   `json:"image_height,omitempty"`
}

FileCommonMetadata contains common file metadata fields shared between PendingFile (uploaded) and File (stored). Following the MessageMetadata pattern.

func (*FileCommonMetadata) IsImage

func (fcm *FileCommonMetadata) IsImage() bool

IsImage returns true if the file is an image

func (*FileCommonMetadata) IsVideo

func (fcm *FileCommonMetadata) IsVideo() bool

IsVideo returns true if the file is a video

type FileId

type FileId = int64

type InviteCode

type InviteCode struct {
	CodeHash  string
	CreatedBy UserId
	CreatedAt time.Time
	ExpiresAt time.Time
	UsedBy    *UserId    // nil if unused
	UsedAt    *time.Time // nil if unused
}

InviteCode represents an invite code in the system

type InviteCodeWithPlaintext

type InviteCodeWithPlaintext struct {
	PlainCode string
	InviteCode
}

InviteCodeWithPlaintext is returned when generating a new invite It contains the plain-text code that should only be shown once to the creator

type Message

type Message struct {
	MessageMetadata
	Text        string
	Attachments Attachments
}

func (*Message) String

func (m *Message) String() string

for debug

type MessageCreationData

type MessageCreationData struct {
	Board           BoardShortName
	ThreadId        MsgId
	Author          User
	Text            MsgText
	ShowEmailDomain bool
	CreatedAt       *time.Time
	PendingFiles    []*PendingFile // Files to be saved after message creation
	ReplyTo         *Replies
}

to iterate thru layers: handler -> service -> storage

type MessageMetadata

type MessageMetadata struct {
	Board           BoardShortName
	ThreadId        ThreadId
	Id              MsgId // Per-thread sequential (1, 2, 3...) - id=1 is OP
	Author          User
	ShowEmailDomain bool
	Page            int // Page number where this message appears (calculated from Id)
	Replies         Replies
	CreatedAt       time.Time
	ModifiedAt      time.Time
}

func (*MessageMetadata) IsOp

func (m *MessageMetadata) IsOp() bool

IsOp returns true if this message is the opening post (first message in thread)

type MsgId

type MsgId = int64

type MsgText

type MsgText = string

type Password

type Password = string

type PendingFile

type PendingFile struct {
	FileCommonMetadata
	Data io.Reader `json:"-"`
}

PendingFile represents a file upload being processed (moved from domain/message.go)

type ReferralActionStats added in v0.3.2

type ReferralActionStats struct {
	Source string `json:"source"`
	Action string `json:"action"`
	Count  int    `json:"count"`
}

ReferralActionStats contains aggregated counts per source and action type.

type Replies

type Replies = []*Reply

type Reply

type Reply struct {
	Board        BoardShortName
	FromThreadId ThreadId
	ToThreadId   ThreadId
	From         MsgId // Per-thread sequential ID (also serves as ordinal)
	To           MsgId
	FromPage     int // Page where the sender message is located (calculated from From)
	CreatedAt    time.Time
}

type SanitizedImage

type SanitizedImage struct {
	FileCommonMetadata
	Image  any    // Decoded image.Image (any to avoid image import here)
	Format string // Image format from image.Decode ("png", "jpeg", "gif")
}

SanitizedImage represents a sanitized image file ready to be saved. Images are decoded in-memory (metadata stripped) and ready for encoding/thumbnailing.

type SanitizedVideo

type SanitizedVideo struct {
	FileCommonMetadata
	TempFilePath string // Path to sanitized video on disk (always present)
	Thumbnail    []byte // Scaled first-frame JPEG (nil if extraction failed)
}

SanitizedVideo represents a sanitized video file ready to be moved. Videos are processed to disk to avoid memory overhead and moved via MoveFile.

type SaveUserData

type SaveUserData struct {
	Email    Email
	PassHash Password
	Admin    bool
}

SaveUserData contains the data needed to create a new user

type Thread

type Thread struct {
	ThreadMetadata
	Messages   []*Message        `json:"messages"`
	Pagination *ThreadPagination `json:"pagination,omitempty"`
}

func (*Thread) String

func (t *Thread) String() string

type ThreadCreationData

type ThreadCreationData struct {
	Title     ThreadTitle
	Board     BoardShortName
	IsPinned  bool
	OpMessage MessageCreationData
}

to iterate thru layers: handler -> service -> storage

type ThreadId

type ThreadId = int64

type ThreadMetadata

type ThreadMetadata struct {
	Id             ThreadId
	Title          ThreadTitle
	Board          BoardShortName
	MessageCount   int
	LastBumped     time.Time
	LastModifiedAt time.Time
	IsPinned       bool
}

type ThreadPagination

type ThreadPagination struct {
	CurrentPage int `json:"current_page"`
	TotalPages  int `json:"total_pages"`
	TotalCount  int `json:"total_count"` // Total message count
}

type ThreadTitle

type ThreadTitle = string

type User

type User struct {
	Id UserId
	// Stored fields - encrypted and hashed email data
	EmailEncrypted []byte
	EmailDomain    string
	EmailHash      []byte
	PassHash       Password
	Admin          bool
	CreatedAt      time.Time
	ReferralSource string
}

func (*User) GetEmailDomain

func (u *User) GetEmailDomain() (string, error)

type UserId

type UserId = int64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL