Documentation
¶
Index ¶
- Variables
- func BanUser(db *pgxpool.Pool, ownerID, banishedID, reason string, duration int) error
- func Connect() (*pgxpool.Pool, error)
- func CreateChannel(db *pgxpool.Pool, name string, description string) error
- func FetchBanRecords(db *pgxpool.Pool, limit, offset int) ([]models.BanRecord, bool, error)
- func FetchChannels(db *pgxpool.Pool) ([]models.Channel, error)
- func FetchMessageCountByChannel(db *pgxpool.Pool) ([]api.ChannelMessageCount, error)
- func FetchMessages(db *pgxpool.Pool, userID string, channels []string, keyword string, ...) ([]models.ChatMessage, bool, error)
- func FetchSessionActivity(db *pgxpool.Pool, userID string) ([]models.SessionActivity, error)
- func FetchUsers(db *pgxpool.Pool, username string) ([]models.User, error)
- func FlushPrivateMessages(db *pgxpool.Pool, messages []models.PrivateChatMessage) error
- func GetRateLimiterByID(db *pgxpool.Pool, rateLimiterID int) (models.RateLimiter, error)
- func IsUserBanned(db *pgxpool.Pool, banishedID string) (bool, error)
- func MoveChannelBefore(db *pgxpool.Pool, movedID int, beforeID *int) error
- func PardonUser(db *pgxpool.Pool, banishedID int) error
- func RecordUserSession(db *pgxpool.Pool, userID string, start, end time.Time) error
- func RemoveChannelByID(db *pgxpool.Pool, channelID int, purgeMessages bool) error
- func RemoveMessage(db *pgxpool.Pool, messageID int) (bool, error)
- func RemoveMessages(db *pgxpool.Pool, messageIDs []int) (int64, []int, error)
- func UpdateChannel(db *pgxpool.Pool, ID int, name *string, description *string) error
- func UpdateRateLimiter(db *pgxpool.Pool, rateLimiterID, messageLimit, windowSeconds int) error
- type ServerIdentity
Constants ¶
This section is empty.
Variables ¶
var DB *pgxpool.Pool
Functions ¶
func FetchBanRecords ¶
func FetchChannels ¶
FetchChannels retrieves all channels from the database's `channels` table. For each channel, if the `description` column is NULL, the Channel.Description field will be set to nil in the returned slice. Otherwise, it contains the description as a pointer to a string. It returns:
- A slice of Channel models
- An error, if any
func FetchMessageCountByChannel ¶
func FetchMessageCountByChannel(db *pgxpool.Pool) ([]api.ChannelMessageCount, error)
FetchMessageCountByChannel returns the total number of chat messages per channel. It queries the `chat_messages` table, grouping by the `channel` column to produce a list of channels and their respective message counts. It returns:
- A slice of ChannelMessageCount, where each item contains a channel name and a message count
- An error, if the query or row scanning fails
func FetchMessages ¶
func FetchMessages(db *pgxpool.Pool, userID string, channels []string, keyword string, limit, offset int) ([]models.ChatMessage, bool, error)
FetchMessages retrieves cchat messages from the database. Filters can be applied via userID, channels, and keywords. Pagination is controlled by 'limit' and 'offset'. It returns: 1) A slice of ChatMessage objects. 2) A boolean indicating whether there are more results beyond this page. 3) An error, if any occurred.
func FetchSessionActivity ¶
func FlushPrivateMessages ¶
func FlushPrivateMessages(db *pgxpool.Pool, messages []models.PrivateChatMessage) error
FlushPrivateMessages inserts a batch of private messages into the database.
func GetRateLimiterByID ¶
func MoveChannelBefore ¶
MoveChannelBefore reorders a channel to appear before another channel. If beforeID is nil, it moves the channel to the end.
func RecordUserSession ¶
func RemoveChannelByID ¶
func RemoveMessage ¶
RemoveMessage is currently unused. TODO: remove?
func RemoveMessages ¶
RemoveMessages deletes multiple chat messages by their IDs. Before deleting, it fetches each message's cacheID. It returns:
- rowsDeleted: the number of rows actually deleted.
- cacheIDs: a list of cacheIDs associated with the deleted messages.
- An error, if any.
func UpdateChannel ¶
Types ¶
type ServerIdentity ¶
func RegisterOrLoadServer ¶
func RegisterOrLoadServer(db *pgxpool.Pool) ServerIdentity