models

package
v0.0.0-...-eefbc77 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: GPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FriendCountTTL defines how long friend counts remain valid.
	FriendCountTTL = 7 * 24 * time.Hour
)

Variables

View Source
var ErrNoUsersNeedScanning = errors.New("no users need scanning")

Functions

This section is empty.

Types

type ActivityModel

type ActivityModel struct {
	// contains filtered or unexported fields
}

ActivityModel handles database operations for moderator action logs.

func NewActivity

func NewActivity(db *bun.DB, logger *zap.Logger) *ActivityModel

NewActivity creates a repository with database access for storing and retrieving moderator action logs.

func (*ActivityModel) GetLogs

func (r *ActivityModel) GetLogs(
	ctx context.Context, filter types.ActivityFilter, cursor *types.LogCursor, limit int,
) ([]*types.ActivityLog, *types.LogCursor, error)

GetLogs retrieves activity logs based on filter criteria.

func (*ActivityModel) GetRecentlyReviewedIDs

func (r *ActivityModel) GetRecentlyReviewedIDs(
	ctx context.Context, reviewerID uint64, isGroup bool, limit int,
) ([]int64, error)

GetRecentlyReviewedIDs returns the IDs of users or groups that were recently reviewed by a specific reviewer. Uses a time-based filter (30 minutes) with fallback to no filtering if no items are available.

func (*ActivityModel) Log

func (r *ActivityModel) Log(ctx context.Context, log *types.ActivityLog)

Log stores a moderator action in the database.

func (*ActivityModel) LogBatch

func (r *ActivityModel) LogBatch(ctx context.Context, logs []*types.ActivityLog)

LogBatch stores multiple moderator actions in the database.

type CacheModel

type CacheModel struct {
	// contains filtered or unexported fields
}

CacheModel handles database operations for caching user data to optimize worker performance.

func NewCache

func NewCache(db *bun.DB, logger *zap.Logger) *CacheModel

NewCache creates a CacheModel for managing cache entries.

func (*CacheModel) DeleteUserCacheWithTx

func (r *CacheModel) DeleteUserCacheWithTx(ctx context.Context, tx bun.Tx, userIDs []int64) error

DeleteUserCacheWithTx removes cache entries for the given users using the provided transaction.

func (*CacheModel) GetFriendCount

func (r *CacheModel) GetFriendCount(ctx context.Context, userID int64) (int, bool, error)

GetFriendCount retrieves a user's cached friend count. Returns the count and true if found and fresh (within TTL), or 0 and false otherwise.

func (*CacheModel) GetProcessingLogs

func (r *CacheModel) GetProcessingLogs(ctx context.Context, userIDs []int64) ([]types.UserProcessingLog, error)

GetProcessingLogs retrieves processing log entries for the given user IDs.

func (*CacheModel) HasFriendCountChanged

func (r *CacheModel) HasFriendCountChanged(ctx context.Context, userID int64, currentCount int) (bool, error)

HasFriendCountChanged compares current friend count with cached value. Returns true if the count has changed or no valid cache entry exists.

func (*CacheModel) MarkUsersProcessed

func (r *CacheModel) MarkUsersProcessed(ctx context.Context, entries []*types.UserProcessingLog) error

MarkUsersProcessed marks the given users as processed with pre-calculated next scan times.

func (*CacheModel) SetFriendCount

func (r *CacheModel) SetFriendCount(ctx context.Context, userID int64, count int) error

SetFriendCount caches a user's current friend count.

type CommentModel

type CommentModel struct {
	// contains filtered or unexported fields
}

CommentModel handles database operations for comments.

func NewComment

func NewComment(db *bun.DB, logger *zap.Logger) *CommentModel

NewComment creates a new comment model.

func (*CommentModel) DeleteGroupComment

func (r *CommentModel) DeleteGroupComment(ctx context.Context, targetID int64, commenterID uint64) error

DeleteGroupComment deletes a comment by the commenter.

func (*CommentModel) DeleteUserComment

func (r *CommentModel) DeleteUserComment(ctx context.Context, targetID int64, commenterID uint64) error

DeleteUserComment deletes a comment by the commenter.

func (*CommentModel) GetGroupComments

func (r *CommentModel) GetGroupComments(ctx context.Context, targetID int64) ([]*types.Comment, error)

GetGroupComments retrieves comments for a target group ID.

func (*CommentModel) GetUserComments

func (r *CommentModel) GetUserComments(ctx context.Context, targetID int64) ([]*types.Comment, error)

GetUserComments retrieves comments for a target user ID.

func (*CommentModel) UpsertGroupComment

func (r *CommentModel) UpsertGroupComment(ctx context.Context, comment *types.GroupComment) error

UpsertGroupComment inserts or updates a comment from a user.

func (*CommentModel) UpsertUserComment

func (r *CommentModel) UpsertUserComment(ctx context.Context, comment *types.UserComment) error

UpsertUserComment inserts or updates a comment from a user.

type ConsentModel

type ConsentModel struct {
	// contains filtered or unexported fields
}

ConsentModel handles database operations for user consent records.

func NewConsent

func NewConsent(db *bun.DB, logger *zap.Logger) *ConsentModel

NewConsent creates a new consent model.

func (*ConsentModel) HasConsented

func (m *ConsentModel) HasConsented(ctx context.Context, discordUserID uint64) (bool, error)

HasConsented checks if a user has consented to the terms.

func (*ConsentModel) SaveConsent

func (m *ConsentModel) SaveConsent(ctx context.Context, consent *types.UserConsent) error

SaveConsent saves a user's consent record.

type GroupModel

type GroupModel struct {
	// contains filtered or unexported fields
}

GroupModel handles database operations for group records.

func NewGroup

func NewGroup(db *bun.DB, logger *zap.Logger) *GroupModel

NewGroup creates a GroupModel.

func (*GroupModel) ConfirmGroup deprecated

func (r *GroupModel) ConfirmGroup(ctx context.Context, group *types.ReviewGroup) error

ConfirmGroup moves a group to confirmed status and creates a verification record.

Deprecated: Use Service().Group().ConfirmGroup() instead.

func (*GroupModel) DeleteGroups

func (r *GroupModel) DeleteGroups(ctx context.Context, groupIDs []int64) (int64, error)

DeleteGroups removes groups and their associated data from the database.

func (*GroupModel) DeleteGroupsWithTx

func (r *GroupModel) DeleteGroupsWithTx(ctx context.Context, tx bun.Tx, groupIDs []int64) (int64, error)

DeleteGroupsWithTx removes groups and their associated data using the provided transaction.

func (*GroupModel) GetFlaggedAndConfirmedGroups

func (r *GroupModel) GetFlaggedAndConfirmedGroups(ctx context.Context) ([]*types.ReviewGroup, error)

GetFlaggedAndConfirmedGroups retrieves all flagged and confirmed groups.

func (*GroupModel) GetGroupByID

func (r *GroupModel) GetGroupByID(
	ctx context.Context, groupID string, fields types.GroupField,
) (*types.ReviewGroup, error)

GetGroupByID retrieves a group by either their numeric ID or UUID.

func (*GroupModel) GetGroupCounts

func (r *GroupModel) GetGroupCounts(ctx context.Context) (*types.GroupCounts, error)

GetGroupCounts returns counts for all group statuses.

func (*GroupModel) GetGroupToScan

func (r *GroupModel) GetGroupToScan(ctx context.Context) (*types.Group, error)

GetGroupToScan finds the next group to scan.

func (*GroupModel) GetGroupsByIDs

func (r *GroupModel) GetGroupsByIDs(
	ctx context.Context, groupIDs []int64, fields types.GroupField,
) (map[int64]*types.ReviewGroup, error)

GetGroupsByIDs retrieves specified group information for a list of group IDs. Returns a map of group IDs to review groups.

func (*GroupModel) GetGroupsForThumbnailUpdate

func (r *GroupModel) GetGroupsForThumbnailUpdate(ctx context.Context, limit int) (map[int64]*types.ReviewGroup, error)

GetGroupsForThumbnailUpdate retrieves groups that need thumbnail updates.

func (*GroupModel) GetGroupsToCheck

func (r *GroupModel) GetGroupsToCheck(
	ctx context.Context, limit int,
) (groupIDs []int64, lockedIDs []int64, err error)

GetGroupsToCheck finds groups that haven't been checked for locked status recently.

func (*GroupModel) GetLockedCount

func (r *GroupModel) GetLockedCount(ctx context.Context) (int, error)

GetLockedCount returns the total number of locked groups.

func (*GroupModel) GetNextToReview deprecated

func (r *GroupModel) GetNextToReview(
	ctx context.Context, targetStatus enum.GroupType, sortBy enum.ReviewSortBy, recentIDs []int64,
) (*types.ReviewGroup, error)

GetNextToReview handles the common logic for getting the next item to review.

Deprecated: Use Service().Group().GetGroupToReview() instead.

func (*GroupModel) MarkGroupsLockStatus

func (r *GroupModel) MarkGroupsLockStatus(ctx context.Context, groupIDs []int64, isLocked bool) error

MarkGroupsLockStatus updates the locked status of groups.

func (*GroupModel) MixGroup deprecated

func (r *GroupModel) MixGroup(ctx context.Context, group *types.ReviewGroup) error

ClearGroup moves a group to cleared status and creates a clearance record.

Deprecated: Use Service().Group().MixGroup() instead.

func (*GroupModel) SaveGroups deprecated

func (r *GroupModel) SaveGroups(ctx context.Context, tx bun.Tx, groups []*types.ReviewGroup) error

SaveGroups saves groups to the database.

Deprecated: Use Service().Group().SaveGroups() instead.

type GuildBanModel

type GuildBanModel struct {
	// contains filtered or unexported fields
}

GuildBanModel handles database operations for guild ban logs.

func NewGuildBan

func NewGuildBan(db *bun.DB, logger *zap.Logger) *GuildBanModel

NewGuildBan creates a new guild ban model instance.

func (*GuildBanModel) GetGuildBanLogs

func (m *GuildBanModel) GetGuildBanLogs(
	ctx context.Context, guildID uint64, cursor *types.LogCursor, limit int,
) ([]*types.GuildBanLog, *types.LogCursor, error)

GetGuildBanLogs retrieves ban logs for a specific guild with pagination.

func (*GuildBanModel) LogBanOperation

func (m *GuildBanModel) LogBanOperation(ctx context.Context, log *types.GuildBanLog) error

LogBanOperation stores a guild ban operation in the database.

type MaterializedViewModel

type MaterializedViewModel struct {
	// contains filtered or unexported fields
}

MaterializedViewModel handles refresh tracking for materialized views.

func NewMaterializedView

func NewMaterializedView(db *bun.DB, logger *zap.Logger) *MaterializedViewModel

NewMaterializedView creates a new MaterializedViewModel.

func (*MaterializedViewModel) GetRefreshInfo

func (m *MaterializedViewModel) GetRefreshInfo(
	ctx context.Context, viewName string,
) (lastRefresh time.Time, err error)

GetRefreshInfo returns the last refresh time for a view.

func (*MaterializedViewModel) RefreshIfStale

func (m *MaterializedViewModel) RefreshIfStale(
	ctx context.Context, viewName string, staleDuration time.Duration,
) error

RefreshIfStale refreshes a materialized view if it hasn't been refreshed in the given duration.

type MessageModel

type MessageModel struct {
	// contains filtered or unexported fields
}

MessageModel handles database operations for inappropriate Discord messages.

func NewMessage

func NewMessage(db *bun.DB, logger *zap.Logger) *MessageModel

NewMessage creates a new message model instance.

func (*MessageModel) BatchStoreInappropriateMessages

func (m *MessageModel) BatchStoreInappropriateMessages(
	ctx context.Context, messages []*types.InappropriateMessage,
) error

BatchStoreInappropriateMessages stores multiple inappropriate messages.

func (*MessageModel) BatchUpdateUserSummaries

func (m *MessageModel) BatchUpdateUserSummaries(
	ctx context.Context, summaries []*types.InappropriateUserSummary,
) error

BatchUpdateUserSummaries updates multiple user summaries.

func (*MessageModel) DeleteUserMessages

func (m *MessageModel) DeleteUserMessages(ctx context.Context, userID uint64) error

DeleteUserMessages deletes all inappropriate messages for a specific user.

func (*MessageModel) GetUniqueInappropriateUserCount

func (m *MessageModel) GetUniqueInappropriateUserCount(ctx context.Context) (int, error)

GetUniqueInappropriateUserCount returns the number of unique users with inappropriate messages.

func (*MessageModel) GetUserInappropriateMessageSummaries

func (m *MessageModel) GetUserInappropriateMessageSummaries(
	ctx context.Context, userIDs []uint64,
) (map[uint64]*types.InappropriateUserSummary, error)

GetUserInappropriateMessageSummaries retrieves summaries of inappropriate messages for multiple users.

func (*MessageModel) GetUserInappropriateMessageSummary

func (m *MessageModel) GetUserInappropriateMessageSummary(
	ctx context.Context, userID uint64,
) (*types.InappropriateUserSummary, error)

GetUserInappropriateMessageSummary retrieves the inappropriate message summary for a specific user.

func (*MessageModel) GetUserInappropriateMessages

func (m *MessageModel) GetUserInappropriateMessages(
	ctx context.Context, serverID uint64, userID uint64, limit int,
) ([]*types.InappropriateMessage, error)

GetUserInappropriateMessages retrieves inappropriate messages for a specific user in a server.

func (*MessageModel) GetUserMessageGuilds

func (m *MessageModel) GetUserMessageGuilds(ctx context.Context, userID uint64) ([]uint64, error)

GetUserMessageGuilds returns a list of guild IDs where a user has inappropriate messages.

func (*MessageModel) GetUserMessageSummaries

func (m *MessageModel) GetUserMessageSummaries(
	ctx context.Context, userIDs []uint64,
) (map[uint64]*types.InappropriateUserSummary, error)

GetUserMessageSummaries retrieves message summaries for specific users.

func (*MessageModel) GetUserMessagesByCursor

func (m *MessageModel) GetUserMessagesByCursor(
	ctx context.Context, serverID uint64, userID uint64, cursor *types.MessageCursor, limit int,
) ([]*types.InappropriateMessage, *types.MessageCursor, error)

GetUserMessagesByCursor retrieves paginated inappropriate messages for a user in a server .

func (*MessageModel) RedactUserMessages

func (m *MessageModel) RedactUserMessages(ctx context.Context, userID uint64) error

RedactUserMessages redacts the content of all inappropriate messages for a specific user.

type ReviewerModel

type ReviewerModel struct {
	// contains filtered or unexported fields
}

ReviewerModel handles database operations for reviewer statistics.

func NewReviewer

func NewReviewer(db *bun.DB, logger *zap.Logger) *ReviewerModel

NewReviewer creates a new ReviewerModel instance.

func (*ReviewerModel) GetReviewerInfos

func (r *ReviewerModel) GetReviewerInfos(ctx context.Context, reviewerIDs []uint64) (map[uint64]*types.ReviewerInfo, error)

GetReviewerInfos gets reviewer info records for the specified reviewer IDs.

func (*ReviewerModel) GetReviewerInfosForUpdate

func (r *ReviewerModel) GetReviewerInfosForUpdate(
	ctx context.Context, maxAge time.Duration,
) (map[uint64]*types.ReviewerInfo, error)

GetReviewerInfosForUpdate gets all reviewer info records that need updating.

func (*ReviewerModel) GetReviewerStats deprecated

GetReviewerStats retrieves paginated reviewer statistics for a specific time period.

Deprecated: Use Service().Reviewer().GetReviewerStats() instead.

func (*ReviewerModel) SaveReviewerInfos

func (r *ReviewerModel) SaveReviewerInfos(ctx context.Context, reviewers []*types.ReviewerInfo) error

SaveReviewerInfos saves or updates reviewer info records.

type SettingModel

type SettingModel struct {
	// contains filtered or unexported fields
}

SettingModel handles database operations for user and bot settings.

func NewSetting

func NewSetting(db *bun.DB, logger *zap.Logger) *SettingModel

NewSetting creates a SettingModel with database access.

func (*SettingModel) GetBotSettings

func (r *SettingModel) GetBotSettings(ctx context.Context) (*types.BotSetting, error)

GetBotSettings retrieves the bot settings.

func (*SettingModel) GetUserSettings

func (r *SettingModel) GetUserSettings(ctx context.Context, userID snowflake.ID) (*types.UserSetting, error)

GetUserSettings retrieves settings for a specific user.

func (*SettingModel) SaveBotSettings

func (r *SettingModel) SaveBotSettings(ctx context.Context, settings *types.BotSetting) error

SaveBotSettings saves bot settings to the database.

func (*SettingModel) SaveUserSettings

func (r *SettingModel) SaveUserSettings(ctx context.Context, settings *types.UserSetting) error

SaveUserSettings updates or creates user settings.

type StatsModel

type StatsModel struct {
	// contains filtered or unexported fields
}

StatsModel handles database operations for statistics.

func NewStats

func NewStats(db *bun.DB, logger *zap.Logger) *StatsModel

NewStats creates a new StatsModel.

func (*StatsModel) GetHourlyStats

func (r *StatsModel) GetHourlyStats(ctx context.Context) ([]*types.HourlyStats, error)

GetHourlyStats retrieves hourly statistics for the last 24 hours.

func (*StatsModel) HasStatsForHour

func (r *StatsModel) HasStatsForHour(ctx context.Context, hour time.Time) (bool, error)

HasStatsForHour checks if statistics exist for a specific hour.

func (*StatsModel) PurgeOldStats

func (r *StatsModel) PurgeOldStats(ctx context.Context, cutoffDate time.Time) error

PurgeOldStats removes statistics older than the cutoff date.

func (*StatsModel) SaveHourlyStats deprecated

func (r *StatsModel) SaveHourlyStats(ctx context.Context, stats *types.HourlyStats) error

SaveHourlyStats saves the current statistics snapshot.

Deprecated: Use Service().Stats().SaveHourlyStats() instead.

type SyncModel

type SyncModel struct {
	// contains filtered or unexported fields
}

SyncModel handles database operations for Discord server syncing.

func NewSync

func NewSync(db *bun.DB, logger *zap.Logger) *SyncModel

NewSync creates a new sync model instance.

func (*SyncModel) DeleteUserGuildMemberships

func (m *SyncModel) DeleteUserGuildMemberships(ctx context.Context, userID uint64) error

DeleteUserGuildMemberships deletes all guild memberships for a specific user.

func (*SyncModel) GetDiscordRobloxConnection

func (m *SyncModel) GetDiscordRobloxConnection(ctx context.Context, discordUserID uint64) (*types.DiscordRobloxConnection, error)

GetDiscordRobloxConnection retrieves a Discord-Roblox connection by Discord user ID.

func (*SyncModel) GetDiscordServerCountByRobloxID

func (m *SyncModel) GetDiscordServerCountByRobloxID(ctx context.Context, robloxUserID int64) (int, error)

GetDiscordServerCountByRobloxID returns the Discord server count for a Roblox user ID. Returns 0 if no Discord connection exists for this Roblox user.

func (*SyncModel) GetDiscordUserGuildCount

func (m *SyncModel) GetDiscordUserGuildCount(ctx context.Context, discordUserID uint64) (int, error)

GetDiscordUserGuildCount returns the total number of flagged guilds for a specific Discord user.

func (*SyncModel) GetDiscordUserGuilds

func (m *SyncModel) GetDiscordUserGuilds(ctx context.Context, discordUserID uint64) ([]uint64, error)

GetDiscordUserGuilds returns all guild IDs for a specific Discord user.

func (*SyncModel) GetDiscordUserGuildsByCursor

func (m *SyncModel) GetDiscordUserGuildsByCursor(
	ctx context.Context, discordUserID uint64, cursor *types.GuildCursor, limit int,
) ([]*types.UserGuildInfo, *types.GuildCursor, error)

GetDiscordUserGuildsByCursor returns paginated guild memberships for a specific Discord user.

func (*SyncModel) GetDiscordUserIDsByRobloxIDs

func (m *SyncModel) GetDiscordUserIDsByRobloxIDs(
	ctx context.Context, robloxUserIDs []int64,
) (map[int64]uint64, error)

GetDiscordUserIDsByRobloxIDs retrieves Discord user IDs for multiple Roblox user IDs.

func (*SyncModel) GetFlaggedServerMembers

func (m *SyncModel) GetFlaggedServerMembers(
	ctx context.Context, memberIDs []uint64,
) (map[uint64][]*types.UserGuildInfo, error)

GetFlaggedServerMembers returns information about flagged users and their servers.

func (*SyncModel) GetServerInfo

func (m *SyncModel) GetServerInfo(ctx context.Context, serverIDs []uint64) ([]*types.DiscordServerInfo, error)

GetServerInfo returns server information for the given server IDs.

func (*SyncModel) GetUniqueGuildCount

func (m *SyncModel) GetUniqueGuildCount(ctx context.Context) (int, error)

GetUniqueGuildCount returns the number of unique guilds in the database.

func (*SyncModel) GetUniqueUserCount

func (m *SyncModel) GetUniqueUserCount(ctx context.Context) (int, error)

GetUniqueUserCount returns the number of unique user IDs in the server members table.

func (*SyncModel) GetUserForFullScan

func (m *SyncModel) GetUserForFullScan(ctx context.Context, before time.Time) (*uint64, error)

GetUserForFullScan atomically fetches one user and updates their scan timestamp.

func (*SyncModel) GetUsersForFullScan

func (m *SyncModel) GetUsersForFullScan(ctx context.Context, before time.Time, limit int) ([]uint64, error)

GetUsersForFullScan returns users that haven't been scanned recently.

func (*SyncModel) IsUserDataRedacted

func (m *SyncModel) IsUserDataRedacted(ctx context.Context, userID uint64) (bool, error)

IsUserDataRedacted checks if a user's data has been redacted.

func (*SyncModel) IsUserWhitelisted

func (m *SyncModel) IsUserWhitelisted(ctx context.Context, userID uint64) (bool, error)

IsUserWhitelisted checks if a user is whitelisted.

func (*SyncModel) MarkUserDataRedacted

func (m *SyncModel) MarkUserDataRedacted(ctx context.Context, userID uint64) error

MarkUserDataRedacted marks a user's data as redacted.

func (*SyncModel) RemoveServerMember

func (m *SyncModel) RemoveServerMember(ctx context.Context, serverID, userID uint64) error

RemoveServerMember removes a member from a server.

func (*SyncModel) UpdateUserScanTimestamp

func (m *SyncModel) UpdateUserScanTimestamp(ctx context.Context, userID uint64) error

UpdateUserScanTimestamp updates the last scan timestamp for a user.

func (*SyncModel) UpsertDiscordRobloxConnection

func (m *SyncModel) UpsertDiscordRobloxConnection(ctx context.Context, connection *types.DiscordRobloxConnection) error

UpsertDiscordRobloxConnection creates or updates a Discord-Roblox account connection.

func (*SyncModel) UpsertServerInfo

func (m *SyncModel) UpsertServerInfo(ctx context.Context, server *types.DiscordServerInfo) error

UpsertServerInfo creates or updates a single server information record.

func (*SyncModel) UpsertServerMember

func (m *SyncModel) UpsertServerMember(ctx context.Context, member *types.DiscordServerMember) error

UpsertServerMember creates or updates a single server member record.

func (*SyncModel) UpsertServerMembers

func (m *SyncModel) UpsertServerMembers(
	ctx context.Context, members []*types.DiscordServerMember, updateScanTime bool,
) error

UpsertServerMembers creates or updates multiple server member records.

func (*SyncModel) WhitelistDiscordUser

func (m *SyncModel) WhitelistDiscordUser(ctx context.Context, whitelist *types.DiscordUserWhitelist) error

WhitelistDiscordUser adds a Discord user to the whitelist.

type TrackingModel

type TrackingModel struct {
	// contains filtered or unexported fields
}

TrackingModel handles database operations for monitoring affiliations between users and groups.

func NewTracking

func NewTracking(db *bun.DB, logger *zap.Logger) *TrackingModel

NewTracking creates a TrackingModel for tracking group members.

func (*TrackingModel) AddGamesToTracking

func (r *TrackingModel) AddGamesToTracking(ctx context.Context, gameToUsers map[int64][]int64) error

AddGamesToTracking adds multiple users to multiple games' tracking lists.

func (*TrackingModel) AddGroupToExclusions

func (r *TrackingModel) AddGroupToExclusions(ctx context.Context, groupID int64) error

AddGroupToExclusions adds a group to the exclusion list to prevent future tracking.

func (*TrackingModel) AddOutfitAssetsToTracking

func (r *TrackingModel) AddOutfitAssetsToTracking(ctx context.Context, assetToOutfits map[int64][]types.TrackedID) error

AddOutfitAssetsToTracking adds multiple outfits to multiple assets' tracking lists. The map values can contain either outfit IDs or user IDs (for current outfit).

func (*TrackingModel) AddUsersToGroupsTracking

func (r *TrackingModel) AddUsersToGroupsTracking(ctx context.Context, groupToUsers map[int64][]int64) error

AddUsersToGroupsTracking adds multiple users to multiple groups' tracking lists.

func (*TrackingModel) GetExcludedGroupIDs

func (r *TrackingModel) GetExcludedGroupIDs(ctx context.Context, groupIDs []int64) (map[int64]struct{}, error)

GetExcludedGroupIDs returns a set of excluded group IDs from the provided list.

func (*TrackingModel) GetFlaggedUsers

func (r *TrackingModel) GetFlaggedUsers(ctx context.Context, groupID int64) ([]int64, error)

GetFlaggedUsers retrieves the list of flagged users for a specific group.

func (*TrackingModel) GetFlaggedUsersCount

func (r *TrackingModel) GetFlaggedUsersCount(ctx context.Context, groupID int64) (int, error)

GetFlaggedUsersCount retrieves the count of flagged users for a specific group.

func (*TrackingModel) GetGameTrackingsToCheck

func (r *TrackingModel) GetGameTrackingsToCheck(
	ctx context.Context, batchSize int, minFlaggedUsers int, minFlaggedOverride int,
) (map[int64][]int64, error)

GetGameTrackingsToCheck finds games that haven't been checked recently and have at least minFlaggedUsers. Returns games for both hard threshold (minFlaggedOverride) and percentage-based checks.

func (*TrackingModel) GetGroupTrackingsToCheck

func (r *TrackingModel) GetGroupTrackingsToCheck(
	ctx context.Context, batchSize int, minFlaggedUsers int, minFlaggedOverride int,
) (map[int64][]int64, error)

GetGroupTrackingsToCheck finds groups that haven't been checked recently and have at least minFlaggedUsers. Returns groups for both hard threshold (minFlaggedOverride) and percentage-based checks.

func (*TrackingModel) GetOutfitAssetTrackingsToCheck

func (r *TrackingModel) GetOutfitAssetTrackingsToCheck(
	ctx context.Context, batchSize int, minOutfits int, minOutfitsOverride int,
) (map[int64][]types.TrackedID, error)

GetOutfitAssetTrackingsToCheck finds assets that haven't been checked recently and appear in at least minOutfits. Returns assets for both hard threshold (minOutfitsOverride) and percentage-based checks.

func (*TrackingModel) RemoveGamesFromTracking

func (r *TrackingModel) RemoveGamesFromTracking(ctx context.Context, gameIDs []int64) error

RemoveGamesFromTracking removes multiple games and their users from tracking.

func (*TrackingModel) RemoveGroupsFromTracking

func (r *TrackingModel) RemoveGroupsFromTracking(ctx context.Context, groupIDs []int64) error

RemoveGroupsFromTracking removes multiple groups and their users from tracking.

func (*TrackingModel) RemoveUsersFromAllGroups

func (r *TrackingModel) RemoveUsersFromAllGroups(ctx context.Context, userIDs []int64) error

RemoveUsersFromAllGroups removes multiple users from all group tracking records.

func (*TrackingModel) RemoveUsersFromAllGroupsWithTx

func (r *TrackingModel) RemoveUsersFromAllGroupsWithTx(ctx context.Context, tx bun.IDB, userIDs []int64) error

RemoveUsersFromAllGroupsWithTx removes multiple users from all group tracking records using the provided transaction.

func (*TrackingModel) RemoveUsersFromAssetTracking

func (r *TrackingModel) RemoveUsersFromAssetTracking(ctx context.Context, userIDs []int64) error

RemoveUsersFromAssetTracking removes multiple users and their outfits from asset tracking.

func (*TrackingModel) RemoveUsersFromAssetTrackingWithTx

func (r *TrackingModel) RemoveUsersFromAssetTrackingWithTx(ctx context.Context, tx bun.Tx, userIDs []int64) error

RemoveUsersFromAssetTrackingWithTx removes multiple users and their outfits from asset tracking using the provided transaction.

func (*TrackingModel) RemoveUsersFromGameTracking

func (r *TrackingModel) RemoveUsersFromGameTracking(ctx context.Context, userIDs []int64) error

RemoveUsersFromGameTracking removes multiple users from game tracking.

func (*TrackingModel) RemoveUsersFromGameTrackingWithTx

func (r *TrackingModel) RemoveUsersFromGameTrackingWithTx(ctx context.Context, tx bun.IDB, userIDs []int64) error

RemoveUsersFromGameTrackingWithTx removes multiple users from game tracking using the provided transaction.

func (*TrackingModel) UpdateFlaggedGroups

func (r *TrackingModel) UpdateFlaggedGroups(ctx context.Context, groupIDs []int64) error

UpdateFlaggedGroups marks the specified groups as flagged in the tracking table.

type UserModel

type UserModel struct {
	// contains filtered or unexported fields
}

UserModel handles database operations for user records.

func NewUser

func NewUser(db *bun.DB, logger *zap.Logger) *UserModel

NewUser creates a UserModel.

func (*UserModel) ClearUser deprecated

func (r *UserModel) ClearUser(ctx context.Context, user *types.ReviewUser) error

ClearUser moves a user to cleared status and creates a clearance record.

Deprecated: Use Service().User().ClearUser() instead.

func (*UserModel) ClearUserWithTx deprecated

func (r *UserModel) ClearUserWithTx(ctx context.Context, tx bun.Tx, user *types.ReviewUser) error

ClearUserWithTx moves a user to cleared status and creates a clearance record using the provided transaction.

Deprecated: Use Service().User().ClearUserWithTx() instead.

func (*UserModel) ConfirmUsers

func (r *UserModel) ConfirmUsers(ctx context.Context, users []*types.ReviewUser) error

ConfirmUsers moves multiple users to confirmed status and creates verification records.

func (*UserModel) DeleteUserFavorites

func (r *UserModel) DeleteUserFavorites(ctx context.Context, tx bun.Tx, userIDs []int64) (int64, error)

DeleteUserFavorites removes favorite games for the specified users and their associated info.

func (*UserModel) DeleteUserFriends

func (r *UserModel) DeleteUserFriends(ctx context.Context, tx bun.Tx, userIDs []int64) (int64, error)

DeleteUserFriends removes user friend relationships and unreferenced friend info.

func (*UserModel) DeleteUserGames

func (r *UserModel) DeleteUserGames(ctx context.Context, tx bun.Tx, userIDs []int64) (int64, error)

DeleteUserGames removes user game relationships and unreferenced game info.

func (*UserModel) DeleteUserGroups

func (r *UserModel) DeleteUserGroups(ctx context.Context, tx bun.Tx, userIDs []int64) (int64, error)

DeleteUserGroups removes user group relationships and unreferenced group info.

func (*UserModel) DeleteUserInventory

func (r *UserModel) DeleteUserInventory(ctx context.Context, tx bun.Tx, userIDs []int64) (int64, error)

DeleteUserInventory removes user inventory relationships and unreferenced inventory info.

func (*UserModel) DeleteUserOutfits

func (r *UserModel) DeleteUserOutfits(ctx context.Context, tx bun.Tx, userIDs []int64) (int64, error)

DeleteUserOutfits removes user outfit relationships and unreferenced outfits.

func (*UserModel) DeleteUsers

func (r *UserModel) DeleteUsers(ctx context.Context, userIDs []int64) (int64, error)

DeleteUsers removes users and their verification/clearance records from the database.

func (*UserModel) DeleteUsersWithTx

func (r *UserModel) DeleteUsersWithTx(ctx context.Context, tx bun.Tx, userIDs []int64) (int64, error)

DeleteUsersWithTx removes users and their verification/clearance records from the database using the provided transaction.

func (*UserModel) GetBannedCount

func (r *UserModel) GetBannedCount(ctx context.Context) (int, error)

GetBannedCount returns the total number of banned users across all tables.

func (*UserModel) GetConfirmedUsersCount

func (r *UserModel) GetConfirmedUsersCount(ctx context.Context) (int, error)

GetConfirmedUsersCount returns the total number of users in confirmed_users.

func (*UserModel) GetFlaggedAndConfirmedUsers

func (r *UserModel) GetFlaggedAndConfirmedUsers(ctx context.Context) ([]*types.ReviewUser, error)

GetFlaggedAndConfirmedUsers retrieves all flagged and confirmed users.

func (*UserModel) GetFlaggedUsersCount

func (r *UserModel) GetFlaggedUsersCount(ctx context.Context) (int, error)

GetFlaggedUsersCount returns the total number of users in flagged_users.

func (*UserModel) GetFlaggedUsersWithOnlyReason

func (r *UserModel) GetFlaggedUsersWithOnlyReason(
	ctx context.Context, reasonType enum.UserReasonType, confidenceThreshold float64,
) ([]*types.User, error)

GetFlaggedUsersWithOnlyReason returns users that are flagged, have only the specified reason type, and have confidence below the specified threshold for that specific reason.

func (*UserModel) GetFlaggedUsersWithProfileReasons deprecated

func (r *UserModel) GetFlaggedUsersWithProfileReasons(
	ctx context.Context, confidenceThreshold float64, limit int,
) ([]int64, error)

GetFlaggedUsersWithProfileReasons returns user IDs of flagged users that have profile reasons with confidence above the specified threshold.

Deprecated: Use Service().User().GetFlaggedUsersWithProfileReasons() instead.

func (*UserModel) GetFriendInfos

func (r *UserModel) GetFriendInfos(ctx context.Context, friendIDs []int64) (map[int64]*apiTypes.ExtendedFriend, error)

GetFriendInfos retrieves friend information for a list of friend IDs. Returns a map of friend IDs to extended friend objects.

func (*UserModel) GetGlobalTargetCandidates

func (r *UserModel) GetGlobalTargetCandidates(
	ctx context.Context, limit int, excludeUserIDs []int64,
) ([]*types.GlobalTargetCandidate, error)

GetGlobalTargetCandidates returns candidate users for global targeting in the war system.

func (*UserModel) GetNextToReview deprecated

func (r *UserModel) GetNextToReview(
	ctx context.Context, targetStatus enum.UserType, sortBy enum.ReviewSortBy, recentIDs []int64,
) (*types.ReviewUser, error)

GetNextToReview handles the common logic for getting the next item to review.

Deprecated: Use Service().User().GetUserToReview() instead.

func (*UserModel) GetOldClearedUsers

func (r *UserModel) GetOldClearedUsers(ctx context.Context, cutoffDate time.Time) ([]int64, error)

GetOldClearedUsers returns users that were cleared before the cutoff date.

func (*UserModel) GetRecentFriendInfos

func (r *UserModel) GetRecentFriendInfos(
	ctx context.Context, friendIDs []int64, cutoffTime time.Time,
) (map[int64]*apiTypes.ExtendedFriend, error)

GetRecentFriendInfos retrieves friend information for a list of friend IDs, but only if they were updated within the cutoff time.

func (*UserModel) GetUserByID deprecated

func (r *UserModel) GetUserByID(
	ctx context.Context, userID string, fields types.UserField,
) (*types.ReviewUser, error)

GetUserByID retrieves a user by either their numeric ID or UUID.

Deprecated: Use Service().User().GetUserByID() instead.

func (*UserModel) GetUserCounts

func (r *UserModel) GetUserCounts(ctx context.Context) (*types.UserCounts, error)

GetUserCounts returns counts for all user statuses.

func (*UserModel) GetUserIDsByCategory

func (r *UserModel) GetUserIDsByCategory(
	ctx context.Context, category enum.UserCategoryType,
) ([]int64, error)

GetUserIDsByCategory returns all user IDs for a specific category. Only returns users with flagged or confirmed status (excludes cleared users).

func (*UserModel) GetUserToScan

func (r *UserModel) GetUserToScan(ctx context.Context) (*types.User, error)

GetUserToScan finds the next confirmed user to scan with specific high-priority categories.

func (*UserModel) GetUsersAssets

func (r *UserModel) GetUsersAssets(ctx context.Context, userIDs []int64) (map[int64][]*apiTypes.AssetV2, error)

GetUsersAssets fetches the current assets for multiple users.

func (*UserModel) GetUsersByIDs

func (r *UserModel) GetUsersByIDs(
	ctx context.Context, userIDs []int64, fields types.UserField,
) (map[int64]*types.ReviewUser, error)

GetUsersByIDs retrieves specified user information for a list of user IDs. Returns a map of user IDs to review users.

func (*UserModel) GetUsersFavorites

func (r *UserModel) GetUsersFavorites(ctx context.Context, userIDs []int64) (map[int64][]*apiTypes.Game, error)

GetUsersFavorites fetches favorite games for multiple users.

func (*UserModel) GetUsersForGroupCheck

func (r *UserModel) GetUsersForGroupCheck(
	ctx context.Context, limit int,
) ([]int64, error)

GetUsersForGroupCheck finds flagged/confirmed users that haven't had their groups checked recently.

func (*UserModel) GetUsersForThumbnailUpdate

func (r *UserModel) GetUsersForThumbnailUpdate(ctx context.Context, limit int) (map[int64]*types.User, error)

GetUsersForThumbnailUpdate retrieves users that need thumbnail updates.

func (*UserModel) GetUsersFriends

func (r *UserModel) GetUsersFriends(ctx context.Context, userIDs []int64) (map[int64][]*apiTypes.ExtendedFriend, error)

GetUsersFriends fetches friends for multiple users.

func (*UserModel) GetUsersGames

func (r *UserModel) GetUsersGames(ctx context.Context, userIDs []int64) (map[int64][]*apiTypes.Game, error)

GetUsersGames fetches games for multiple users.

func (*UserModel) GetUsersGroups

func (r *UserModel) GetUsersGroups(ctx context.Context, userIDs []int64) (map[int64][]*apiTypes.UserGroupRoles, error)

GetUsersGroups fetches groups for multiple users.

func (*UserModel) GetUsersInventory

func (r *UserModel) GetUsersInventory(ctx context.Context, userIDs []int64) (map[int64][]*apiTypes.InventoryAsset, error)

GetUsersInventory fetches inventory for multiple users.

func (*UserModel) GetUsersOutfits

func (r *UserModel) GetUsersOutfits(ctx context.Context, userIDs []int64) (map[int64]*types.UserOutfitsResult, error)

GetUsersOutfits fetches outfits for multiple users.

func (*UserModel) GetUsersToCheck

func (r *UserModel) GetUsersToCheck(
	ctx context.Context, limit int,
) ([]int64, error)

GetUsersToCheck finds unbanned users that haven't been checked for banned status recently.

func (*UserModel) GetUsersUpdatedAfter

func (r *UserModel) GetUsersUpdatedAfter(
	ctx context.Context, cutoffTime time.Time, reasonTypes []enum.UserReasonType,
) ([]*types.User, error)

GetUsersUpdatedAfter returns users that have been updated after the specified time. If reasonTypes is provided, it will filter for users with only those specific reason types.

func (*UserModel) GetUsersWithReason

func (r *UserModel) GetUsersWithReason(
	ctx context.Context, reasonType enum.UserReasonType, limit int, cursorID int64,
) ([]*types.ReviewUser, error)

GetUsersWithReason gets users that have a specific reason type.

func (*UserModel) GetUsersWithoutCategory

func (r *UserModel) GetUsersWithoutCategory(
	ctx context.Context, limit int, cursorID int64,
) ([]*types.ReviewUser, error)

GetUsersWithoutCategory gets users that don't have a category assigned.

func (*UserModel) GetUsersWithoutReason

func (r *UserModel) GetUsersWithoutReason(
	ctx context.Context, reasonType enum.UserReasonType, limit int, cursorID int64,
) ([]*types.ReviewUser, error)

GetUsersWithoutReason gets users that don't have a specific reason type.

func (*UserModel) MarkUsersBanStatus

func (r *UserModel) MarkUsersBanStatus(ctx context.Context, userIDs []int64, isBanned bool) error

MarkUsersBanStatus updates the banned status of users in their respective tables.

func (*UserModel) SaveUserAssets

func (r *UserModel) SaveUserAssets(ctx context.Context, tx bun.Tx, userAssets map[int64][]*apiTypes.AssetV2) error

SaveUserAssets saves the current assets for multiple users.

func (*UserModel) SaveUserFavorites

func (r *UserModel) SaveUserFavorites(ctx context.Context, tx bun.Tx, userFavorites map[int64][]*apiTypes.Game) error

SaveUserFavorites saves favorite games for multiple users.

func (*UserModel) SaveUserFriends

func (r *UserModel) SaveUserFriends(ctx context.Context, tx bun.Tx, userFriends map[int64][]*apiTypes.ExtendedFriend) error

SaveUserFriends saves friends for multiple users.

func (*UserModel) SaveUserGames

func (r *UserModel) SaveUserGames(ctx context.Context, tx bun.Tx, userGames map[int64][]*apiTypes.Game) error

SaveUserGames saves games for multiple users.

func (*UserModel) SaveUserGroups

func (r *UserModel) SaveUserGroups(ctx context.Context, tx bun.Tx, userGroups map[int64][]*apiTypes.UserGroupRoles) error

SaveUserGroups saves groups for multiple users.

func (*UserModel) SaveUserInventory

func (r *UserModel) SaveUserInventory(ctx context.Context, tx bun.Tx, userInventory map[int64][]*apiTypes.InventoryAsset) error

SaveUserInventory saves inventory for multiple users.

func (*UserModel) SaveUserOutfits

func (r *UserModel) SaveUserOutfits(
	ctx context.Context, tx bun.Tx, userOutfits map[int64][]*apiTypes.Outfit,
	userOutfitAssets map[int64]map[int64][]*apiTypes.AssetV2,
) error

SaveUserOutfits saves outfits and their assets for multiple users.

func (*UserModel) SaveUsers deprecated

func (r *UserModel) SaveUsers(ctx context.Context, tx bun.Tx, users []*types.ReviewUser) error

SaveUsers saves users to the database.

Deprecated: Use Service().User().SaveUsers() instead.

func (*UserModel) UpdateUserCategories

func (r *UserModel) UpdateUserCategories(
	ctx context.Context, categories map[int64]enum.UserCategoryType,
) error

UpdateUserCategories updates the category field for multiple users.

func (*UserModel) UpdateUserReason

func (r *UserModel) UpdateUserReason(ctx context.Context, userID int64, reasonType enum.UserReasonType, newMessage string) error

UpdateUserReason updates a specific reason for a user.

func (*UserModel) UpdateUsersToPastOffender

func (r *UserModel) UpdateUsersToPastOffender(ctx context.Context, tx bun.Tx, userIDs []int64) error

UpdateUsersToPastOffender updates users to past offender status while preserving their reasons and confidence.

Jump to

Keyboard shortcuts

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