Documentation
¶
Index ¶
- type Auth
- func (a *Auth) BlacklistUser(userId domain.UserId, reason string, blacklistedBy domain.UserId) error
- func (a *Auth) CheckConfirmationCode(email domain.Email, confirmationCode string, refSource string) error
- func (a *Auth) GenerateInvite(user domain.User) (*domain.InviteCodeWithPlaintext, error)
- func (a *Auth) GetBlacklistedUsersWithDetails(page int) ([]domain.BlacklistEntry, error)
- func (a *Auth) GetUserInvites(userId domain.UserId, page int) ([]domain.InviteCode, error)
- func (a *Auth) Login(creds domain.Credentials) (string, error)
- func (a *Auth) RefreshBlacklistCache() error
- func (a *Auth) Register(creds domain.Credentials) error
- func (a *Auth) RegisterWithInvite(inviteCode string, password domain.Password, refSource string) (string, error)
- func (a *Auth) RevokeInvite(userId domain.UserId, codeHash string) error
- func (a *Auth) UnblacklistUser(userId domain.UserId) error
- type AuthService
- type AuthStorage
- type Board
- func (b *Board) Create(creationData domain.BoardCreationData) error
- func (b *Board) Delete(shortName domain.BoardShortName) error
- func (b *Board) Get(shortName domain.BoardShortName, page int) (domain.Board, error)
- func (b *Board) GetAllBoards() ([]domain.BoardMetadata, error)
- func (b *Board) GetLastModified(shortName domain.BoardShortName) (time.Time, error)
- type BoardService
- type BoardStorage
- type BoardValidator
- type CleanupStats
- type CredentialsValidator
- type Email
- type EmailCrypto
- type GCMediaStorage
- type GCStorage
- type Jwt
- type MediaGarbageCollector
- type MediaStorage
- type Message
- func (b *Message) Create(creationData domain.MessageCreationData) (domain.MsgId, error)
- func (b *Message) Delete(board domain.BoardShortName, threadId domain.ThreadId, id domain.MsgId) error
- func (b *Message) Get(board domain.BoardShortName, threadId domain.ThreadId, id domain.MsgId) (domain.Message, error)
- type MessageService
- type MessageStorage
- type MessageValidator
- type Referral
- type ReferralService
- type ReferralStorage
- type Thread
- func (b *Thread) Create(creationData domain.ThreadCreationData) (domain.ThreadId, error)
- func (b *Thread) Delete(board domain.BoardShortName, id domain.ThreadId) error
- func (b *Thread) Get(board domain.BoardShortName, id domain.ThreadId, page int) (domain.Thread, error)
- func (b *Thread) GetLastModified(board domain.BoardShortName, id domain.ThreadId) (time.Time, error)
- func (b *Thread) TogglePinned(board domain.BoardShortName, id domain.ThreadId) (bool, error)
- type ThreadService
- type ThreadStorage
- type ThreadValidator
- type UserActivity
- type UserActivityService
- type UserActivityStorage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
func NewAuth ¶
func NewAuth(storage AuthStorage, email Email, jwt Jwt, cfg *config.Public, blacklistCache *blacklist.Cache, emailCrypto EmailCrypto, credentialsValidator CredentialsValidator, allowedRefs sharedutils.AllowedSources) *Auth
func (*Auth) BlacklistUser ¶
func (*Auth) CheckConfirmationCode ¶
func (*Auth) GenerateInvite ¶
GenerateInvite creates a new invite code for a user
func (*Auth) GetBlacklistedUsersWithDetails ¶
func (a *Auth) GetBlacklistedUsersWithDetails(page int) ([]domain.BlacklistEntry, error)
func (*Auth) GetUserInvites ¶
GetUserInvites returns invite codes created by a user, with pagination.
func (*Auth) RefreshBlacklistCache ¶
func (*Auth) RegisterWithInvite ¶
func (a *Auth) RegisterWithInvite(inviteCode string, password domain.Password, refSource string) (string, error)
RegisterWithInvite creates a user account using an invite code Returns the generated @itchan.ru email address
func (*Auth) RevokeInvite ¶
RevokeInvite deletes an unused invite code
type AuthService ¶
type AuthService interface {
Register(creds domain.Credentials) error
CheckConfirmationCode(email domain.Email, confirmationCode string, refSource string) error
Login(creds domain.Credentials) (string, error)
// Invite system methods
RegisterWithInvite(inviteCode string, password domain.Password, refSource string) (string, error)
GenerateInvite(user domain.User) (*domain.InviteCodeWithPlaintext, error)
GetUserInvites(userId domain.UserId, page int) ([]domain.InviteCode, error)
RevokeInvite(userId domain.UserId, codeHash string) error
// Admin blacklist operations
BlacklistUser(userId domain.UserId, reason string, blacklistedBy domain.UserId) error
UnblacklistUser(userId domain.UserId) error
GetBlacklistedUsersWithDetails(page int) ([]domain.BlacklistEntry, error)
RefreshBlacklistCache() error
}
type AuthStorage ¶
type AuthStorage interface {
SaveUser(user domain.User) (domain.UserId, error)
User(emailHash []byte) (domain.User, error)
UpdatePassword(emailHash []byte, newPasswordHash domain.Password) error
DeleteUser(emailHash []byte) error
SaveConfirmationData(data domain.ConfirmationData) error
ConfirmationData(emailHash []byte) (domain.ConfirmationData, error)
DeleteConfirmationData(emailHash []byte) error
// Invite code operations
SaveInviteCode(invite domain.InviteCode) error
InviteCodeByHash(codeHash string) (domain.InviteCode, error)
GetInvitesByUser(userId domain.UserId, limit, offset int) ([]domain.InviteCode, error)
CountActiveInvites(userId domain.UserId) (int, error)
MarkInviteUsed(codeHash string, usedBy domain.UserId) error
DeleteInviteCode(codeHash string) error
DeleteInvitesByUser(userId domain.UserId) error
// Admin blacklist operations
IsUserBlacklisted(userId domain.UserId) (bool, error)
BlacklistUser(userId domain.UserId, reason string, blacklistedBy domain.UserId) error
UnblacklistUser(userId domain.UserId) error
GetBlacklistedUsersWithDetails(limit, offset int) ([]domain.BlacklistEntry, error)
}
type Board ¶
type Board struct {
// contains filtered or unexported fields
}
func (*Board) GetAllBoards ¶ added in v0.3.1
func (b *Board) GetAllBoards() ([]domain.BoardMetadata, error)
func (*Board) GetLastModified ¶
type BoardService ¶
type BoardService interface {
Create(creationData domain.BoardCreationData) error
Get(shortName domain.BoardShortName, page int) (domain.Board, error)
GetLastModified(shortName domain.BoardShortName) (time.Time, error)
Delete(shortName domain.BoardShortName) error
GetAllBoards() ([]domain.BoardMetadata, error)
}
func NewBoard ¶
func NewBoard(storage BoardStorage, validator BoardValidator, mediaStorage MediaStorage) BoardService
type BoardStorage ¶
type BoardStorage interface {
CreateBoard(creationData domain.BoardCreationData) error
GetBoard(shortName domain.BoardShortName, page int) (domain.Board, error)
GetBoardLastModified(shortName domain.BoardShortName) (time.Time, error)
DeleteBoard(shortName domain.BoardShortName) error
GetBoards() ([]domain.BoardMetadata, error)
}
type BoardValidator ¶
type CleanupStats ¶
type CleanupStats struct {
RunAt time.Time
FilesScanned int
OrphanedFiles int
FilesDeleted int
FileRecordsDeleted int // Number of orphaned file records deleted from DB
BytesReclaimed int64
DurationMs int64
Errors []string
}
CleanupStats tracks metrics from the last garbage collection run.
type CredentialsValidator ¶
type EmailCrypto ¶
type GCMediaStorage ¶
type GCMediaStorage interface {
WalkFiles() ([]string, error)
GetFileModTime(filePath string) (time.Time, error)
DeleteFile(filePath string) error
}
GCMediaStorage defines the filesystem operations needed for garbage collection.
type GCStorage ¶
type GCStorage interface {
GetAllFilePaths() ([]string, error)
DeleteOrphanedFileRecords() (int64, error)
}
GCStorage defines the database operations needed for garbage collection.
type MediaGarbageCollector ¶
type MediaGarbageCollector struct {
// contains filtered or unexported fields
}
MediaGarbageCollector handles cleanup of orphaned media files. It compares files on disk with database records and removes orphans.
func NewMediaGarbageCollector ¶
func NewMediaGarbageCollector( storage GCStorage, mediaStorage GCMediaStorage, safetyThreshold time.Duration, ) *MediaGarbageCollector
NewMediaGarbageCollector creates a new garbage collector instance. safetyThreshold is the minimum age a file must have before being deleted. This prevents deletion of files that were just uploaded but not yet committed to DB.
func (*MediaGarbageCollector) GetLastCleanupStats ¶
func (gc *MediaGarbageCollector) GetLastCleanupStats() CleanupStats
GetLastCleanupStats returns statistics from the last cleanup run. Useful for monitoring and observability.
func (*MediaGarbageCollector) RunCleanup ¶
func (gc *MediaGarbageCollector) RunCleanup() error
RunCleanup executes a single garbage collection cycle. It can be called manually for testing or maintenance.
func (*MediaGarbageCollector) StartBackgroundCleanup ¶
func (gc *MediaGarbageCollector) StartBackgroundCleanup(ctx context.Context, interval time.Duration)
StartBackgroundCleanup starts a background goroutine that runs cleanup periodically. It follows the same pattern as board_access.StartBackgroundUpdate.
type MediaStorage ¶
type MediaStorage interface {
// SaveFile stores a file's content.
// It takes the board and thread IDs to construct the path and generates a unique filename.
// It returns the relative path where the file was stored.
SaveFile(fileData io.Reader, boardID, threadID, originalFilename string) (string, error)
// SaveImage encodes and saves an image.Image (PNG if format="png", JPEG otherwise).
// It returns the relative path where the image was stored and the file size in bytes.
SaveImage(img image.Image, format, boardID, threadID, originalFilename string) (string, int64, error)
// MoveFile moves a file from sourcePath to the storage location.
// Used for sanitized videos to avoid loading into memory.
// The source file will be deleted after successful move.
// Returns the relative path where the file was stored.
MoveFile(sourcePath, boardID, threadID, filename string) (string, error)
// SaveThumbnail saves pre-encoded thumbnail bytes (e.g. JPEG from ffmpeg or Go encoder).
// It returns the relative path where the thumbnail was stored.
SaveThumbnail(data io.Reader, originalRelativePath string) (string, error)
// Read opens a file for reading given its relative path.
Read(filePath string) (io.ReadCloser, error)
// DeleteFile removes a single file.
DeleteFile(filePath string) error
// DeleteThread removes all media for an entire thread.
DeleteThread(boardID, threadID string) error
// DeleteBoard removes all media for an entire board.
DeleteBoard(boardID string) error
}
MediaStorage — интерфейс для хранения медиафайлов. Реализуется storage/fs.Storage (локальная ФС), в будущем — S3 и т.д.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
type MessageService ¶
type MessageService interface {
Create(creationData domain.MessageCreationData) (msgId domain.MsgId, err error)
Get(board domain.BoardShortName, threadId domain.ThreadId, id domain.MsgId) (domain.Message, error)
Delete(board domain.BoardShortName, threadId domain.ThreadId, id domain.MsgId) error
}
func NewMessage ¶
func NewMessage(storage MessageStorage, validator MessageValidator, mediaStorage MediaStorage, cfg *config.Public) MessageService
type MessageStorage ¶
type MessageStorage interface {
CreateMessage(creationData domain.MessageCreationData, attachments domain.Attachments) (msgId domain.MsgId, err error)
GetMessage(board domain.BoardShortName, threadId domain.ThreadId, id domain.MsgId) (domain.Message, error)
DeleteMessage(board domain.BoardShortName, threadId domain.ThreadId, id domain.MsgId) error
}
type MessageValidator ¶
type Referral ¶ added in v0.1.3
type Referral struct {
// contains filtered or unexported fields
}
func NewReferral ¶ added in v0.1.3
func NewReferral(storage ReferralStorage) *Referral
func (*Referral) GetStats ¶ added in v0.1.3
func (s *Referral) GetStats() ([]domain.ReferralActionStats, error)
func (*Referral) RecordAction ¶ added in v0.3.2
type ReferralService ¶ added in v0.1.3
type ReferralService interface {
RecordAction(source, action, ip string) error
GetStats() ([]domain.ReferralActionStats, error)
}
type ReferralStorage ¶ added in v0.1.3
type ReferralStorage interface {
SaveReferralAction(source, action, ip string) error
GetReferralActionStats() ([]domain.ReferralActionStats, error)
}
type Thread ¶
type Thread struct {
// contains filtered or unexported fields
}
func (*Thread) GetLastModified ¶
func (*Thread) TogglePinned ¶
type ThreadService ¶
type ThreadService interface {
// Create returns only ThreadId - OP message always has Id=1
Create(creationData domain.ThreadCreationData) (domain.ThreadId, error)
Get(board domain.BoardShortName, id domain.ThreadId, page int) (domain.Thread, error)
GetLastModified(board domain.BoardShortName, id domain.ThreadId) (time.Time, error)
Delete(board domain.BoardShortName, id domain.ThreadId) error
TogglePinned(board domain.BoardShortName, id domain.ThreadId) (bool, error)
}
func NewThread ¶
func NewThread(storage ThreadStorage, validator ThreadValidator, messageService MessageService, mediaStorage MediaStorage, maxThreadCount *int) ThreadService
type ThreadStorage ¶
type ThreadStorage interface {
CreateThread(creationData domain.ThreadCreationData, maxThreadCount *int) (domain.ThreadId, time.Time, error)
GetThread(board domain.BoardShortName, id domain.ThreadId, page int) (domain.Thread, error)
GetThreadLastModified(board domain.BoardShortName, id domain.ThreadId) (time.Time, error)
DeleteThread(board domain.BoardShortName, id domain.ThreadId) error
TogglePinnedStatus(board domain.BoardShortName, threadId domain.ThreadId) (bool, error)
}
type ThreadValidator ¶
type ThreadValidator interface {
Title(title domain.ThreadTitle) error
}
type UserActivity ¶
type UserActivity struct {
// contains filtered or unexported fields
}
UserActivity implements UserActivityService
func (*UserActivity) GetUserActivity ¶
GetUserActivity fetches user's recent messages
type UserActivityService ¶
type UserActivityService interface {
GetUserActivity(userId domain.UserId) ([]domain.Message, error)
}
UserActivityService provides methods for fetching user activity data
func NewUserActivity ¶
func NewUserActivity(storage UserActivityStorage, cfg *config.Public) UserActivityService
NewUserActivity creates a new UserActivity service