Documentation ¶
Index ¶
- Variables
- func ActionLen() int
- func Close()
- func Init()
- type Action
- type Audit
- type Channel
- func (v Channel) All() []*Channel
- func (c *Channel) AssertMessageTableExists()
- func (v *Channel) Delete()
- func (v *Channel) EnableHistory(b bool)
- func (v *Channel) MessageCount() int64
- func (v *Channel) MoveTo(n int)
- func (c *Channel) QueryMsgAfterUID(uid UUID, limit int) []*Message
- func (v Channel) Scan(rows *sql.Rows) dbstorage.Scannable
- func (v *Channel) SetDescription(s string)
- func (v *Channel) SetName(s string)
- func (v *Channel) SetPosition(n int)
- type Invite
- type List
- type Message
- type Perm
- type Properties
- func (p *Properties) Decrement(key string)
- func (p *Properties) Get(key string) string
- func (p *Properties) GetAll() map[string]string
- func (p *Properties) GetInt64(key string) int64
- func (p *Properties) GetSome(ks ...string) map[string]string
- func (p *Properties) Has(key string) bool
- func (p *Properties) Increment(key string)
- func (p *Properties) Init()
- func (p *Properties) Set(key string, val string) bool
- func (p *Properties) SetDefault(key string, value string)
- func (p *Properties) SetDefaultInt64(key string, value int64)
- func (p *Properties) SetInt64(key string, value int64)
- type Role
- func (v Role) All() []*Role
- func (v Role) AllSorted() []*Role
- func (v *Role) Delete() []*User
- func (v *Role) MoveTo(n int)
- func (v Role) Scan(rows *sql.Rows) dbstorage.Scannable
- func (v *Role) SetColor(s string)
- func (v *Role) SetDistinguish(b bool)
- func (v *Role) SetName(s string)
- func (v *Role) SetPermMngBans(p Perm)
- func (v *Role) SetPermMngChannels(p Perm)
- func (v *Role) SetPermMngInvites(p Perm)
- func (v *Role) SetPermMngRoles(p Perm)
- func (v *Role) SetPermMngServer(p Perm)
- func (v *Role) SetPermViewAudits(p Perm)
- func (v *Role) SetPosition(n int)
- type Setting
- type User
- func (u *User) AddRole(role UUID)
- func (v User) Count() int64
- func (u *User) DeleteMessage(c *Channel, uid UUID)
- func (u *User) GetRoles() []*Role
- func (u *User) GetRolesSorted() []*Role
- func (u *User) HasRole(role UUID) bool
- func (v User) MemberCount() int64
- func (u *User) RemoveRole(role UUID)
- func (u *User) ResetUID()
- func (v User) Scan(rows *sql.Rows) dbstorage.Scannable
- func (u *User) SetAsMember(b bool)
- func (u *User) SetName(s string)
- func (u *User) SetNickname(s string)
- func (u *User) SetUID(uid UUID)
Constants ¶
This section is empty.
Variables ¶
var ( Props = Properties{} BuiltInRoles = map[UUID]*Role{ "o": &Role{ 0, "o", 0, "Owner", "", pa, pa, false, pa, pa, Time(etc.Epoch), pa, pa, }, } )
var ( // ResourceTables is the list of db table names that represent the various resources in Mantle ResourceTables = []string{cTableUsers, cTableChannels, cTableRoles, cTableInvites, cTableAudits} )
Functions ¶
Types ¶
type Action ¶
type Action int16
Action is a custom sql/driver type to handle Audit Log actions
const ( ActionSettingUpdate Action ActionUserUpdate ActionChannelCreate ActionChannelUpdate ActionChannelDelete ActionRoleCreate ActionRoleUpdate ActionRoleDelete ActionInviteCreate ActionInviteUpdate ActionInviteDelete ActionInviteUse )
Actions Enum
type Audit ¶
type Audit struct { ID int64 `json:"id"` UUID UUID `json:"uuid" dbsorm:"1"` CreatedOn Time `json:"created_on" dbsorm:"1"` Action Action `json:"action" dbsorm:"1"` Agent UUID `json:"agent" dbsorm:"1"` Affected UUID `json:"affected" dbsorm:"1"` Key string `json:"a_key" dbsorm:"1"` Value string `json:"a_value" dbsorm:"1"` }
type Channel ¶
type Channel struct { ID int64 `json:"id"` UUID UUID `json:"uuid" dbsorm:"1"` Position int `json:"position" dbsorm:"1"` Name string `json:"name" dbsorm:"1"` Description string `json:"description" dbsorm:"1"` HistoryOff bool `json:"history_off" dbsorm:"1"` LatestMsg UUID `json:"latest_message" dbsorm:"1"` CreatedOn Time `json:"created_on" dbsorm:"1"` }
func CreateChannel ¶
func QueryChannelByUUID ¶
func (*Channel) AssertMessageTableExists ¶
func (c *Channel) AssertMessageTableExists()
func (*Channel) MessageCount ¶
func (*Channel) QueryMsgAfterUID ¶
QueryMsgAfterUID runs 'select * from messages where uuid < ? order by uuid desc limit 50'
func (*Channel) SetDescription ¶
SetDescription sets description
type Invite ¶
type Invite struct { ID int64 `json:"id"` UUID UUID `json:"uuid" dbsorm:"1"` CreatedOn Time `json:"created_on" dbsorm:"1"` Code string `json:"name" dbsorm:"1"` Uses int64 `json:"uses" dbsorm:"1"` MaxUses int64 `json:"max_uses" dbsorm:"1"` Mode int `json:"mode" dbsorm:"1"` ExpiresIn Duration `json:"expires_in" dbsorm:"1"` ExpiresOn Time `json:"expires_on" dbsorm:"1"` IsFrozen bool `json:"is_frozen" dbsorm:"1"` GivenRoles List `json:"given_roles" dbsorm:"1"` }
func CreateInvite ¶
func CreateInvite() *Invite
CreateInvite creates a new permanent invite and returns it
func QueryInviteByCode ¶
QueryInviteByCode does exactly that
func QueryInviteByUID ¶
QueryInviteByUID does exactly that
type List ¶
type List []string
List is a custom sql/driver type to handle list columns
type Message ¶
type Perm ¶
type Perm uint8
Perm is a custom sql/driver type to handle 3-state permissions
type Properties ¶
type Properties struct {
// contains filtered or unexported fields
}
Properties is a KV-store abstraction around a cached db table
func (*Properties) Decrement ¶
func (p *Properties) Decrement(key string)
Decrement subtracts 1 from key's value if it is an integer
func (*Properties) Get ¶
func (p *Properties) Get(key string) string
Get retrieves the value of a single key
func (*Properties) GetAll ¶
func (p *Properties) GetAll() map[string]string
GetAll returns entire store in a map structure
func (*Properties) GetInt64 ¶
func (p *Properties) GetInt64(key string) int64
GetInt64 returns key's value as an int64
func (*Properties) GetSome ¶
func (p *Properties) GetSome(ks ...string) map[string]string
GetSome returns a subset of the store in a map structure
func (*Properties) Has ¶
func (p *Properties) Has(key string) bool
Has tests whether this Properties contains a certain key
func (*Properties) Increment ¶
func (p *Properties) Increment(key string)
Increment adds 1 to key's value if it is an integer
func (*Properties) Init ¶
func (p *Properties) Init()
Init is called at all SetDefaults and loads cache from db table
func (*Properties) Set ¶
func (p *Properties) Set(key string, val string) bool
Set sets the value of a single key
func (*Properties) SetDefault ¶
func (p *Properties) SetDefault(key string, value string)
SetDefault sets a key's value only if that key has never been set
func (*Properties) SetDefaultInt64 ¶
func (p *Properties) SetDefaultInt64(key string, value int64)
SetDefaultInt64 sets key's value to value if never set before
func (*Properties) SetInt64 ¶
func (p *Properties) SetInt64(key string, value int64)
SetInt64 sets key's value to value
type Role ¶
type Role struct { ID int64 `json:"id"` UUID UUID `json:"uuid" dbsorm:"1"` Position int `json:"position" dbsorm:"1"` Name string `json:"name" dbsorm:"1"` Color string `json:"color" dbsorm:"1"` PermManageChannels Perm `json:"perm_manage_channels" dbsorm:"1"` PermManageRoles Perm `json:"perm_manage_roles" dbsorm:"1"` Distinguish bool `json:"distinguish" dbsorm:"1"` PermManageServer Perm `json:"perm_manage_server" dbsorm:"1"` PermManageInvites Perm `json:"perm_manage_invites" dbsorm:"1"` CreatedOn Time `json:"created_on" dbsorm:"1"` PermViewAudits Perm `json:"perm_view_audits" dbsorm:"1"` PermManageBans Perm `json:"perm_manage_bans" dbsorm:"1"` }
func CreateRole ¶
func QueryRoleByUID ¶
QueryRoleByUID finds a Role with the specified uid
func (*Role) Delete ¶
Delete removes this item from the database and returns the list of users that got the role removed
type Setting ¶
type Setting struct { ID int64 `json:"id"` Key string `json:"key" dbsorm:"1"` Value string `json:"value" dbsorm:"1"` }
func QuerySettingByKey ¶
type User ¶
type User struct { ID int64 `json:"id"` Provider string `json:"provider" dbsorm:"1"` Snowflake string `json:"snowflake" dbsorm:"1"` UUID UUID `json:"uuid" dbsorm:"1"` IsMember bool `json:"is_member" dbsorm:"1"` IsBanned bool `json:"is_banned" dbsorm:"1"` Name string `json:"name" dbsorm:"1"` Nickname string `json:"nickname" dbsorm:"1"` JoindedOn Time `json:"joined_on" dbsorm:"1"` LastActive Time `json:"last_active" dbsorm:"1"` Roles List `json:"roles" dbsorm:"1"` }
func QueryUserBySnowflake ¶
func QueryUserByUUID ¶
func (*User) DeleteMessage ¶
DeleteMessage attempts to delete a UID from this Channel's associated message table. If the UID is not a message in this Channel, nothing happens.
func (*User) GetRolesSorted ¶
func (User) MemberCount ¶
func (*User) RemoveRole ¶
func (u *User) RemoveRole(role UUID)