mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-10 16:33:11 -06:00
Doc'd
This commit is contained in:
parent
a765352d16
commit
89b792cfad
|
|
@ -31,7 +31,7 @@ type Database struct {
|
|||
profiles profilesStatements
|
||||
}
|
||||
|
||||
// NewDatabase creates a new accounts database
|
||||
// NewDatabase creates a new accounts and profiles database
|
||||
func NewDatabase(dataSourceName string, serverName gomatrixserverlib.ServerName) (*Database, error) {
|
||||
var db *sql.DB
|
||||
var err error
|
||||
|
|
@ -62,20 +62,26 @@ func (d *Database) GetAccountByPassword(localpart, plaintextPassword string) (*a
|
|||
return d.accounts.selectAccountByLocalpart(localpart)
|
||||
}
|
||||
|
||||
// GetProfileByLocalpart returns the profile associated with the given localpart.
|
||||
// Returns sql.ErrNoRows if no profile exists which matches the given localpart.
|
||||
func (d *Database) GetProfileByLocalpart(localpart string) (*authtypes.Profile, error) {
|
||||
return d.profiles.selectProfileByLocalpart(localpart)
|
||||
}
|
||||
|
||||
// SetAvatarURL updates the avatar URL of the profile associated with the given
|
||||
// localpart. Returns an error if something went wrong with the SQL query
|
||||
func (d *Database) SetAvatarURL(localpart string, avatarURL string) error {
|
||||
return d.profiles.setAvatarURL(localpart, avatarURL)
|
||||
}
|
||||
|
||||
// SetDisplayName updates the display name of the profile associated with the given
|
||||
// localpart. Returns an error if something went wrong with the SQL query
|
||||
func (d *Database) SetDisplayName(localpart string, displayName string) error {
|
||||
return d.profiles.setDisplayName(localpart, displayName)
|
||||
}
|
||||
|
||||
// CreateAccount makes a new account with the given login name and password. If no password is supplied,
|
||||
// the account will be a passwordless account.
|
||||
// CreateAccount makes a new account with the given login name and password, and creates an empty profile
|
||||
// for this account. If no password is supplied, the account will be a passwordless account.
|
||||
func (d *Database) CreateAccount(localpart, plaintextPassword string) (*authtypes.Account, error) {
|
||||
hash, err := hashPassword(plaintextPassword)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ type displayName struct {
|
|||
DisplayName string `json:"displayname"`
|
||||
}
|
||||
|
||||
// GetProfile implements GET /profile/{userID}
|
||||
func GetProfile(
|
||||
req *http.Request, accountDB *accounts.Database, userID string,
|
||||
) util.JSONResponse {
|
||||
|
|
@ -66,6 +67,7 @@ func GetProfile(
|
|||
}
|
||||
}
|
||||
|
||||
// AvatarURL implements GET and PUT /profile/{userID}/avatar_url
|
||||
func AvatarURL(
|
||||
req *http.Request, accountDB *accounts.Database, userID string,
|
||||
) util.JSONResponse {
|
||||
|
|
@ -115,6 +117,7 @@ func AvatarURL(
|
|||
}
|
||||
}
|
||||
|
||||
// DisplayName implements GET and PUT /profile/{userID}/displayname
|
||||
func DisplayName(
|
||||
req *http.Request, accountDB *accounts.Database, userID string,
|
||||
) util.JSONResponse {
|
||||
|
|
|
|||
Loading…
Reference in a new issue