Documentation
¶
Index ¶
- type ActionCount
- type CountRecord
- type Db
- func (d Db) DeleteSubscribedChannel(channelId, guildId string) (changed bool, err error)
- func (d Db) GetSession(id string) (exists bool, record SessionRecord, err error)
- func (d Db) RemoveSession(id string) (deleted bool, err error)
- func (d Db) SetSession(id string, accessTokenEncrypted []byte, expiresIn int, ...) (changed bool, err error)
- func (d Db) Stats() ([]CountRecord, []ActionCount, error)
- func (d Db) SubscribedChannels(guildIds []string) ([]SubscribedChannelRecord, error)
- func (d Db) UpdateSubscribedChannel(channelId, guildId, notificationType, launchMentions string) (changed bool, err error)
- type SessionRecord
- type SubscribedChannelRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionCount ¶
type ActionCount struct {
Action string `db:"action_formatted" json:"a"`
Count int `db:"count" json:"c"`
}
ActionCount represents a formatted record from the metrics table. Can be marshalled straight to JSON.
type CountRecord ¶
type CountRecord struct {
GuildCount int `db:"guild_count" json:"g"`
SubscribedCount int `db:"subscribed_count" json:"s"`
Date string `db:"date" json:"d"`
}
CountRecord represents a record in the counts table. Can be marshalled straight to JSON.
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
Db is a wrapper around sqlx.DB which provides methods for interacting with SLB specific tables.
func (Db) DeleteSubscribedChannel ¶
DeleteSubscribedChannel removes a given channel from the subscribed_channels table.
func (Db) GetSession ¶
func (d Db) GetSession(id string) (exists bool, record SessionRecord, err error)
GetSession gets a session record from the database with the given session id.
func (Db) RemoveSession ¶
RemoveSession remove a session record from the database with the given session id.
func (Db) SetSession ¶
func (d Db) SetSession(id string, accessTokenEncrypted []byte, expiresIn int, refreshTokenEncrypted []byte) (changed bool, err error)
SetSession creates a session record in the database.
func (Db) SubscribedChannels ¶
func (d Db) SubscribedChannels(guildIds []string) ([]SubscribedChannelRecord, error)
SubscribedChannels returns a slice of SubscribedChannels that exist in the given guild ids.
func (Db) UpdateSubscribedChannel ¶
func (d Db) UpdateSubscribedChannel(channelId, guildId, notificationType, launchMentions string) (changed bool, err error)
UpdateSubscribedChannel sets the notification type and launch mentions for a given channel ID. guildId is required to ensure that the channel exists in that guild.
type SessionRecord ¶
type SessionRecord struct {
SessionId string `db:"session_id"`
SessionCreationTime time.Time `db:"session_creation_time"`
AccessToken string
AccessTokenEncrypted []byte `db:"access_token_encrypted"`
AccessTokenExpiresAt time.Time `db:"access_token_expires_at"`
RefreshToken string
RefreshTokenEncrypted []byte `db:"refresh_token_encrypted"`
RefreshTime time.Time `db:"refresh_time"`
}
SessionRecord represents a record in the sessions table. The 2 non-marshalled-to fields are because we pass this around and we will need store the unencrypted values.
type SubscribedChannelRecord ¶
type SubscribedChannelRecord struct {
Id string `db:"channel_id" json:"id"`
GuildId string `db:"guild_id"`
Name string `db:"channel_name" json:"name"`
NotificationType string `db:"notification_type" json:"notification_type"`
LaunchMentions *string `db:"launch_mentions" json:"launch_mentions"` // Pointer because it can be NULL in the db.
}
SubscribedChannelRecord represents a record in the subscribed channel table. Can be marshalled straight to JSON, be careful of nil pointers.