mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
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
This commit is contained in:
parent
83391da0e0
commit
e15a8042a1
19 changed files with 207 additions and 53 deletions
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue