aboutsummaryrefslogtreecommitdiff
path: root/userapi/api
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2023-04-03 20:19:26 +0200
committerGitHub <noreply@github.com>2023-04-03 20:19:26 +0200
commitc2db38d2954b8d5d1944b64671985d5ffd3b5c28 (patch)
tree7199fa013869cd7298562d75f6e94f8321da8a15 /userapi/api
parent4cb9cd7842e58b542b25a2e9d7cdb7f61d147e96 (diff)
Add user profile tests, refactor user API methods (#3030)
This adds tests for `/profile`. Also, as a first change in this regard, refactors the methods defined on the `UserInternalAPI` to not use structs as the request/response parameters.
Diffstat (limited to 'userapi/api')
-rw-r--r--userapi/api/api.go49
1 files changed, 8 insertions, 41 deletions
diff --git a/userapi/api/api.go b/userapi/api/api.go
index 19d48684..5fd7992c 100644
--- a/userapi/api/api.go
+++ b/userapi/api/api.go
@@ -58,7 +58,7 @@ type MediaUserAPI interface {
type FederationUserAPI interface {
UploadDeviceKeysAPI
QueryOpenIDToken(ctx context.Context, req *QueryOpenIDTokenRequest, res *QueryOpenIDTokenResponse) error
- QueryProfile(ctx context.Context, req *QueryProfileRequest, res *QueryProfileResponse) error
+ QueryProfile(ctx context.Context, userID string) (*authtypes.Profile, error)
QueryDevices(ctx context.Context, req *QueryDevicesRequest, res *QueryDevicesResponse) error
QueryKeys(ctx context.Context, req *QueryKeysRequest, res *QueryKeysResponse) error
QuerySignatures(ctx context.Context, req *QuerySignaturesRequest, res *QuerySignaturesResponse) error
@@ -83,9 +83,9 @@ type ClientUserAPI interface {
LoginTokenInternalAPI
UserLoginAPI
ClientKeyAPI
+ ProfileAPI
QueryNumericLocalpart(ctx context.Context, req *QueryNumericLocalpartRequest, res *QueryNumericLocalpartResponse) error
QueryDevices(ctx context.Context, req *QueryDevicesRequest, res *QueryDevicesResponse) error
- QueryProfile(ctx context.Context, req *QueryProfileRequest, res *QueryProfileResponse) error
QueryAccountData(ctx context.Context, req *QueryAccountDataRequest, res *QueryAccountDataResponse) error
QueryPushers(ctx context.Context, req *QueryPushersRequest, res *QueryPushersResponse) error
QueryPushRules(ctx context.Context, req *QueryPushRulesRequest, res *QueryPushRulesResponse) error
@@ -100,8 +100,6 @@ type ClientUserAPI interface {
PerformPushRulesPut(ctx context.Context, req *PerformPushRulesPutRequest, res *struct{}) error
PerformAccountDeactivation(ctx context.Context, req *PerformAccountDeactivationRequest, res *PerformAccountDeactivationResponse) error
PerformOpenIDTokenCreation(ctx context.Context, req *PerformOpenIDTokenCreationRequest, res *PerformOpenIDTokenCreationResponse) error
- SetAvatarURL(ctx context.Context, req *PerformSetAvatarURLRequest, res *PerformSetAvatarURLResponse) error
- SetDisplayName(ctx context.Context, req *PerformUpdateDisplayNameRequest, res *PerformUpdateDisplayNameResponse) error
QueryNotifications(ctx context.Context, req *QueryNotificationsRequest, res *QueryNotificationsResponse) error
InputAccountData(ctx context.Context, req *InputAccountDataRequest, res *InputAccountDataResponse) error
PerformKeyBackup(ctx context.Context, req *PerformKeyBackupRequest, res *PerformKeyBackupResponse) error
@@ -113,6 +111,12 @@ type ClientUserAPI interface {
PerformSaveThreePIDAssociation(ctx context.Context, req *PerformSaveThreePIDAssociationRequest, res *struct{}) error
}
+type ProfileAPI interface {
+ QueryProfile(ctx context.Context, userID string) (*authtypes.Profile, error)
+ SetAvatarURL(ctx context.Context, localpart string, serverName gomatrixserverlib.ServerName, avatarURL string) (*authtypes.Profile, bool, error)
+ SetDisplayName(ctx context.Context, localpart string, serverName gomatrixserverlib.ServerName, displayName string) (*authtypes.Profile, bool, error)
+}
+
// custom api functions required by pinecone / p2p demos
type QuerySearchProfilesAPI interface {
QuerySearchProfiles(ctx context.Context, req *QuerySearchProfilesRequest, res *QuerySearchProfilesResponse) error
@@ -290,22 +294,6 @@ type QueryDevicesResponse struct {
Devices []Device
}
-// 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 {
- // True if the user exists. Querying for a profile does not create them.
- UserExists bool
- // The current display name if set.
- DisplayName string
- // The current avatar URL if set.
- AvatarURL string
-}
-
// QuerySearchProfilesRequest is the request for QueryProfile
type QuerySearchProfilesRequest struct {
// The search string to match
@@ -600,16 +588,6 @@ type Notification struct {
TS gomatrixserverlib.Timestamp `json:"ts"` // Required.
}
-type PerformSetAvatarURLRequest struct {
- Localpart string
- ServerName gomatrixserverlib.ServerName
- AvatarURL string
-}
-type PerformSetAvatarURLResponse struct {
- Profile *authtypes.Profile `json:"profile"`
- Changed bool `json:"changed"`
-}
-
type QueryNumericLocalpartRequest struct {
ServerName gomatrixserverlib.ServerName
}
@@ -638,17 +616,6 @@ type QueryAccountByPasswordResponse struct {
Exists bool
}
-type PerformUpdateDisplayNameRequest struct {
- Localpart string
- ServerName gomatrixserverlib.ServerName
- DisplayName string
-}
-
-type PerformUpdateDisplayNameResponse struct {
- Profile *authtypes.Profile `json:"profile"`
- Changed bool `json:"changed"`
-}
-
type QueryLocalpartForThreePIDRequest struct {
ThreePID, Medium string
}