Documentation ¶
Overview ¶
The storage package manages setting up the database ond knows how to fetch and update all relevant data.
Index ¶
- Variables
- func CreateEvent(tx TX, event_id m.EventID, user_id m.UserID, room_id m.RoomID, ...) error
- func CreateStateEvent(tx TX, event_id m.EventID, user_id m.UserID, room_id m.RoomID, ...) error
- func GetPowerLevel(db DBI, room_id m.RoomID, state_key string) (int64, error)
- func LookupRoomAlias(db DBI, room_alias m.RoomAlias) (m.RoomID, []string, error)
- func NewEvent(tx TX, user_id m.UserID, room_id m.RoomID, event_type string, ...) (m.EventID, error)
- func NewStateEvent(tx TX, user_id m.UserID, room_id m.RoomID, event_type, state_key string, ...) (m.EventID, error)
- func Now() int64
- func Setup() error
- type AccessToken
- type DB
- type DBI
- type DBID
- type Password
- type PasswordHash
- type Presence
- type PresenceState
- type Profile
- type Room
- func (r *Room) CheckedUpdateMember(tx TX, sender, target m.UserID, new_membership m.RoomMembership) (err error)
- func (r *Room) GetInviteLevel(db DBI) (invite int64, err error)
- func (r *Room) GetJoinRule(db DBI) (m.RoomJoinRule, error)
- func (r *Room) GetOpsLevels(db DBI) (ban int64, kick int64, redact int64, err error)
- func (r *Room) GetUserMembership(db DBI, user_id m.UserID) (m.RoomMembership, error)
- func (r *Room) GetUserPowerLevel(db DBI, user_id m.UserID) (int64, error)
- func (r *Room) InviteMember(tx TX, sender m.UserID, target m.UserID) error
- func (r *Room) UpdateAddStateLevel(tx TX, sender m.UserID, new_level int64) (err error)
- func (r *Room) UpdateAliases(tx TX, sender m.UserID, new_aliases []m.RoomAlias) (err error)
- func (r *Room) UpdateJoinRule(tx TX, sender m.UserID, new_join_rule m.RoomJoinRule) (err error)
- func (r *Room) UpdateMember(tx TX, sender m.UserID, target m.UserID, new_membership m.RoomMembership) (err error)
- func (r *Room) UpdateName(tx TX, sender m.UserID, new_name string) (err error)
- func (r *Room) UpdateOpsLevel(tx TX, sender m.UserID, new_levels map[string]int64) (err error)
- func (r *Room) UpdatePowerLevels(tx TX, sender m.UserID, new_levels map[m.UserID]int64, default_level *int64) (err error)
- func (r *Room) UpdateSendEventLevel(tx TX, sender m.UserID, new_level int64) (err error)
- func (r *Room) UpdateTopic(tx TX, sender m.UserID, new_topic string) (err error)
- type TX
- type Timestamp
- type Token
- type User
- func (u *User) GetAccessToken(db DBI) (*AccessToken, error)
- func (u *User) GetInitialPresence(db DBI) ([]o.InitialSyncEvent, error)
- func (u *User) GetPresence(db DBI) (*Presence, error)
- func (u *User) GetProfile(db DBI) (*Profile, error)
- func (u *User) GetRoomMemberships(db DBI, limit uint64) ([]o.InitialSyncRoomData, error)
- func (u *User) SetPassword(db DBI, passwordstring string) error
- func (u *User) UpdatePassword(db DBI, hash PasswordHash) error
- func (u *User) UpdatePresence(db DBI, newpresence PresenceState, message string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( PresenceStates map[string]PresenceState = map[string]PresenceState{ "free for chat": P_FREEFORCHAT, "online": P_ONLINE, "unavailable": P_UNAVAILABLE, "hidden": P_HIDDEN, "offline": P_OFFLINE, } )
Functions ¶
func CreateEvent ¶
func CreateStateEvent ¶
func LookupRoomAlias ¶
func NewStateEvent ¶
Types ¶
type AccessToken ¶
func NewAccessToken ¶
func NewAccessToken(db DBI, u *User) (*AccessToken, error)
func (*AccessToken) UpdateAccessToken ¶
func (t *AccessToken) UpdateAccessToken(db DBI) error
type DB ¶
func GetDatabase ¶
func GetDatabase() DB
type DBI ¶
type DBI interface { Exec(string, ...interface{}) (sql.Result, error) Query(string, ...interface{}) (*sql.Rows, error) QueryRow(string, ...interface{}) *sql.Row }
The DBI is something that can do something on a database, normally either a `*sql.DB` or a `*sql.Tx`.
type Password ¶
type Password string
func (Password) MakeHash ¶
func (p Password) MakeHash(salt string) PasswordHash
type PasswordHash ¶
type PasswordHash struct {
// contains filtered or unexported fields
}
func (PasswordHash) Equal ¶
func (p PasswordHash) Equal(password string) bool
func (PasswordHash) Hash ¶
func (p PasswordHash) Hash() string
func (PasswordHash) Salt ¶
func (p PasswordHash) Salt() string
type Presence ¶
type Presence struct { User *User Presence PresenceState PresenceString string Status string MTime int64 }
type PresenceState ¶
type PresenceState int
const ( P_FREEFORCHAT PresenceState = 20 P_ONLINE PresenceState = 10 P_UNAVAILABLE PresenceState = 5 P_HIDDEN PresenceState = 1 P_OFFLINE PresenceState = 0 )
func (PresenceState) String ¶
func (p PresenceState) String() string
type Room ¶
type Room struct { ID m.RoomID `json:"-"` Aliases []string `json:"aliases"` Name string `json:"name"` JoinedMembers int `json:"num_joined_members"` RoomId string `json:"room_id"` Topic string `json:"topic"` }
func GetPublicRooms ¶
func (*Room) CheckedUpdateMember ¶
func (*Room) GetJoinRule ¶
func (r *Room) GetJoinRule(db DBI) (m.RoomJoinRule, error)
func (*Room) GetOpsLevels ¶
func (*Room) GetUserMembership ¶
func (*Room) GetUserPowerLevel ¶
func (*Room) InviteMember ¶
func (*Room) UpdateAddStateLevel ¶
func (*Room) UpdateAliases ¶
func (*Room) UpdateJoinRule ¶
func (*Room) UpdateMember ¶
func (*Room) UpdateName ¶
func (*Room) UpdateOpsLevel ¶
func (*Room) UpdatePowerLevels ¶
func (*Room) UpdateSendEventLevel ¶
type User ¶
type User struct { ID DBID UserID m.UserID Password PasswordHash Created Timestamp Profile *Profile }
func (*User) GetAccessToken ¶
func (u *User) GetAccessToken(db DBI) (*AccessToken, error)
func (*User) GetInitialPresence ¶
func (u *User) GetInitialPresence(db DBI) ([]o.InitialSyncEvent, error)
func (*User) GetRoomMemberships ¶
Fetch the users joined rooms and return it in a list for initial sync. limit is used to limit the number of messages that is returned for each room.
func (*User) UpdatePassword ¶
func (u *User) UpdatePassword(db DBI, hash PasswordHash) error
func (*User) UpdatePresence ¶
func (u *User) UpdatePresence(db DBI, newpresence PresenceState, message string) error
Click to show internal directories.
Click to hide internal directories.