aboutsummaryrefslogtreecommitdiff
path: root/userapi/api
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-06-16 17:39:56 +0100
committerGitHub <noreply@github.com>2020-06-16 17:39:56 +0100
commite15a8042a19b270060beef1358f90cda075ddd38 (patch)
treefaa2334c37ec7b0753541bbe000a16b4ac13548d /userapi/api
parent83391da0e04dda7a52589ee7ec6df2b615571894 (diff)
BREAKING: Make eduserver/appservice use userapi (#1138)
* BREAKING: Make eduserver/appservice use userapi This is a breaking change because this PR restructures how the AS API tracks its position in Kafka streams. Previously, it used the account DB to store partition offsets. However, this is also being used by `clientapi` for the same purpose, which is bad (each component needs to store offsets independently or else you might lose messages across restarts). This PR changes this behaviour to now store partition offsets in the `appservice` database. This means that: - Upon restart, the `appservice` component will attempt to replay all room events from the beginning of time. - An additional table will be created in the appservice database, which in and of itself is backwards compatible. * Return ErrorConflict
Diffstat (limited to 'userapi/api')
-rw-r--r--userapi/api/api.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/userapi/api/api.go b/userapi/api/api.go
index 1578268a..34c74bb3 100644
--- a/userapi/api/api.go
+++ b/userapi/api/api.go
@@ -22,6 +22,8 @@ import (
// UserInternalAPI is the internal API for information about users and devices.
type UserInternalAPI interface {
+ PerformAccountCreation(ctx context.Context, req *PerformAccountCreationRequest, res *PerformAccountCreationResponse) error
+ PerformDeviceCreation(ctx context.Context, req *PerformDeviceCreationRequest, res *PerformDeviceCreationResponse) error
QueryProfile(ctx context.Context, req *QueryProfileRequest, res *QueryProfileResponse) error
QueryAccessToken(ctx context.Context, req *QueryAccessTokenRequest, res *QueryAccessTokenResponse) error
QueryDevices(ctx context.Context, req *QueryDevicesRequest, res *QueryDevicesResponse) error
@@ -85,6 +87,38 @@ type QueryProfileResponse struct {
AvatarURL string
}
+// PerformAccountCreationRequest is the request for PerformAccountCreation
+type PerformAccountCreationRequest struct {
+ Localpart string
+ AppServiceID string
+ Password string
+ OnConflict Conflict
+}
+
+// PerformAccountCreationResponse is the response for PerformAccountCreation
+type PerformAccountCreationResponse struct {
+ AccountCreated bool
+ UserID string
+}
+
+// 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
+}
+
+// PerformDeviceCreationResponse is the response for PerformDeviceCreation
+type PerformDeviceCreationResponse struct {
+ DeviceCreated bool
+ AccessToken string
+ DeviceID string
+}
+
// Device represents a client's device (mobile, web, etc)
type Device struct {
ID string
@@ -108,3 +142,22 @@ type ErrorForbidden struct {
func (e *ErrorForbidden) Error() string {
return "Forbidden: " + e.Message
}
+
+// 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
+
+const (
+ // ConflictUpdate will update matching records returning no error
+ ConflictUpdate Conflict = 1
+ // ConflictAbort will reject the request with ErrorConflict
+ ConflictAbort Conflict = 2
+)