2020-06-15 08:54:11 +00:00
|
|
|
// Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package api
|
|
|
|
|
2020-06-16 16:05:38 +00:00
|
|
|
import (
|
|
|
|
"context"
|
2020-06-18 17:36:03 +00:00
|
|
|
"encoding/json"
|
2020-06-16 16:05:38 +00:00
|
|
|
|
2020-07-28 09:53:17 +00:00
|
|
|
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
|
2020-06-16 16:05:38 +00:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
|
|
)
|
2020-06-15 08:54:11 +00:00
|
|
|
|
|
|
|
// UserInternalAPI is the internal API for information about users and devices.
|
|
|
|
type UserInternalAPI interface {
|
2022-02-10 10:27:26 +00:00
|
|
|
LoginTokenInternalAPI
|
|
|
|
|
2020-06-18 17:36:03 +00:00
|
|
|
InputAccountData(ctx context.Context, req *InputAccountDataRequest, res *InputAccountDataResponse) error
|
2020-06-16 16:39:56 +00:00
|
|
|
PerformAccountCreation(ctx context.Context, req *PerformAccountCreationRequest, res *PerformAccountCreationResponse) error
|
2020-09-04 14:16:13 +00:00
|
|
|
PerformPasswordUpdate(ctx context.Context, req *PerformPasswordUpdateRequest, res *PerformPasswordUpdateResponse) error
|
2020-06-16 16:39:56 +00:00
|
|
|
PerformDeviceCreation(ctx context.Context, req *PerformDeviceCreationRequest, res *PerformDeviceCreationResponse) error
|
2020-07-30 17:00:56 +00:00
|
|
|
PerformDeviceDeletion(ctx context.Context, req *PerformDeviceDeletionRequest, res *PerformDeviceDeletionResponse) error
|
2020-11-20 11:29:02 +00:00
|
|
|
PerformLastSeenUpdate(ctx context.Context, req *PerformLastSeenUpdateRequest, res *PerformLastSeenUpdateResponse) error
|
2020-07-31 13:40:45 +00:00
|
|
|
PerformDeviceUpdate(ctx context.Context, req *PerformDeviceUpdateRequest, res *PerformDeviceUpdateResponse) error
|
2020-10-02 16:18:20 +00:00
|
|
|
PerformAccountDeactivation(ctx context.Context, req *PerformAccountDeactivationRequest, res *PerformAccountDeactivationResponse) error
|
2021-04-07 12:26:20 +00:00
|
|
|
PerformOpenIDTokenCreation(ctx context.Context, req *PerformOpenIDTokenCreationRequest, res *PerformOpenIDTokenCreationResponse) error
|
2021-12-03 17:18:35 +00:00
|
|
|
PerformKeyBackup(ctx context.Context, req *PerformKeyBackupRequest, res *PerformKeyBackupResponse) error
|
2021-07-27 11:47:32 +00:00
|
|
|
QueryKeyBackup(ctx context.Context, req *QueryKeyBackupRequest, res *QueryKeyBackupResponse)
|
2020-06-15 08:54:11 +00:00
|
|
|
QueryProfile(ctx context.Context, req *QueryProfileRequest, res *QueryProfileResponse) error
|
2020-06-16 13:10:55 +00:00
|
|
|
QueryAccessToken(ctx context.Context, req *QueryAccessTokenRequest, res *QueryAccessTokenResponse) error
|
2020-06-16 13:53:19 +00:00
|
|
|
QueryDevices(ctx context.Context, req *QueryDevicesRequest, res *QueryDevicesResponse) error
|
2020-06-16 16:05:38 +00:00
|
|
|
QueryAccountData(ctx context.Context, req *QueryAccountDataRequest, res *QueryAccountDataResponse) error
|
2020-07-22 16:04:57 +00:00
|
|
|
QueryDeviceInfos(ctx context.Context, req *QueryDeviceInfosRequest, res *QueryDeviceInfosResponse) error
|
2020-07-28 09:53:17 +00:00
|
|
|
QuerySearchProfiles(ctx context.Context, req *QuerySearchProfilesRequest, res *QuerySearchProfilesResponse) error
|
2021-04-07 12:26:20 +00:00
|
|
|
QueryOpenIDToken(ctx context.Context, req *QueryOpenIDTokenRequest, res *QueryOpenIDTokenResponse) error
|
2020-06-16 13:10:55 +00:00
|
|
|
}
|
|
|
|
|
2021-07-27 11:47:32 +00:00
|
|
|
type PerformKeyBackupRequest struct {
|
|
|
|
UserID string
|
|
|
|
Version string // optional if modifying a key backup
|
|
|
|
AuthData json.RawMessage
|
|
|
|
Algorithm string
|
|
|
|
DeleteBackup bool // if true will delete the backup based on 'Version'.
|
2021-07-27 16:08:53 +00:00
|
|
|
|
|
|
|
// The keys to upload, if any. If blank, creates/updates/deletes key version metadata only.
|
|
|
|
Keys struct {
|
|
|
|
Rooms map[string]struct {
|
|
|
|
Sessions map[string]KeyBackupSession `json:"sessions"`
|
|
|
|
} `json:"rooms"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// KeyBackupData in https://spec.matrix.org/unstable/client-server-api/#get_matrixclientr0room_keyskeysroomidsessionid
|
|
|
|
type KeyBackupSession struct {
|
|
|
|
FirstMessageIndex int `json:"first_message_index"`
|
|
|
|
ForwardedCount int `json:"forwarded_count"`
|
|
|
|
IsVerified bool `json:"is_verified"`
|
|
|
|
SessionData json.RawMessage `json:"session_data"`
|
|
|
|
}
|
|
|
|
|
2021-07-27 18:29:32 +00:00
|
|
|
func (a *KeyBackupSession) ShouldReplaceRoomKey(newKey *KeyBackupSession) bool {
|
|
|
|
// https://spec.matrix.org/unstable/client-server-api/#backup-algorithm-mmegolm_backupv1curve25519-aes-sha2
|
|
|
|
// "if the keys have different values for is_verified, then it will keep the key that has is_verified set to true"
|
|
|
|
if newKey.IsVerified && !a.IsVerified {
|
|
|
|
return true
|
2021-07-28 09:25:45 +00:00
|
|
|
} else if newKey.FirstMessageIndex < a.FirstMessageIndex {
|
|
|
|
// "if they have the same values for is_verified, then it will keep the key with a lower first_message_index"
|
2021-07-27 18:29:32 +00:00
|
|
|
return true
|
2021-07-28 09:25:45 +00:00
|
|
|
} else if newKey.ForwardedCount < a.ForwardedCount {
|
|
|
|
// "and finally, is is_verified and first_message_index are equal, then it will keep the key with a lower forwarded_count"
|
2021-07-27 18:29:32 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-07-27 16:08:53 +00:00
|
|
|
// Internal KeyBackupData for passing to/from the storage layer
|
|
|
|
type InternalKeyBackupSession struct {
|
|
|
|
KeyBackupSession
|
|
|
|
RoomID string
|
|
|
|
SessionID string
|
2021-07-27 11:47:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PerformKeyBackupResponse struct {
|
|
|
|
Error string // set if there was a problem performing the request
|
|
|
|
BadInput bool // if set, the Error was due to bad input (HTTP 400)
|
2021-07-27 16:08:53 +00:00
|
|
|
|
|
|
|
Exists bool // set to true if the Version exists
|
|
|
|
Version string // the newly created version
|
|
|
|
|
|
|
|
KeyCount int64 // only set if Keys were given in the request
|
|
|
|
KeyETag string // only set if Keys were given in the request
|
2021-07-27 11:47:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type QueryKeyBackupRequest struct {
|
|
|
|
UserID string
|
|
|
|
Version string // the version to query, if blank it means the latest
|
2021-07-27 18:29:32 +00:00
|
|
|
|
|
|
|
ReturnKeys bool // whether to return keys in the backup response or just the metadata
|
|
|
|
KeysForRoomID string // optional string to return keys which belong to this room
|
|
|
|
KeysForSessionID string // optional string to return keys which belong to this (room, session)
|
2021-07-27 11:47:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type QueryKeyBackupResponse struct {
|
|
|
|
Error string
|
|
|
|
Exists bool
|
|
|
|
|
|
|
|
Algorithm string `json:"algorithm"`
|
|
|
|
AuthData json.RawMessage `json:"auth_data"`
|
2021-07-27 18:29:32 +00:00
|
|
|
Count int64 `json:"count"`
|
2021-07-27 11:47:32 +00:00
|
|
|
ETag string `json:"etag"`
|
|
|
|
Version string `json:"version"`
|
2021-07-27 18:29:32 +00:00
|
|
|
|
|
|
|
Keys map[string]map[string]KeyBackupSession // the keys if ReturnKeys=true
|
2021-07-27 11:47:32 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 17:36:03 +00:00
|
|
|
// InputAccountDataRequest is the request for InputAccountData
|
|
|
|
type InputAccountDataRequest struct {
|
|
|
|
UserID string // required: the user to set account data for
|
|
|
|
RoomID string // optional: the room to associate the account data with
|
2020-06-19 08:18:09 +00:00
|
|
|
DataType string // required: the data type of the data
|
2020-06-18 17:36:03 +00:00
|
|
|
AccountData json.RawMessage // required: the message content
|
|
|
|
}
|
|
|
|
|
|
|
|
// InputAccountDataResponse is the response for InputAccountData
|
|
|
|
type InputAccountDataResponse struct {
|
|
|
|
}
|
|
|
|
|
2020-07-31 13:40:45 +00:00
|
|
|
type PerformDeviceUpdateRequest struct {
|
|
|
|
RequestingUserID string
|
|
|
|
DeviceID string
|
|
|
|
DisplayName *string
|
|
|
|
}
|
|
|
|
type PerformDeviceUpdateResponse struct {
|
|
|
|
DeviceExists bool
|
|
|
|
Forbidden bool
|
|
|
|
}
|
|
|
|
|
2020-07-30 17:00:56 +00:00
|
|
|
type PerformDeviceDeletionRequest struct {
|
|
|
|
UserID string
|
2020-08-27 17:53:40 +00:00
|
|
|
// The devices to delete. An empty slice means delete all devices.
|
2020-07-30 17:00:56 +00:00
|
|
|
DeviceIDs []string
|
2020-09-04 14:16:13 +00:00
|
|
|
// The requesting device ID to exclude from deletion. This is needed
|
|
|
|
// so that a password change doesn't cause that client to be logged
|
|
|
|
// out. Only specify when DeviceIDs is empty.
|
|
|
|
ExceptDeviceID string
|
2020-07-30 17:00:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PerformDeviceDeletionResponse struct {
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:04:57 +00:00
|
|
|
// QueryDeviceInfosRequest is the request to QueryDeviceInfos
|
|
|
|
type QueryDeviceInfosRequest struct {
|
|
|
|
DeviceIDs []string
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryDeviceInfosResponse is the response to QueryDeviceInfos
|
|
|
|
type QueryDeviceInfosResponse struct {
|
|
|
|
DeviceInfo map[string]struct {
|
|
|
|
DisplayName string
|
|
|
|
UserID string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-16 13:10:55 +00:00
|
|
|
// QueryAccessTokenRequest is the request for QueryAccessToken
|
|
|
|
type QueryAccessTokenRequest struct {
|
|
|
|
AccessToken string
|
|
|
|
// optional user ID, valid only if the token is an appservice.
|
|
|
|
// https://matrix.org/docs/spec/application_service/r0.1.2#using-sync-and-events
|
|
|
|
AppServiceUserID string
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryAccessTokenResponse is the response for QueryAccessToken
|
|
|
|
type QueryAccessTokenResponse struct {
|
|
|
|
Device *Device
|
2021-12-03 17:18:35 +00:00
|
|
|
Err string // e.g ErrorForbidden
|
2020-06-15 08:54:11 +00:00
|
|
|
}
|
|
|
|
|
2020-06-16 16:05:38 +00:00
|
|
|
// QueryAccountDataRequest is the request for QueryAccountData
|
|
|
|
type QueryAccountDataRequest struct {
|
2020-06-18 17:36:03 +00:00
|
|
|
UserID string // required: the user to get account data for.
|
|
|
|
RoomID string // optional: the room ID, or global account data if not specified.
|
|
|
|
DataType string // optional: the data type, or all types if not specified.
|
2020-06-16 16:05:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// QueryAccountDataResponse is the response for QueryAccountData
|
|
|
|
type QueryAccountDataResponse struct {
|
2020-06-18 17:36:03 +00:00
|
|
|
GlobalAccountData map[string]json.RawMessage // type -> data
|
|
|
|
RoomAccountData map[string]map[string]json.RawMessage // room -> type -> data
|
2020-06-16 16:05:38 +00:00
|
|
|
}
|
|
|
|
|
2020-06-16 13:53:19 +00:00
|
|
|
// QueryDevicesRequest is the request for QueryDevices
|
|
|
|
type QueryDevicesRequest struct {
|
|
|
|
UserID string
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryDevicesResponse is the response for QueryDevices
|
|
|
|
type QueryDevicesResponse struct {
|
|
|
|
UserExists bool
|
|
|
|
Devices []Device
|
|
|
|
}
|
|
|
|
|
2020-06-15 08:54:11 +00:00
|
|
|
// QueryProfileRequest is the request for QueryProfile
|
|
|
|
type QueryProfileRequest struct {
|
|
|
|
// The user ID to query
|
|
|
|
UserID string
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryProfileResponse is the response for QueryProfile
|
|
|
|
type QueryProfileResponse struct {
|
2020-06-16 13:10:55 +00:00
|
|
|
// True if the user exists. Querying for a profile does not create them.
|
2020-06-15 08:54:11 +00:00
|
|
|
UserExists bool
|
|
|
|
// The current display name if set.
|
|
|
|
DisplayName string
|
|
|
|
// The current avatar URL if set.
|
|
|
|
AvatarURL string
|
|
|
|
}
|
2020-06-16 13:10:55 +00:00
|
|
|
|
2020-07-28 09:53:17 +00:00
|
|
|
// QuerySearchProfilesRequest is the request for QueryProfile
|
|
|
|
type QuerySearchProfilesRequest struct {
|
|
|
|
// The search string to match
|
|
|
|
SearchString string
|
|
|
|
// How many results to return
|
|
|
|
Limit int
|
|
|
|
}
|
|
|
|
|
|
|
|
// QuerySearchProfilesResponse is the response for QuerySearchProfilesRequest
|
|
|
|
type QuerySearchProfilesResponse struct {
|
|
|
|
// Profiles matching the search
|
|
|
|
Profiles []authtypes.Profile
|
|
|
|
}
|
|
|
|
|
2020-06-16 16:39:56 +00:00
|
|
|
// PerformAccountCreationRequest is the request for PerformAccountCreation
|
|
|
|
type PerformAccountCreationRequest struct {
|
2020-06-17 10:22:26 +00:00
|
|
|
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
|
2020-06-16 16:39:56 +00:00
|
|
|
OnConflict Conflict
|
|
|
|
}
|
|
|
|
|
|
|
|
// PerformAccountCreationResponse is the response for PerformAccountCreation
|
|
|
|
type PerformAccountCreationResponse struct {
|
|
|
|
AccountCreated bool
|
2020-06-17 10:22:26 +00:00
|
|
|
Account *Account
|
2020-06-16 16:39:56 +00:00
|
|
|
}
|
|
|
|
|
2020-09-04 14:16:13 +00:00
|
|
|
// PerformAccountCreationRequest is the request for PerformAccountCreation
|
|
|
|
type PerformPasswordUpdateRequest struct {
|
|
|
|
Localpart string // Required: The localpart for this account.
|
|
|
|
Password string // Required: The new password to set.
|
|
|
|
}
|
|
|
|
|
|
|
|
// PerformAccountCreationResponse is the response for PerformAccountCreation
|
|
|
|
type PerformPasswordUpdateResponse struct {
|
|
|
|
PasswordUpdated bool
|
|
|
|
Account *Account
|
|
|
|
}
|
|
|
|
|
2020-11-20 11:29:02 +00:00
|
|
|
// PerformLastSeenUpdateRequest is the request for PerformLastSeenUpdate.
|
|
|
|
type PerformLastSeenUpdateRequest struct {
|
|
|
|
UserID string
|
|
|
|
DeviceID string
|
|
|
|
RemoteAddr string
|
|
|
|
}
|
|
|
|
|
|
|
|
// PerformLastSeenUpdateResponse is the response for PerformLastSeenUpdate.
|
|
|
|
type PerformLastSeenUpdateResponse struct {
|
|
|
|
}
|
|
|
|
|
2020-06-16 16:39:56 +00:00
|
|
|
// PerformDeviceCreationRequest is the request for PerformDeviceCreation
|
|
|
|
type PerformDeviceCreationRequest struct {
|
|
|
|
Localpart string
|
|
|
|
AccessToken string // optional: if blank one will be made on your behalf
|
|
|
|
// optional: if nil an ID is generated for you. If set, replaces any existing device session,
|
|
|
|
// which will generate a new access token and invalidate the old one.
|
|
|
|
DeviceID *string
|
|
|
|
// optional: if nil no display name will be associated with this device.
|
|
|
|
DeviceDisplayName *string
|
2020-10-09 08:17:23 +00:00
|
|
|
// IP address of this device
|
|
|
|
IPAddr string
|
|
|
|
// Useragent for this device
|
|
|
|
UserAgent string
|
2021-12-03 17:18:35 +00:00
|
|
|
// NoDeviceListUpdate determines whether we should avoid sending a device list
|
|
|
|
// update for this account. Generally the only reason to do this is if the account
|
|
|
|
// is an appservice account.
|
|
|
|
NoDeviceListUpdate bool
|
2020-06-16 16:39:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PerformDeviceCreationResponse is the response for PerformDeviceCreation
|
|
|
|
type PerformDeviceCreationResponse struct {
|
|
|
|
DeviceCreated bool
|
2020-06-17 10:22:26 +00:00
|
|
|
Device *Device
|
2020-06-16 16:39:56 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 16:18:20 +00:00
|
|
|
// PerformAccountDeactivationRequest is the request for PerformAccountDeactivation
|
|
|
|
type PerformAccountDeactivationRequest struct {
|
|
|
|
Localpart string
|
|
|
|
}
|
|
|
|
|
|
|
|
// PerformAccountDeactivationResponse is the response for PerformAccountDeactivation
|
|
|
|
type PerformAccountDeactivationResponse struct {
|
|
|
|
AccountDeactivated bool
|
|
|
|
}
|
|
|
|
|
2021-04-07 12:26:20 +00:00
|
|
|
// PerformOpenIDTokenCreationRequest is the request for PerformOpenIDTokenCreation
|
|
|
|
type PerformOpenIDTokenCreationRequest struct {
|
|
|
|
UserID string
|
|
|
|
}
|
|
|
|
|
|
|
|
// PerformOpenIDTokenCreationResponse is the response for PerformOpenIDTokenCreation
|
|
|
|
type PerformOpenIDTokenCreationResponse struct {
|
|
|
|
Token OpenIDToken
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryOpenIDTokenRequest is the request for QueryOpenIDToken
|
|
|
|
type QueryOpenIDTokenRequest struct {
|
|
|
|
Token string
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryOpenIDTokenResponse is the response for QueryOpenIDToken
|
|
|
|
type QueryOpenIDTokenResponse struct {
|
|
|
|
Sub string // The Matrix User ID that generated the token
|
|
|
|
ExpiresAtMS int64
|
|
|
|
}
|
|
|
|
|
2020-06-16 13:10:55 +00:00
|
|
|
// Device represents a client's device (mobile, web, etc)
|
|
|
|
type Device struct {
|
|
|
|
ID string
|
|
|
|
UserID string
|
|
|
|
// The access_token granted to this device.
|
|
|
|
// This uniquely identifies the device from all other devices and clients.
|
|
|
|
AccessToken string
|
|
|
|
// The unique ID of the session identified by the access token.
|
|
|
|
// Can be used as a secure substitution in places where data needs to be
|
|
|
|
// associated with access tokens.
|
2020-08-27 17:53:40 +00:00
|
|
|
SessionID int64
|
2020-06-16 13:10:55 +00:00
|
|
|
DisplayName string
|
2020-10-09 08:17:23 +00:00
|
|
|
LastSeenTS int64
|
|
|
|
LastSeenIP string
|
|
|
|
UserAgent string
|
2021-03-03 16:27:44 +00:00
|
|
|
// If the device is for an appservice user,
|
|
|
|
// this is the appservice ID.
|
|
|
|
AppserviceID string
|
2020-06-16 13:10:55 +00:00
|
|
|
}
|
|
|
|
|
2020-06-17 10:22:26 +00:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2021-04-07 12:26:20 +00:00
|
|
|
// OpenIDToken represents an OpenID token
|
|
|
|
type OpenIDToken struct {
|
|
|
|
Token string
|
|
|
|
UserID string
|
|
|
|
ExpiresAtMS int64
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpenIDTokenInfo represents the attributes associated with an issued OpenID token
|
|
|
|
type OpenIDTokenAttributes struct {
|
|
|
|
UserID string
|
|
|
|
ExpiresAtMS int64
|
|
|
|
}
|
|
|
|
|
|
|
|
// UserInfo is for returning information about the user an OpenID token was issued for
|
|
|
|
type UserInfo struct {
|
|
|
|
Sub string // The Matrix user's ID who generated the token
|
|
|
|
}
|
|
|
|
|
2020-06-16 13:10:55 +00:00
|
|
|
// ErrorForbidden is an error indicating that the supplied access token is forbidden
|
|
|
|
type ErrorForbidden struct {
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *ErrorForbidden) Error() string {
|
|
|
|
return "Forbidden: " + e.Message
|
|
|
|
}
|
2020-06-16 16:39:56 +00:00
|
|
|
|
|
|
|
// ErrorConflict is an error indicating that there was a conflict which resulted in the request being aborted.
|
|
|
|
type ErrorConflict struct {
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *ErrorConflict) Error() string {
|
|
|
|
return "Conflict: " + e.Message
|
|
|
|
}
|
|
|
|
|
|
|
|
// Conflict is an enum representing what to do when encountering conflicting when creating profiles/devices
|
|
|
|
type Conflict int
|
|
|
|
|
2020-06-17 10:22:26 +00:00
|
|
|
// AccountType is an enum representing the kind of account
|
|
|
|
type AccountType int
|
|
|
|
|
2020-06-16 16:39:56 +00:00
|
|
|
const (
|
|
|
|
// ConflictUpdate will update matching records returning no error
|
|
|
|
ConflictUpdate Conflict = 1
|
|
|
|
// ConflictAbort will reject the request with ErrorConflict
|
|
|
|
ConflictAbort Conflict = 2
|
2020-06-17 10:22:26 +00:00
|
|
|
|
|
|
|
// AccountTypeUser indicates this is a user account
|
|
|
|
AccountTypeUser AccountType = 1
|
|
|
|
// AccountTypeGuest indicates this is a guest account
|
|
|
|
AccountTypeGuest AccountType = 2
|
2020-06-16 16:39:56 +00:00
|
|
|
)
|