aboutsummaryrefslogtreecommitdiff
path: root/userapi/api
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2020-06-18 18:36:03 +0100
committerGitHub <noreply@github.com>2020-06-18 18:36:03 +0100
commitdc0bac85d5bad933d32ee63f8bc1aef6348ca6e9 (patch)
tree78d5e0fc237e0104d525071af83d550d6a314d49 /userapi/api
parent3547a1768c36626c672e5c7834f297496f568b2f (diff)
Refactor account data (#1150)
* Refactor account data * Tweak database fetching * Tweaks * Restore syncProducer notification * Various tweaks, update tag behaviour * Fix initial sync
Diffstat (limited to 'userapi/api')
-rw-r--r--userapi/api/api.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/userapi/api/api.go b/userapi/api/api.go
index c953a5ba..a80adf2d 100644
--- a/userapi/api/api.go
+++ b/userapi/api/api.go
@@ -16,12 +16,14 @@ package api
import (
"context"
+ "encoding/json"
"github.com/matrix-org/gomatrixserverlib"
)
// UserInternalAPI is the internal API for information about users and devices.
type UserInternalAPI interface {
+ InputAccountData(ctx context.Context, req *InputAccountDataRequest, res *InputAccountDataResponse) error
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
@@ -30,6 +32,18 @@ type UserInternalAPI interface {
QueryAccountData(ctx context.Context, req *QueryAccountDataRequest, res *QueryAccountDataResponse) error
}
+// 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
+ DataType string // optional: the data type of the data
+ AccountData json.RawMessage // required: the message content
+}
+
+// InputAccountDataResponse is the response for InputAccountData
+type InputAccountDataResponse struct {
+}
+
// QueryAccessTokenRequest is the request for QueryAccessToken
type QueryAccessTokenRequest struct {
AccessToken string
@@ -46,18 +60,15 @@ type QueryAccessTokenResponse struct {
// QueryAccountDataRequest is the request for QueryAccountData
type QueryAccountDataRequest struct {
- UserID string // required: the user to get account data for.
- // TODO: This is a terribly confusing API shape :/
- DataType string // optional: if specified returns only a single event matching this data type.
- // optional: Only used if DataType is set. If blank returns global account data matching the data type.
- // If set, returns only room account data matching this data type.
- RoomID string
+ 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.
}
// QueryAccountDataResponse is the response for QueryAccountData
type QueryAccountDataResponse struct {
- GlobalAccountData []gomatrixserverlib.ClientEvent
- RoomAccountData map[string][]gomatrixserverlib.ClientEvent
+ GlobalAccountData map[string]json.RawMessage // type -> data
+ RoomAccountData map[string]map[string]json.RawMessage // room -> type -> data
}
// QueryDevicesRequest is the request for QueryDevices