diff options
author | Kegsay <kegan@matrix.org> | 2020-06-17 11:22:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-17 11:22:26 +0100 |
commit | a66a3b830c53c223cb939bd010d3769f02f6ccfb (patch) | |
tree | 251b6464d8f8c4fffad106dc18f07203212427fc /userapi/api/api.go | |
parent | 04c99092a46b2ad0b90645bf6553360b5f1b7da7 (diff) |
Make userapi control account creation entirely (#1139)
This makes a chokepoint with which we can finally fix
'database is locked' errors on sqlite during account creation
Diffstat (limited to 'userapi/api/api.go')
-rw-r--r-- | userapi/api/api.go | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/userapi/api/api.go b/userapi/api/api.go index 34c74bb3..c953a5ba 100644 --- a/userapi/api/api.go +++ b/userapi/api/api.go @@ -89,16 +89,18 @@ type QueryProfileResponse struct { // PerformAccountCreationRequest is the request for PerformAccountCreation type PerformAccountCreationRequest struct { - Localpart string - AppServiceID string - Password string + AccountType AccountType // Required: whether this is a guest or user account + Localpart string // Required: The localpart for this account. Ignored if account type is guest. + + AppServiceID string // optional: the application service ID (not user ID) creating this account, if any. + Password string // optional: if missing then this account will be a passwordless account OnConflict Conflict } // PerformAccountCreationResponse is the response for PerformAccountCreation type PerformAccountCreationResponse struct { AccountCreated bool - UserID string + Account *Account } // PerformDeviceCreationRequest is the request for PerformDeviceCreation @@ -115,8 +117,7 @@ type PerformDeviceCreationRequest struct { // PerformDeviceCreationResponse is the response for PerformDeviceCreation type PerformDeviceCreationResponse struct { DeviceCreated bool - AccessToken string - DeviceID string + Device *Device } // Device represents a client's device (mobile, web, etc) @@ -134,6 +135,16 @@ type Device struct { DisplayName string } +// Account represents a Matrix account on this home server. +type Account struct { + UserID string + Localpart string + ServerName gomatrixserverlib.ServerName + AppServiceID string + // TODO: Other flags like IsAdmin, IsGuest + // TODO: Associations (e.g. with application services) +} + // ErrorForbidden is an error indicating that the supplied access token is forbidden type ErrorForbidden struct { Message string @@ -155,9 +166,17 @@ func (e *ErrorConflict) Error() string { // Conflict is an enum representing what to do when encountering conflicting when creating profiles/devices type Conflict int +// AccountType is an enum representing the kind of account +type AccountType int + const ( // ConflictUpdate will update matching records returning no error ConflictUpdate Conflict = 1 // ConflictAbort will reject the request with ErrorConflict ConflictAbort Conflict = 2 + + // AccountTypeUser indicates this is a user account + AccountTypeUser AccountType = 1 + // AccountTypeGuest indicates this is a guest account + AccountTypeGuest AccountType = 2 ) |