aboutsummaryrefslogtreecommitdiff
path: root/clientapi
diff options
context:
space:
mode:
Diffstat (limited to 'clientapi')
-rw-r--r--clientapi/auth/login.go2
-rw-r--r--clientapi/auth/login_test.go5
-rw-r--r--clientapi/auth/user_interactive.go2
-rw-r--r--clientapi/auth/user_interactive_test.go4
-rw-r--r--clientapi/clientapi.go8
-rw-r--r--clientapi/producers/syncapi.go2
-rw-r--r--clientapi/routing/account_data.go6
-rw-r--r--clientapi/routing/admin.go2
-rw-r--r--clientapi/routing/admin_whois.go2
-rw-r--r--clientapi/routing/aliases.go2
-rw-r--r--clientapi/routing/capabilities.go2
-rw-r--r--clientapi/routing/createroom.go30
-rw-r--r--clientapi/routing/deactivate.go2
-rw-r--r--clientapi/routing/device.go10
-rw-r--r--clientapi/routing/directory.go12
-rw-r--r--clientapi/routing/directory_public.go6
-rw-r--r--clientapi/routing/getevent.go5
-rw-r--r--clientapi/routing/joinroom.go4
-rw-r--r--clientapi/routing/key_backup.go12
-rw-r--r--clientapi/routing/key_crosssigning.go6
-rw-r--r--clientapi/routing/keys.go6
-rw-r--r--clientapi/routing/leaveroom.go2
-rw-r--r--clientapi/routing/login.go4
-rw-r--r--clientapi/routing/logout.go4
-rw-r--r--clientapi/routing/membership.go74
-rw-r--r--clientapi/routing/memberships.go4
-rw-r--r--clientapi/routing/notification.go2
-rw-r--r--clientapi/routing/openid.go2
-rw-r--r--clientapi/routing/password.go2
-rw-r--r--clientapi/routing/peekroom.go4
-rw-r--r--clientapi/routing/profile.go18
-rw-r--r--clientapi/routing/pusher.go4
-rw-r--r--clientapi/routing/pushrules.go20
-rw-r--r--clientapi/routing/redaction.go2
-rw-r--r--clientapi/routing/register.go16
-rw-r--r--clientapi/routing/room_tagging.go10
-rw-r--r--clientapi/routing/routing.go12
-rw-r--r--clientapi/routing/sendevent.go4
-rw-r--r--clientapi/routing/sendtyping.go2
-rw-r--r--clientapi/routing/server_notices.go6
-rw-r--r--clientapi/routing/state.go4
-rw-r--r--clientapi/routing/threepid.go8
-rw-r--r--clientapi/routing/upgrade_room.go4
-rw-r--r--clientapi/routing/userdirectory.go14
-rw-r--r--clientapi/threepid/invites.go14
45 files changed, 180 insertions, 186 deletions
diff --git a/clientapi/auth/login.go b/clientapi/auth/login.go
index 020731c9..5f51c662 100644
--- a/clientapi/auth/login.go
+++ b/clientapi/auth/login.go
@@ -33,7 +33,7 @@ import (
// called after authorization has completed, with the result of the authorization.
// If the final return value is non-nil, an error occurred and the cleanup function
// is nil.
-func LoginFromJSONReader(ctx context.Context, r io.Reader, useraccountAPI uapi.UserAccountAPI, userAPI UserInternalAPIForLogin, cfg *config.ClientAPI) (*Login, LoginCleanupFunc, *util.JSONResponse) {
+func LoginFromJSONReader(ctx context.Context, r io.Reader, useraccountAPI uapi.UserLoginAPI, userAPI UserInternalAPIForLogin, cfg *config.ClientAPI) (*Login, LoginCleanupFunc, *util.JSONResponse) {
reqBytes, err := ioutil.ReadAll(r)
if err != nil {
err := &util.JSONResponse{
diff --git a/clientapi/auth/login_test.go b/clientapi/auth/login_test.go
index d401469c..5085f017 100644
--- a/clientapi/auth/login_test.go
+++ b/clientapi/auth/login_test.go
@@ -160,7 +160,6 @@ func TestBadLoginFromJSONReader(t *testing.T) {
type fakeUserInternalAPI struct {
UserInternalAPIForLogin
- uapi.UserAccountAPI
DeletedTokens []string
}
@@ -179,6 +178,10 @@ func (ua *fakeUserInternalAPI) PerformLoginTokenDeletion(ctx context.Context, re
return nil
}
+func (ua *fakeUserInternalAPI) PerformLoginTokenCreation(ctx context.Context, req *uapi.PerformLoginTokenCreationRequest, res *uapi.PerformLoginTokenCreationResponse) error {
+ return nil
+}
+
func (*fakeUserInternalAPI) QueryLoginToken(ctx context.Context, req *uapi.QueryLoginTokenRequest, res *uapi.QueryLoginTokenResponse) error {
if req.Token == "invalidtoken" {
return nil
diff --git a/clientapi/auth/user_interactive.go b/clientapi/auth/user_interactive.go
index 22c430f9..6caf7dcd 100644
--- a/clientapi/auth/user_interactive.go
+++ b/clientapi/auth/user_interactive.go
@@ -110,7 +110,7 @@ type UserInteractive struct {
Sessions map[string][]string
}
-func NewUserInteractive(userAccountAPI api.UserAccountAPI, cfg *config.ClientAPI) *UserInteractive {
+func NewUserInteractive(userAccountAPI api.UserLoginAPI, cfg *config.ClientAPI) *UserInteractive {
typePassword := &LoginTypePassword{
GetAccountByPassword: userAccountAPI.QueryAccountByPassword,
Config: cfg,
diff --git a/clientapi/auth/user_interactive_test.go b/clientapi/auth/user_interactive_test.go
index a4b4587a..262e4810 100644
--- a/clientapi/auth/user_interactive_test.go
+++ b/clientapi/auth/user_interactive_test.go
@@ -24,9 +24,7 @@ var (
}
)
-type fakeAccountDatabase struct {
- api.UserAccountAPI
-}
+type fakeAccountDatabase struct{}
func (d *fakeAccountDatabase) PerformPasswordUpdate(ctx context.Context, req *api.PerformPasswordUpdateRequest, res *api.PerformPasswordUpdateResponse) error {
return nil
diff --git a/clientapi/clientapi.go b/clientapi/clientapi.go
index 0d16e4c1..957d082a 100644
--- a/clientapi/clientapi.go
+++ b/clientapi/clientapi.go
@@ -33,13 +33,13 @@ import (
func AddPublicRoutes(
base *base.BaseDendrite,
federation *gomatrixserverlib.FederationClient,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
transactionsCache *transactions.Cache,
- fsAPI federationAPI.FederationInternalAPI,
- userAPI userapi.UserInternalAPI,
+ fsAPI federationAPI.ClientFederationAPI,
+ userAPI userapi.ClientUserAPI,
userDirectoryProvider userapi.UserDirectoryProvider,
- keyAPI keyserverAPI.KeyInternalAPI,
+ keyAPI keyserverAPI.ClientKeyAPI,
extRoomsProvider api.ExtraPublicRoomsProvider,
) {
cfg := &base.Cfg.ClientAPI
diff --git a/clientapi/producers/syncapi.go b/clientapi/producers/syncapi.go
index 187e3412..48b1ae88 100644
--- a/clientapi/producers/syncapi.go
+++ b/clientapi/producers/syncapi.go
@@ -38,7 +38,7 @@ type SyncAPIProducer struct {
TopicPresenceEvent string
JetStream nats.JetStreamContext
ServerName gomatrixserverlib.ServerName
- UserAPI userapi.UserInternalAPI
+ UserAPI userapi.ClientUserAPI
}
// SendData sends account data to the sync API server
diff --git a/clientapi/routing/account_data.go b/clientapi/routing/account_data.go
index d0dd3ab8..a5a3014a 100644
--- a/clientapi/routing/account_data.go
+++ b/clientapi/routing/account_data.go
@@ -33,7 +33,7 @@ import (
// GetAccountData implements GET /user/{userId}/[rooms/{roomid}/]account_data/{type}
func GetAccountData(
- req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.ClientUserAPI, device *api.Device,
userID string, roomID string, dataType string,
) util.JSONResponse {
if userID != device.UserID {
@@ -76,7 +76,7 @@ func GetAccountData(
// SaveAccountData implements PUT /user/{userId}/[rooms/{roomId}/]account_data/{type}
func SaveAccountData(
- req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.ClientUserAPI, device *api.Device,
userID string, roomID string, dataType string, syncProducer *producers.SyncAPIProducer,
) util.JSONResponse {
if userID != device.UserID {
@@ -152,7 +152,7 @@ type fullyReadEvent struct {
// SaveReadMarker implements POST /rooms/{roomId}/read_markers
func SaveReadMarker(
req *http.Request,
- userAPI api.UserInternalAPI, rsAPI roomserverAPI.RoomserverInternalAPI,
+ userAPI api.ClientUserAPI, rsAPI roomserverAPI.ClientRoomserverAPI,
syncProducer *producers.SyncAPIProducer, device *api.Device, roomID string,
) util.JSONResponse {
// Verify that the user is a member of this room
diff --git a/clientapi/routing/admin.go b/clientapi/routing/admin.go
index 31e431c7..125b3847 100644
--- a/clientapi/routing/admin.go
+++ b/clientapi/routing/admin.go
@@ -11,7 +11,7 @@ import (
"github.com/matrix-org/util"
)
-func AdminEvacuateRoom(req *http.Request, device *userapi.Device, rsAPI roomserverAPI.RoomserverInternalAPI) util.JSONResponse {
+func AdminEvacuateRoom(req *http.Request, device *userapi.Device, rsAPI roomserverAPI.ClientRoomserverAPI) util.JSONResponse {
if device.AccountType != userapi.AccountTypeAdmin {
return util.JSONResponse{
Code: http.StatusForbidden,
diff --git a/clientapi/routing/admin_whois.go b/clientapi/routing/admin_whois.go
index 87bb7936..f1cbd346 100644
--- a/clientapi/routing/admin_whois.go
+++ b/clientapi/routing/admin_whois.go
@@ -44,7 +44,7 @@ type connectionInfo struct {
// GetAdminWhois implements GET /admin/whois/{userId}
func GetAdminWhois(
- req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.ClientUserAPI, device *api.Device,
userID string,
) util.JSONResponse {
allowed := device.AccountType == api.AccountTypeAdmin || userID == device.UserID
diff --git a/clientapi/routing/aliases.go b/clientapi/routing/aliases.go
index 8c483053..504d6026 100644
--- a/clientapi/routing/aliases.go
+++ b/clientapi/routing/aliases.go
@@ -28,7 +28,7 @@ import (
// GetAliases implements GET /_matrix/client/r0/rooms/{roomId}/aliases
func GetAliases(
- req *http.Request, rsAPI api.RoomserverInternalAPI, device *userapi.Device, roomID string,
+ req *http.Request, rsAPI api.ClientRoomserverAPI, device *userapi.Device, roomID string,
) util.JSONResponse {
stateTuple := gomatrixserverlib.StateKeyTuple{
EventType: gomatrixserverlib.MRoomHistoryVisibility,
diff --git a/clientapi/routing/capabilities.go b/clientapi/routing/capabilities.go
index 72668fa5..b7d47e91 100644
--- a/clientapi/routing/capabilities.go
+++ b/clientapi/routing/capabilities.go
@@ -26,7 +26,7 @@ import (
// GetCapabilities returns information about the server's supported feature set
// and other relevant capabilities to an authenticated user.
func GetCapabilities(
- req *http.Request, rsAPI roomserverAPI.RoomserverInternalAPI,
+ req *http.Request, rsAPI roomserverAPI.ClientRoomserverAPI,
) util.JSONResponse {
roomVersionsQueryReq := roomserverAPI.QueryRoomVersionCapabilitiesRequest{}
roomVersionsQueryRes := roomserverAPI.QueryRoomVersionCapabilitiesResponse{}
diff --git a/clientapi/routing/createroom.go b/clientapi/routing/createroom.go
index 4976b3e5..a21abb0e 100644
--- a/clientapi/routing/createroom.go
+++ b/clientapi/routing/createroom.go
@@ -137,7 +137,7 @@ type fledglingEvent struct {
func CreateRoom(
req *http.Request, device *api.Device,
cfg *config.ClientAPI,
- profileAPI api.UserProfileAPI, rsAPI roomserverAPI.RoomserverInternalAPI,
+ profileAPI api.ClientUserAPI, rsAPI roomserverAPI.ClientRoomserverAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
) util.JSONResponse {
var r createRoomRequest
@@ -164,7 +164,7 @@ func createRoom(
ctx context.Context,
r createRoomRequest, device *api.Device,
cfg *config.ClientAPI,
- profileAPI api.UserProfileAPI, rsAPI roomserverAPI.RoomserverInternalAPI,
+ profileAPI api.ClientUserAPI, rsAPI roomserverAPI.ClientRoomserverAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
evTime time.Time,
) util.JSONResponse {
@@ -531,25 +531,23 @@ func createRoom(
gomatrixserverlib.NewInviteV2StrippedState(inviteEvent.Event),
)
// Send the invite event to the roomserver.
- err = roomserverAPI.SendInvite(
- ctx,
- rsAPI,
- inviteEvent.Headered(roomVersion),
- inviteStrippedState, // invite room state
- cfg.Matrix.ServerName, // send as server
- nil, // transaction ID
- )
- switch e := err.(type) {
- case *roomserverAPI.PerformError:
- return e.JSONResponse()
- case nil:
- default:
- util.GetLogger(ctx).WithError(err).Error("roomserverAPI.SendInvite failed")
+ var inviteRes roomserverAPI.PerformInviteResponse
+ event := inviteEvent.Headered(roomVersion)
+ if err := rsAPI.PerformInvite(ctx, &roomserverAPI.PerformInviteRequest{
+ Event: event,
+ InviteRoomState: inviteStrippedState,
+ RoomVersion: event.RoomVersion,
+ SendAsServer: string(cfg.Matrix.ServerName),
+ }, &inviteRes); err != nil {
+ util.GetLogger(ctx).WithError(err).Error("PerformInvite failed")
return util.JSONResponse{
Code: http.StatusInternalServerError,
JSON: jsonerror.InternalServerError(),
}
}
+ if inviteRes.Error != nil {
+ return inviteRes.Error.JSONResponse()
+ }
}
}
diff --git a/clientapi/routing/deactivate.go b/clientapi/routing/deactivate.go
index da1b6dcf..c8aa6a3b 100644
--- a/clientapi/routing/deactivate.go
+++ b/clientapi/routing/deactivate.go
@@ -15,7 +15,7 @@ import (
func Deactivate(
req *http.Request,
userInteractiveAuth *auth.UserInteractive,
- accountAPI api.UserAccountAPI,
+ accountAPI api.ClientUserAPI,
deviceAPI *api.Device,
) util.JSONResponse {
ctx := req.Context()
diff --git a/clientapi/routing/device.go b/clientapi/routing/device.go
index 161bc273..bb1cf47b 100644
--- a/clientapi/routing/device.go
+++ b/clientapi/routing/device.go
@@ -50,7 +50,7 @@ type devicesDeleteJSON struct {
// GetDeviceByID handles /devices/{deviceID}
func GetDeviceByID(
- req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.ClientUserAPI, device *api.Device,
deviceID string,
) util.JSONResponse {
var queryRes api.QueryDevicesResponse
@@ -88,7 +88,7 @@ func GetDeviceByID(
// GetDevicesByLocalpart handles /devices
func GetDevicesByLocalpart(
- req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.ClientUserAPI, device *api.Device,
) util.JSONResponse {
var queryRes api.QueryDevicesResponse
err := userAPI.QueryDevices(req.Context(), &api.QueryDevicesRequest{
@@ -118,7 +118,7 @@ func GetDevicesByLocalpart(
// UpdateDeviceByID handles PUT on /devices/{deviceID}
func UpdateDeviceByID(
- req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.ClientUserAPI, device *api.Device,
deviceID string,
) util.JSONResponse {
@@ -161,7 +161,7 @@ func UpdateDeviceByID(
// DeleteDeviceById handles DELETE requests to /devices/{deviceId}
func DeleteDeviceById(
- req *http.Request, userInteractiveAuth *auth.UserInteractive, userAPI api.UserInternalAPI, device *api.Device,
+ req *http.Request, userInteractiveAuth *auth.UserInteractive, userAPI api.ClientUserAPI, device *api.Device,
deviceID string,
) util.JSONResponse {
var (
@@ -242,7 +242,7 @@ func DeleteDeviceById(
// DeleteDevices handles POST requests to /delete_devices
func DeleteDevices(
- req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.ClientUserAPI, device *api.Device,
) util.JSONResponse {
ctx := req.Context()
payload := devicesDeleteJSON{}
diff --git a/clientapi/routing/directory.go b/clientapi/routing/directory.go
index ac355b5d..53ba3f19 100644
--- a/clientapi/routing/directory.go
+++ b/clientapi/routing/directory.go
@@ -46,8 +46,8 @@ func DirectoryRoom(
roomAlias string,
federation *gomatrixserverlib.FederationClient,
cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI,
- fedSenderAPI federationAPI.FederationInternalAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
+ fedSenderAPI federationAPI.ClientFederationAPI,
) util.JSONResponse {
_, domain, err := gomatrixserverlib.SplitID('#', roomAlias)
if err != nil {
@@ -117,7 +117,7 @@ func SetLocalAlias(
device *userapi.Device,
alias string,
cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
) util.JSONResponse {
_, domain, err := gomatrixserverlib.SplitID('#', alias)
if err != nil {
@@ -199,7 +199,7 @@ func RemoveLocalAlias(
req *http.Request,
device *userapi.Device,
alias string,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
) util.JSONResponse {
queryReq := roomserverAPI.RemoveRoomAliasRequest{
Alias: alias,
@@ -237,7 +237,7 @@ type roomVisibility struct {
// GetVisibility implements GET /directory/list/room/{roomID}
func GetVisibility(
- req *http.Request, rsAPI roomserverAPI.RoomserverInternalAPI,
+ req *http.Request, rsAPI roomserverAPI.ClientRoomserverAPI,
roomID string,
) util.JSONResponse {
var res roomserverAPI.QueryPublishedRoomsResponse
@@ -265,7 +265,7 @@ func GetVisibility(
// SetVisibility implements PUT /directory/list/room/{roomID}
// TODO: Allow admin users to edit the room visibility
func SetVisibility(
- req *http.Request, rsAPI roomserverAPI.RoomserverInternalAPI, dev *userapi.Device,
+ req *http.Request, rsAPI roomserverAPI.ClientRoomserverAPI, dev *userapi.Device,
roomID string,
) util.JSONResponse {
resErr := checkMemberInRoom(req.Context(), rsAPI, dev.UserID, roomID)
diff --git a/clientapi/routing/directory_public.go b/clientapi/routing/directory_public.go
index 0dacfced..c3e6141b 100644
--- a/clientapi/routing/directory_public.go
+++ b/clientapi/routing/directory_public.go
@@ -50,7 +50,7 @@ type filter struct {
// GetPostPublicRooms implements GET and POST /publicRooms
func GetPostPublicRooms(
- req *http.Request, rsAPI roomserverAPI.RoomserverInternalAPI,
+ req *http.Request, rsAPI roomserverAPI.ClientRoomserverAPI,
extRoomsProvider api.ExtraPublicRoomsProvider,
federation *gomatrixserverlib.FederationClient,
cfg *config.ClientAPI,
@@ -91,7 +91,7 @@ func GetPostPublicRooms(
}
func publicRooms(
- ctx context.Context, request PublicRoomReq, rsAPI roomserverAPI.RoomserverInternalAPI, extRoomsProvider api.ExtraPublicRoomsProvider,
+ ctx context.Context, request PublicRoomReq, rsAPI roomserverAPI.ClientRoomserverAPI, extRoomsProvider api.ExtraPublicRoomsProvider,
) (*gomatrixserverlib.RespPublicRooms, error) {
response := gomatrixserverlib.RespPublicRooms{
@@ -229,7 +229,7 @@ func sliceInto(slice []gomatrixserverlib.PublicRoom, since int64, limit int16) (
}
func refreshPublicRoomCache(
- ctx context.Context, rsAPI roomserverAPI.RoomserverInternalAPI, extRoomsProvider api.ExtraPublicRoomsProvider,
+ ctx context.Context, rsAPI roomserverAPI.ClientRoomserverAPI, extRoomsProvider api.ExtraPublicRoomsProvider,
) []gomatrixserverlib.PublicRoom {
cacheMu.Lock()
defer cacheMu.Unlock()
diff --git a/clientapi/routing/getevent.go b/clientapi/routing/getevent.go
index 36f3ee9e..7f584280 100644
--- a/clientapi/routing/getevent.go
+++ b/clientapi/routing/getevent.go
@@ -31,7 +31,6 @@ type getEventRequest struct {
roomID string
eventID string
cfg *config.ClientAPI
- federation *gomatrixserverlib.FederationClient
requestedEvent *gomatrixserverlib.Event
}
@@ -43,8 +42,7 @@ func GetEvent(
roomID string,
eventID string,
cfg *config.ClientAPI,
- rsAPI api.RoomserverInternalAPI,
- federation *gomatrixserverlib.FederationClient,
+ rsAPI api.ClientRoomserverAPI,
) util.JSONResponse {
eventsReq := api.QueryEventsByIDRequest{
EventIDs: []string{eventID},
@@ -72,7 +70,6 @@ func GetEvent(
roomID: roomID,
eventID: eventID,
cfg: cfg,
- federation: federation,
requestedEvent: requestedEvent,
}
diff --git a/clientapi/routing/joinroom.go b/clientapi/routing/joinroom.go
index dc15f4bd..4e6acebc 100644
--- a/clientapi/routing/joinroom.go
+++ b/clientapi/routing/joinroom.go
@@ -29,8 +29,8 @@ import (
func JoinRoomByIDOrAlias(
req *http.Request,
device *api.Device,
- rsAPI roomserverAPI.RoomserverInternalAPI,
- profileAPI api.UserProfileAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
+ profileAPI api.ClientUserAPI,
roomIDOrAlias string,
) util.JSONResponse {
// Prepare to ask the roomserver to perform the room join.
diff --git a/clientapi/routing/key_backup.go b/clientapi/routing/key_backup.go
index 9d2ff87f..28c80415 100644
--- a/clientapi/routing/key_backup.go
+++ b/clientapi/routing/key_backup.go
@@ -55,7 +55,7 @@ type keyBackupSessionResponse struct {
// Create a new key backup. Request must contain a `keyBackupVersion`. Returns a `keyBackupVersionCreateResponse`.
// Implements POST /_matrix/client/r0/room_keys/version
-func CreateKeyBackupVersion(req *http.Request, userAPI userapi.UserInternalAPI, device *userapi.Device) util.JSONResponse {
+func CreateKeyBackupVersion(req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device) util.JSONResponse {
var kb keyBackupVersion
resErr := httputil.UnmarshalJSONRequest(req, &kb)
if resErr != nil {
@@ -89,7 +89,7 @@ func CreateKeyBackupVersion(req *http.Request, userAPI userapi.UserInternalAPI,
// KeyBackupVersion returns the key backup version specified. If `version` is empty, the latest `keyBackupVersionResponse` is returned.
// Implements GET /_matrix/client/r0/room_keys/version and GET /_matrix/client/r0/room_keys/version/{version}
-func KeyBackupVersion(req *http.Request, userAPI userapi.UserInternalAPI, device *userapi.Device, version string) util.JSONResponse {
+func KeyBackupVersion(req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version string) util.JSONResponse {
var queryResp userapi.QueryKeyBackupResponse
userAPI.QueryKeyBackup(req.Context(), &userapi.QueryKeyBackupRequest{
UserID: device.UserID,
@@ -118,7 +118,7 @@ func KeyBackupVersion(req *http.Request, userAPI userapi.UserInternalAPI, device
// Modify the auth data of a key backup. Version must not be empty. Request must contain a `keyBackupVersion`
// Implements PUT /_matrix/client/r0/room_keys/version/{version}
-func ModifyKeyBackupVersionAuthData(req *http.Request, userAPI userapi.UserInternalAPI, device *userapi.Device, version string) util.JSONResponse {
+func ModifyKeyBackupVersionAuthData(req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version string) util.JSONResponse {
var kb keyBackupVersion
resErr := httputil.UnmarshalJSONRequest(req, &kb)
if resErr != nil {
@@ -159,7 +159,7 @@ func ModifyKeyBackupVersionAuthData(req *http.Request, userAPI userapi.UserInter
// Delete a version of key backup. Version must not be empty. If the key backup was previously deleted, will return 200 OK.
// Implements DELETE /_matrix/client/r0/room_keys/version/{version}
-func DeleteKeyBackupVersion(req *http.Request, userAPI userapi.UserInternalAPI, device *userapi.Device, version string) util.JSONResponse {
+func DeleteKeyBackupVersion(req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version string) util.JSONResponse {
var performKeyBackupResp userapi.PerformKeyBackupResponse
if err := userAPI.PerformKeyBackup(req.Context(), &userapi.PerformKeyBackupRequest{
UserID: device.UserID,
@@ -194,7 +194,7 @@ func DeleteKeyBackupVersion(req *http.Request, userAPI userapi.UserInternalAPI,
// Upload a bunch of session keys for a given `version`.
func UploadBackupKeys(
- req *http.Request, userAPI userapi.UserInternalAPI, device *userapi.Device, version string, keys *keyBackupSessionRequest,
+ req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version string, keys *keyBackupSessionRequest,
) util.JSONResponse {
var performKeyBackupResp userapi.PerformKeyBackupResponse
if err := userAPI.PerformKeyBackup(req.Context(), &userapi.PerformKeyBackupRequest{
@@ -230,7 +230,7 @@ func UploadBackupKeys(
// Get keys from a given backup version. Response returned varies depending on if roomID and sessionID are set.
func GetBackupKeys(
- req *http.Request, userAPI userapi.UserInternalAPI, device *userapi.Device, version, roomID, sessionID string,
+ req *http.Request, userAPI userapi.ClientUserAPI, device *userapi.Device, version, roomID, sessionID string,
) util.JSONResponse {
var queryResp userapi.QueryKeyBackupResponse
userAPI.QueryKeyBackup(req.Context(), &userapi.QueryKeyBackupRequest{
diff --git a/clientapi/routing/key_crosssigning.go b/clientapi/routing/key_crosssigning.go
index c73e0a10..8fbb86f7 100644
--- a/clientapi/routing/key_crosssigning.go
+++ b/clientapi/routing/key_crosssigning.go
@@ -34,8 +34,8 @@ type crossSigningRequest struct {
func UploadCrossSigningDeviceKeys(
req *http.Request, userInteractiveAuth *auth.UserInteractive,
- keyserverAPI api.KeyInternalAPI, device *userapi.Device,
- accountAPI userapi.UserAccountAPI, cfg *config.ClientAPI,
+ keyserverAPI api.ClientKeyAPI, device *userapi.Device,
+ accountAPI userapi.ClientUserAPI, cfg *config.ClientAPI,
) util.JSONResponse {
uploadReq := &crossSigningRequest{}
uploadRes := &api.PerformUploadDeviceKeysResponse{}
@@ -105,7 +105,7 @@ func UploadCrossSigningDeviceKeys(
}
}
-func UploadCrossSigningDeviceSignatures(req *http.Request, keyserverAPI api.KeyInternalAPI, device *userapi.Device) util.JSONResponse {
+func UploadCrossSigningDeviceSignatures(req *http.Request, keyserverAPI api.ClientKeyAPI, device *userapi.Device) util.JSONResponse {
uploadReq := &api.PerformUploadDeviceSignaturesRequest{}
uploadRes := &api.PerformUploadDeviceSignaturesResponse{}
diff --git a/clientapi/routing/keys.go b/clientapi/routing/keys.go
index 2d65ac35..fdda34a5 100644
--- a/clientapi/routing/keys.go
+++ b/clientapi/routing/keys.go
@@ -31,7 +31,7 @@ type uploadKeysRequest struct {
OneTimeKeys map[string]json.RawMessage `json:"one_time_keys"`
}
-func UploadKeys(req *http.Request, keyAPI api.KeyInternalAPI, device *userapi.Device) util.JSONResponse {
+func UploadKeys(req *http.Request, keyAPI api.ClientKeyAPI, device *userapi.Device) util.JSONResponse {
var r uploadKeysRequest
resErr := httputil.UnmarshalJSONRequest(req, &r)
if resErr != nil {
@@ -100,7 +100,7 @@ func (r *queryKeysRequest) GetTimeout() time.Duration {
return time.Duration(r.Timeout) * time.Millisecond
}
-func QueryKeys(req *http.Request, keyAPI api.KeyInternalAPI, device *userapi.Device) util.JSONResponse {
+func QueryKeys(req *http.Request, keyAPI api.ClientKeyAPI, device *userapi.Device) util.JSONResponse {
var r queryKeysRequest
resErr := httputil.UnmarshalJSONRequest(req, &r)
if resErr != nil {
@@ -138,7 +138,7 @@ func (r *claimKeysRequest) GetTimeout() time.Duration {
return time.Duration(r.TimeoutMS) * time.Millisecond
}
-func ClaimKeys(req *http.Request, keyAPI api.KeyInternalAPI) util.JSONResponse {
+func ClaimKeys(req *http.Request, keyAPI api.ClientKeyAPI) util.JSONResponse {
var r claimKeysRequest
resErr := httputil.UnmarshalJSONRequest(req, &r)
if resErr != nil {
diff --git a/clientapi/routing/leaveroom.go b/clientapi/routing/leaveroom.go
index a34dd02d..a7166185 100644
--- a/clientapi/routing/leaveroom.go
+++ b/clientapi/routing/leaveroom.go
@@ -26,7 +26,7 @@ import (
func LeaveRoomByID(
req *http.Request,
device *api.Device,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
roomID string,
) util.JSONResponse {
// Prepare to ask the roomserver to perform the room join.
diff --git a/clientapi/routing/login.go b/clientapi/routing/login.go
index 2329df50..6017b584 100644
--- a/clientapi/routing/login.go
+++ b/clientapi/routing/login.go
@@ -53,7 +53,7 @@ func passwordLogin() flows {
// Login implements GET and POST /login
func Login(
- req *http.Request, userAPI userapi.UserInternalAPI,
+ req *http.Request, userAPI userapi.ClientUserAPI,
cfg *config.ClientAPI,
) util.JSONResponse {
if req.Method == http.MethodGet {
@@ -79,7 +79,7 @@ func Login(
}
func completeAuth(
- ctx context.Context, serverName gomatrixserverlib.ServerName, userAPI userapi.UserInternalAPI, login *auth.Login,
+ ctx context.Context, serverName gomatrixserverlib.ServerName, userAPI userapi.ClientUserAPI, login *auth.Login,
ipAddr, userAgent string,
) util.JSONResponse {
token, err := auth.GenerateAccessToken()
diff --git a/clientapi/routing/logout.go b/clientapi/routing/logout.go
index cfbb6f9f..73bae7af 100644
--- a/clientapi/routing/logout.go
+++ b/clientapi/routing/logout.go
@@ -24,7 +24,7 @@ import (
// Logout handles POST /logout
func Logout(
- req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.ClientUserAPI, device *api.Device,
) util.JSONResponse {
var performRes api.PerformDeviceDeletionResponse
err := userAPI.PerformDeviceDeletion(req.Context(), &api.PerformDeviceDeletionRequest{
@@ -44,7 +44,7 @@ func Logout(
// LogoutAll handles POST /logout/all
func LogoutAll(
- req *http.Request, userAPI api.UserInternalAPI, device *api.Device,
+ req *http.Request, userAPI api.ClientUserAPI, device *api.Device,
) util.JSONResponse {
var performRes api.PerformDeviceDeletionResponse
err := userAPI.PerformDeviceDeletion(req.Context(), &api.PerformDeviceDeletionRequest{
diff --git a/clientapi/routing/membership.go b/clientapi/routing/membership.go
index df8447b1..7d91c7b0 100644
--- a/clientapi/routing/membership.go
+++ b/clientapi/routing/membership.go
@@ -27,6 +27,7 @@ import (
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/clientapi/threepid"
"github.com/matrix-org/dendrite/internal/eventutil"
+ "github.com/matrix-org/dendrite/roomserver/api"
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/dendrite/setup/config"
userapi "github.com/matrix-org/dendrite/userapi/api"
@@ -38,9 +39,9 @@ import (
var errMissingUserID = errors.New("'user_id' must be supplied")
func SendBan(
- req *http.Request, profileAPI userapi.UserProfileAPI, device *userapi.Device,
+ req *http.Request, profileAPI userapi.ClientUserAPI, device *userapi.Device,
roomID string, cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI, asAPI appserviceAPI.AppServiceQueryAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceQueryAPI,
) util.JSONResponse {
body, evTime, roomVer, reqErr := extractRequestData(req, roomID, rsAPI)
if reqErr != nil {
@@ -80,10 +81,10 @@ func SendBan(
return sendMembership(req.Context(), profileAPI, device, roomID, "ban", body.Reason, cfg, body.UserID, evTime, roomVer, rsAPI, asAPI)
}
-func sendMembership(ctx context.Context, profileAPI userapi.UserProfileAPI, device *userapi.Device,
+func sendMembership(ctx context.Context, profileAPI userapi.ClientUserAPI, device *userapi.Device,
roomID, membership, reason string, cfg *config.ClientAPI, targetUserID string, evTime time.Time,
roomVer gomatrixserverlib.RoomVersion,
- rsAPI roomserverAPI.RoomserverInternalAPI, asAPI appserviceAPI.AppServiceQueryAPI) util.JSONResponse {
+ rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceQueryAPI) util.JSONResponse {
event, err := buildMembershipEvent(
ctx, targetUserID, reason, profileAPI, device, membership,
@@ -124,9 +125,9 @@ func sendMembership(ctx context.Context, profileAPI userapi.UserProfileAPI, devi
}
func SendKick(
- req *http.Request, profileAPI userapi.UserProfileAPI, device *userapi.Device,
+ req *http.Request, profileAPI userapi.ClientUserAPI, device *userapi.Device,
roomID string, cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI, asAPI appserviceAPI.AppServiceQueryAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceQueryAPI,
) util.JSONResponse {
body, evTime, roomVer, reqErr := extractRequestData(req, roomID, rsAPI)
if reqErr != nil {
@@ -164,9 +165,9 @@ func SendKick(
}
func SendUnban(
- req *http.Request, profileAPI userapi.UserProfileAPI, device *userapi.Device,
+ req *http.Request, profileAPI userapi.ClientUserAPI, device *userapi.Device,
roomID string, cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI, asAPI appserviceAPI.AppServiceQueryAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceQueryAPI,
) util.JSONResponse {
body, evTime, roomVer, reqErr := extractRequestData(req, roomID, rsAPI)
if reqErr != nil {
@@ -199,9 +200,9 @@ func SendUnban(
}
func SendInvite(
- req *http.Request, profileAPI userapi.UserProfileAPI, device *userapi.Device,
+ req *http.Request, profileAPI userapi.ClientUserAPI, device *userapi.Device,
roomID string, cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI, asAPI appserviceAPI.AppServiceQueryAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceQueryAPI,
) util.JSONResponse {
body, evTime, _, reqErr := extractRequestData(req, roomID, rsAPI)
if reqErr != nil {
@@ -233,11 +234,11 @@ func SendInvite(
// sendInvite sends an invitation to a user. Returns a JSONResponse and an error
func sendInvite(
ctx context.Context,
- profileAPI userapi.UserProfileAPI,
+ profileAPI userapi.ClientUserAPI,
device *userapi.Device,
roomID, userID, reason string,
cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
asAPI appserviceAPI.AppServiceQueryAPI, evTime time.Time,
) (util.JSONResponse, error) {
event, err := buildMembershipEvent(
@@ -259,37 +260,36 @@ func sendInvite(
return jsonerror.InternalServerError(), err
}
- err = roomserverAPI.SendInvite(
- ctx, rsAPI,
- event,
- nil, // ask the roomserver to draw up invite room state for us
- cfg.Matrix.ServerName,
- nil,
- )
- switch e := err.(type) {
- case *roomserverAPI.PerformError:
- return e.JSONResponse(), err
- case nil:
- return util.JSONResponse{
- Code: http.StatusOK,
- JSON: struct{}{},
- }, nil
- default:
- util.GetLogger(ctx).WithError(err).Error("roomserverAPI.SendInvite failed")
+ var inviteRes api.PerformInviteResponse
+ if err := rsAPI.PerformInvite(ctx, &api.PerformInviteRequest{
+ Event: event,
+ InviteRoomState: nil, // ask the roomserver to draw up invite room state for us
+ RoomVersion: event.RoomVersion,
+ SendAsServer: string(cfg.Matrix.ServerName),
+ }, &inviteRes); err != nil {
+ util.GetLogger(ctx).WithError(err).Error("PerformInvite failed")
return util.JSONResponse{
Code: http.StatusInternalServerError,
JSON: jsonerror.InternalServerError(),
}, err
}
+ if inviteRes.Error != nil {
+ return inviteRes.Error.JSONResponse(), inviteRes.Error
+ }
+
+ return util.JSONResponse{
+ Code: http.StatusOK,
+ JSON: struct{}{},
+ }, nil
}
func buildMembershipEvent(
ctx context.Context,
- targetUserID, reason string, profileAPI userapi.UserProfileAPI,
+ targetUserID, reason string, profileAPI userapi.ClientUserAPI,
device *userapi.Device,
membership, roomID string, isDirect bool,
cfg *config.ClientAPI, evTime time.Time,
- rsAPI roomserverAPI.RoomserverInternalAPI, asAPI appserviceAPI.AppServiceQueryAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceQueryAPI,
) (*gomatrixserverlib.HeaderedEvent, error) {
profile, err := loadProfile(ctx, targetUserID, cfg, profileAPI, asAPI)
if err != nil {
@@ -326,7 +326,7 @@ func loadProfile(
ctx context.Context,
userID string,
cfg *config.ClientAPI,
- profileAPI userapi.UserProfileAPI,
+ profileAPI userapi.ClientUserAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
) (*authtypes.Profile, error) {
_, serverName, err := gomatrixserverlib.SplitID('@', userID)
@@ -344,7 +344,7 @@ func loadProfile(
return profile, err
}
-func extractRequestData(req *http.Request, roomID string, rsAPI roomserverAPI.RoomserverInternalAPI) (
+func extractRequestData(req *http.Request, roomID string, rsAPI roomserverAPI.ClientRoomserverAPI) (
body *threepid.MembershipRequest, evTime time.Time, roomVer gomatrixserverlib.RoomVersion, resErr *util.JSONResponse,
) {
verReq := roomserverAPI.QueryRoomVersionForRoomRequest{RoomID: roomID}
@@ -379,8 +379,8 @@ func checkAndProcessThreepid(
device *userapi.Device,
body *threepid.MembershipRequest,
cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI,
- profileAPI userapi.UserProfileAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
+ profileAPI userapi.ClientUserAPI,
roomID string,
evTime time.Time,
) (inviteStored bool, errRes *util.JSONResponse) {
@@ -418,7 +418,7 @@ func checkAndProcessThreepid(
return
}
-func checkMemberInRoom(ctx context.Context, rsAPI roomserverAPI.RoomserverInternalAPI, userID, roomID string) *util.JSONResponse {
+func checkMemberInRoom(ctx context.Context, rsAPI roomserverAPI.ClientRoomserverAPI, userID, roomID string) *util.JSONResponse {
tuple := gomatrixserverlib.StateKeyTuple{
EventType: gomatrixserverlib.MRoomMember,
StateKey: userID,
@@ -457,7 +457,7 @@ func checkMemberInRoom(ctx context.Context, rsAPI roomserverAPI.RoomserverIntern
func SendForget(
req *http.Request, device *userapi.Device,
- roomID string, rsAPI roomserverAPI.RoomserverInternalAPI,
+ roomID string, rsAPI roomserverAPI.ClientRoomserverAPI,
) util.JSONResponse {
ctx := req.Context()
logger := util.GetLogger(ctx).WithField("roomID", roomID).WithField("userID", device.UserID)
diff --git a/clientapi/routing/memberships.go b/clientapi/routing/memberships.go
index 6ddcf1be..9bdd8a4f 100644
--- a/clientapi/routing/memberships.go
+++ b/clientapi/routing/memberships.go
@@ -55,7 +55,7 @@ type databaseJoinedMember struct {
func GetMemberships(
req *http.Request, device *userapi.Device, roomID string, joinedOnly bool,
_ *config.ClientAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.ClientRoomserverAPI,
) util.JSONResponse {
queryReq := api.QueryMembershipsForRoomRequest{
JoinedOnly: joinedOnly,
@@ -100,7 +100,7 @@ func GetMemberships(
func GetJoinedRooms(
req *http.Request,
device *userapi.Device,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.ClientRoomserverAPI,
) util.JSONResponse {
var res api.QueryRoomsForUserResponse
err := rsAPI.QueryRoomsForUser(req.Context(), &api.QueryRoomsForUserRequest{
diff --git a/clientapi/routing/notification.go b/clientapi/routing/notification.go
index ee715d32..8a424a14 100644
--- a/clientapi/routing/notification.go
+++ b/clientapi/routing/notification.go
@@ -27,7 +27,7 @@ import (
// GetNotifications handles /_matrix/client/r0/notifications
func GetNotifications(
req *http.Request, device *userapi.Device,
- userAPI userapi.UserInternalAPI,
+ userAPI userapi.ClientUserAPI,
) util.JSONResponse {
var limit int64
if limitStr := req.URL.Query().Get("limit"); limitStr != "" {
diff --git a/clientapi/routing/openid.go b/clientapi/routing/openid.go
index 13656e28..cfb440be 100644
--- a/clientapi/routing/openid.go
+++ b/clientapi/routing/openid.go
@@ -34,7 +34,7 @@ type openIDTokenResponse struct {
// can supply to an OpenID Relying Party to verify their identity
func CreateOpenIDToken(
req *http.Request,
- userAPI api.UserInternalAPI,
+ userAPI api.ClientUserAPI,
device *api.Device,
userID string,
cfg *config.ClientAPI,
diff --git a/clientapi/routing/password.go b/clientapi/routing/password.go
index 08ce1ffa..6dc9af50 100644
--- a/clientapi/routing/password.go
+++ b/clientapi/routing/password.go
@@ -28,7 +28,7 @@ type newPasswordAuth struct {
func Password(
req *http.Request,
- userAPI api.UserInternalAPI,
+ userAPI api.ClientUserAPI,
device *api.Device,
cfg *config.ClientAPI,
) util.JSONResponse {
diff --git a/clientapi/routing/peekroom.go b/clientapi/routing/peekroom.go
index 41d1ff00..d0eeccf1 100644
--- a/clientapi/routing/peekroom.go
+++ b/clientapi/routing/peekroom.go
@@ -26,7 +26,7 @@ import (
func PeekRoomByIDOrAlias(
req *http.Request,
device *api.Device,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
roomIDOrAlias string,
) util.JSONResponse {
// if this is a remote roomIDOrAlias, we have to ask the roomserver (or federation sender?) to
@@ -79,7 +79,7 @@ func PeekRoomByIDOrAlias(
func UnpeekRoomByID(
req *http.Request,
device *api.Device,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
roomID string,
) util.JSONResponse {
unpeekReq := roomserverAPI.PerformUnpeekRequest{
diff --git a/clientapi/routing/profile.go b/clientapi/routing/profile.go
index 3f91b4c9..97f86afe 100644
--- a/clientapi/routing/profile.go
+++ b/clientapi/routing/profile.go
@@ -35,7 +35,7 @@ import (
// GetProfile implements GET /profile/{userID}
func GetProfile(
- req *http.Request, profileAPI userapi.UserProfileAPI, cfg *config.ClientAPI,
+ req *http.Request, profileAPI userapi.ClientUserAPI, cfg *config.ClientAPI,
userID string,
asAPI appserviceAPI.AppServiceQueryAPI,
federation *gomatrixserverlib.FederationClient,
@@ -64,7 +64,7 @@ func GetProfile(
// GetAvatarURL implements GET /profile/{userID}/avatar_url
func GetAvatarURL(
- req *http.Request, profileAPI userapi.UserProfileAPI, cfg *config.ClientAPI,
+ req *http.Request, profileAPI userapi.ClientUserAPI, cfg *config.ClientAPI,
userID string, asAPI appserviceAPI.AppServiceQueryAPI,
federation *gomatrixserverlib.FederationClient,
) util.JSONResponse {
@@ -91,8 +91,8 @@ func GetAvatarURL(
// SetAvatarURL implements PUT /profile/{userID}/avatar_url
func SetAvatarURL(
- req *http.Request, profileAPI userapi.UserProfileAPI,
- device *userapi.Device, userID string, cfg *config.ClientAPI, rsAPI api.RoomserverInternalAPI,
+ req *http.Request, profileAPI userapi.ClientUserAPI,
+ device *userapi.Device, userID string, cfg *config.ClientAPI, rsAPI api.ClientRoomserverAPI,
) util.JSONResponse {
if userID != device.UserID {
return util.JSONResponse{
@@ -193,7 +193,7 @@ func SetAvatarURL(
// GetDisplayName implements GET /profile/{userID}/displayname
func GetDisplayName(
- req *http.Request, profileAPI userapi.UserProfileAPI, cfg *config.ClientAPI,
+ req *http.Request, profileAPI userapi.ClientUserAPI, cfg *config.ClientAPI,
userID string, asAPI appserviceAPI.AppServiceQueryAPI,
federation *gomatrixserverlib.FederationClient,
) util.JSONResponse {
@@ -220,8 +220,8 @@ func GetDisplayName(
// SetDisplayName implements PUT /profile/{userID}/displayname
func SetDisplayName(
- req *http.Request, profileAPI userapi.UserProfileAPI,
- device *userapi.Device, userID string, cfg *config.ClientAPI, rsAPI api.RoomserverInternalAPI,
+ req *http.Request, profileAPI userapi.ClientUserAPI,
+ device *userapi.Device, userID string, cfg *config.ClientAPI, rsAPI api.ClientRoomserverAPI,
) util.JSONResponse {
if userID != device.UserID {
return util.JSONResponse{
@@ -325,7 +325,7 @@ func SetDisplayName(
// Returns an error when something goes wrong or specifically
// eventutil.ErrProfileNoExists when the profile doesn't exist.
func getProfile(
- ctx context.Context, profileAPI userapi.UserProfileAPI, cfg *config.ClientAPI,
+ ctx context.Context, profileAPI userapi.ClientUserAPI, cfg *config.ClientAPI,
userID string,
asAPI appserviceAPI.AppServiceQueryAPI,
federation *gomatrixserverlib.FederationClient,
@@ -366,7 +366,7 @@ func buildMembershipEvents(
ctx context.Context,
roomIDs []string,
newProfile authtypes.Profile, userID string, cfg *config.ClientAPI,
- evTime time.Time, rsAPI api.RoomserverInternalAPI,
+ evTime time.Time, rsAPI api.ClientRoomserverAPI,
) ([]*gomatrixserverlib.HeaderedEvent, error) {
evs := []*gomatrixserverlib.HeaderedEvent{}
diff --git a/clientapi/routing/pusher.go b/clientapi/routing/pusher.go
index 9d6bef8b..d6a6eb93 100644
--- a/clientapi/routing/pusher.go
+++ b/clientapi/routing/pusher.go
@@ -28,7 +28,7 @@ import (
// GetPushers handles /_matrix/client/r0/pushers
func GetPushers(
req *http.Request, device *userapi.Device,
- userAPI userapi.UserInternalAPI,
+ userAPI userapi.ClientUserAPI,
) util.JSONResponse {
var queryRes userapi.QueryPushersResponse
localpart, _, err := gomatrixserverlib.SplitID('@', device.UserID)
@@ -57,7 +57,7 @@ func GetPushers(
// The behaviour of this endpoint varies depending on the values in the JSON body.
func SetPusher(
req *http.Request, device *userapi.Device,
- userAPI userapi.UserInternalAPI,
+ userAPI userapi.ClientUserAPI,
) util.JSONResponse {
localpart, _, err := gomatrixserverlib.SplitID('@', device.UserID)
if err != nil {
diff --git a/clientapi/routing/pushrules.go b/clientapi/routing/pushrules.go
index 81a33b25..856f52c7 100644
--- a/clientapi/routing/pushrules.go
+++ b/clientapi/routing/pushrules.go
@@ -30,7 +30,7 @@ func errorResponse(ctx context.Context, err error, msg string, args ...interface
return jsonerror.InternalServerError()
}
-func GetAllPushRules(ctx context.Context, device *userapi.Device, userAPI userapi.UserInternalAPI) util.JSONResponse {
+func GetAllPushRules(ctx context.Context, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
ruleSets, err := queryPushRules(ctx, device.UserID, userAPI)
if err != nil {
return errorResponse(ctx, err, "queryPushRulesJSON failed")
@@ -41,7 +41,7 @@ func GetAllPushRules(ctx context.Context, device *userapi.Device, userAPI userap
}
}
-func GetPushRulesByScope(ctx context.Context, scope string, device *userapi.Device, userAPI userapi.UserInternalAPI) util.JSONResponse {
+func GetPushRulesByScope(ctx context.Context, scope string, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
ruleSets, err := queryPushRules(ctx, device.UserID, userAPI)
if err != nil {
return errorResponse(ctx, err, "queryPushRulesJSON failed")
@@ -56,7 +56,7 @@ func GetPushRulesByScope(ctx context.Context, scope string, device *userapi.Devi
}
}
-func GetPushRulesByKind(ctx context.Context, scope, kind string, device *userapi.Device, userAPI userapi.UserInternalAPI) util.JSONResponse {
+func GetPushRulesByKind(ctx context.Context, scope, kind string, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
ruleSets, err := queryPushRules(ctx, device.UserID, userAPI)
if err != nil {
return errorResponse(ctx, err, "queryPushRules failed")
@@ -75,7 +75,7 @@ func GetPushRulesByKind(ctx context.Context, scope, kind string, device *userapi
}
}
-func GetPushRuleByRuleID(ctx context.Context, scope, kind, ruleID string, device *userapi.Device, userAPI userapi.UserInternalAPI) util.JSONResponse {
+func GetPushRuleByRuleID(ctx context.Context, scope, kind, ruleID string, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
ruleSets, err := queryPushRules(ctx, device.UserID, userAPI)
if err != nil {
return errorResponse(ctx, err, "queryPushRules failed")
@@ -98,7 +98,7 @@ func GetPushRuleByRuleID(ctx context.Context, scope, kind, ruleID string, device
}
}
-func PutPushRuleByRuleID(ctx context.Context, scope, kind, ruleID, afterRuleID, beforeRuleID string, body io.Reader, device *userapi.Device, userAPI userapi.UserInternalAPI) util.JSONResponse {
+func PutPushRuleByRuleID(ctx context.Context, scope, kind, ruleID, afterRuleID, beforeRuleID string, body io.Reader, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
var newRule pushrules.Rule
if err := json.NewDecoder(body).Decode(&newRule); err != nil {
return errorResponse(ctx, err, "JSON Decode failed")
@@ -160,7 +160,7 @@ func PutPushRuleByRuleID(ctx context.Context, scope, kind, ruleID, afterRuleID,
return util.JSONResponse{Code: http.StatusOK, JSON: struct{}{}}
}
-func DeletePushRuleByRuleID(ctx context.Context, scope, kind, ruleID string, device *userapi.Device, userAPI userapi.UserInternalAPI) util.JSONResponse {
+func DeletePushRuleByRuleID(ctx context.Context, scope, kind, ruleID string, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
ruleSets, err := queryPushRules(ctx, device.UserID, userAPI)
if err != nil {
return errorResponse(ctx, err, "queryPushRules failed")
@@ -187,7 +187,7 @@ func DeletePushRuleByRuleID(ctx context.Context, scope, kind, ruleID string, dev
return util.JSONResponse{Code: http.StatusOK, JSON: struct{}{}}
}
-func GetPushRuleAttrByRuleID(ctx context.Context, scope, kind, ruleID, attr string, device *userapi.Device, userAPI userapi.UserInternalAPI) util.JSONResponse {
+func GetPushRuleAttrByRuleID(ctx context.Context, scope, kind, ruleID, attr string, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
attrGet, err := pushRuleAttrGetter(attr)
if err != nil {
return errorResponse(ctx, err, "pushRuleAttrGetter failed")
@@ -216,7 +216,7 @@ func GetPushRuleAttrByRuleID(ctx context.Context, scope, kind, ruleID, attr stri
}
}
-func PutPushRuleAttrByRuleID(ctx context.Context, scope, kind, ruleID, attr string, body io.Reader, device *userapi.Device, userAPI userapi.UserInternalAPI) util.JSONResponse {
+func PutPushRuleAttrByRuleID(ctx context.Context, scope, kind, ruleID, attr string, body io.Reader, device *userapi.Device, userAPI userapi.ClientUserAPI) util.JSONResponse {
var newPartialRule pushrules.Rule
if err := json.NewDecoder(body).Decode(&newPartialRule); err != nil {
return util.JSONResponse{
@@ -266,7 +266,7 @@ func PutPushRuleAttrByRuleID(ctx context.Context, scope, kind, ruleID, attr stri
return util.JSONResponse{Code: http.StatusOK, JSON: struct{}{}}
}
-func queryPushRules(ctx context.Context, userID string, userAPI userapi.UserInternalAPI) (*pushrules.AccountRuleSets, error) {
+func queryPushRules(ctx context.Context, userID string, userAPI userapi.ClientUserAPI) (*pushrules.AccountRuleSets, error) {
var res userapi.QueryPushRulesResponse
if err := userAPI.QueryPushRules(ctx, &userapi.QueryPushRulesRequest{UserID: userID}, &res); err != nil {
util.GetLogger(ctx).WithError(err).Error("userAPI.QueryPushRules failed")
@@ -275,7 +275,7 @@ func queryPushRules(ctx context.Context, userID string, userAPI userapi.UserInte
return res.RuleSets, nil
}
-func putPushRules(ctx context.Context, userID string, ruleSets *pushrules.AccountRuleSets, userAPI userapi.UserInternalAPI) error {
+func putPushRules(ctx context.Context, userID string, ruleSets *pushrules.AccountRuleSets, userAPI userapi.ClientUserAPI) error {
req := userapi.PerformPushRulesPutRequest{
UserID: userID,
RuleSets: ruleSets,
diff --git a/clientapi/routing/redaction.go b/clientapi/routing/redaction.go
index e8d14ce3..27f0ba5d 100644
--- a/clientapi/routing/redaction.go
+++ b/clientapi/routing/redaction.go
@@ -40,7 +40,7 @@ type redactionResponse struct {
func SendRedaction(
req *http.Request, device *userapi.Device, roomID, eventID string, cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
txnID *string,
txnCache *transactions.Cache,
) util.JSONResponse {
diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go
index 8253f315..eba4920c 100644
--- a/clientapi/routing/register.go
+++ b/clientapi/routing/register.go
@@ -518,7 +518,7 @@ func validateApplicationService(
// http://matrix.org/speculator/spec/HEAD/client_server/unstable.html#post-matrix-client-unstable-register
func Register(
req *http.Request,
- userAPI userapi.UserRegisterAPI,
+ userAPI userapi.ClientUserAPI,
cfg *config.ClientAPI,
) util.JSONResponse {
defer req.Body.Close() // nolint: errcheck
@@ -614,7 +614,7 @@ func handleGuestRegistration(
req *http.Request,
r registerRequest,
cfg *config.ClientAPI,
- userAPI userapi.UserRegisterAPI,
+ userAPI userapi.ClientUserAPI,
) util.JSONResponse {
if cfg.RegistrationDisabled || cfg.GuestsDisabled {
return util.JSONResponse{
@@ -679,7 +679,7 @@ func handleRegistrationFlow(
r registerRequest,
sessionID string,
cfg *config.ClientAPI,
- userAPI userapi.UserRegisterAPI,
+ userAPI userapi.ClientUserAPI,
accessToken string,
accessTokenErr error,
) util.JSONResponse {
@@ -768,7 +768,7 @@ func handleApplicationServiceRegistration(
req *http.Request,
r registerRequest,
cfg *config.ClientAPI,
- userAPI userapi.UserRegisterAPI,
+ userAPI userapi.ClientUserAPI,
) util.JSONResponse {
// Check if we previously had issues extracting the access token from the
// request.
@@ -806,7 +806,7 @@ func checkAndCompleteFlow(
r registerRequest,
sessionID string,
cfg *config.ClientAPI,
- userAPI userapi.UserRegisterAPI,
+ userAPI userapi.ClientUserAPI,
) util.JSONResponse {
if checkFlowCompleted(flow, cfg.Derived.Registration.Flows) {
// This flow was completed, registration can continue
@@ -833,7 +833,7 @@ func checkAndCompleteFlow(
// not all
func completeRegistration(
ctx context.Context,
- userAPI userapi.UserRegisterAPI,
+ userAPI userapi.ClientUserAPI,
username, password, appserviceID, ipAddr, userAgent, sessionID string,
inhibitLogin eventutil.WeakBoolean,
displayName, deviceID *string,
@@ -992,7 +992,7 @@ type availableResponse struct {
func RegisterAvailable(
req *http.Request,
cfg *config.ClientAPI,
- registerAPI userapi.UserRegisterAPI,
+ registerAPI userapi.ClientUserAPI,
) util.JSONResponse {
username := req.URL.Query().Get("username")
@@ -1040,7 +1040,7 @@ func RegisterAvailable(
}
}
-func handleSharedSecretRegistration(userAPI userapi.UserInternalAPI, sr *SharedSecretRegistration, req *http.Request) util.JSONResponse {
+func handleSharedSecretRegistration(userAPI userapi.ClientUserAPI, sr *SharedSecretRegistration, req *http.Request) util.JSONResponse {
ssrr, err := NewSharedSecretRegistrationRequest(req.Body)
if err != nil {
return util.JSONResponse{
diff --git a/clientapi/routing/room_tagging.go b/clientapi/routing/room_tagging.go
index ce173613..03928956 100644
--- a/clientapi/routing/room_tagging.go
+++ b/clientapi/routing/room_tagging.go
@@ -31,7 +31,7 @@ import (
// GetTags implements GET /_matrix/client/r0/user/{userID}/rooms/{roomID}/tags
func GetTags(
req *http.Request,
- userAPI api.UserInternalAPI,
+ userAPI api.ClientUserAPI,
device *api.Device,
userID string,
roomID string,
@@ -62,7 +62,7 @@ func GetTags(
// the tag to the "map" and saving the new "map" to the DB
func PutTag(
req *http.Request,
- userAPI api.UserInternalAPI,
+ userAPI api.ClientUserAPI,
device *api.Device,
userID string,
roomID string,
@@ -113,7 +113,7 @@ func PutTag(
// the "map" and then saving the new "map" in the DB
func DeleteTag(
req *http.Request,
- userAPI api.UserInternalAPI,
+ userAPI api.ClientUserAPI,
device *api.Device,
userID string,
roomID string,
@@ -167,7 +167,7 @@ func obtainSavedTags(
req *http.Request,
userID string,
roomID string,
- userAPI api.UserInternalAPI,
+ userAPI api.ClientUserAPI,
) (tags gomatrix.TagContent, err error) {
dataReq := api.QueryAccountDataRequest{
UserID: userID,
@@ -194,7 +194,7 @@ func saveTagData(
req *http.Request,
userID string,
roomID string,
- userAPI api.UserInternalAPI,
+ userAPI api.ClientUserAPI,
Tag gomatrix.TagContent,
) error {
newTagData, err := json.Marshal(Tag)
diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go
index ba1c76b8..6da46707 100644
--- a/clientapi/routing/routing.go
+++ b/clientapi/routing/routing.go
@@ -50,15 +50,15 @@ import (
func Setup(
publicAPIMux, synapseAdminRouter, dendriteAdminRouter *mux.Router,
cfg *config.ClientAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
- userAPI userapi.UserInternalAPI,
+ userAPI userapi.ClientUserAPI,
userDirectoryProvider userapi.UserDirectoryProvider,
federation *gomatrixserverlib.FederationClient,
syncProducer *producers.SyncAPIProducer,
transactionsCache *transactions.Cache,
- federationSender federationAPI.FederationInternalAPI,
- keyAPI keyserverAPI.KeyInternalAPI,
+ federationSender federationAPI.ClientFederationAPI,
+ keyAPI keyserverAPI.ClientKeyAPI,
extRoomsProvider api.ExtraPublicRoomsProvider,
mscCfg *config.MSCs, natsClient *nats.Conn,
) {
@@ -325,7 +325,7 @@ func Setup(
if err != nil {
return util.ErrorResponse(err)
}
- return GetEvent(req, device, vars["roomID"], vars["eventID"], cfg, rsAPI, federation)
+ return GetEvent(req, device, vars["roomID"], vars["eventID"], cfg, rsAPI)
}),
).Methods(http.MethodGet, http.MethodOptions)
@@ -897,7 +897,7 @@ func Setup(
if resErr := clientutil.UnmarshalJSONRequest(req, &postContent); resErr != nil {
return *resErr
}
- return *SearchUserDirectory(
+ return SearchUserDirectory(
req.Context(),
device,
userAPI,
diff --git a/clientapi/routing/sendevent.go b/clientapi/routing/sendevent.go
index 1211fa72..5f84739d 100644
--- a/clientapi/routing/sendevent.go
+++ b/clientapi/routing/sendevent.go
@@ -70,7 +70,7 @@ func SendEvent(
device *userapi.Device,
roomID, eventType string, txnID, stateKey *string,
cfg *config.ClientAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.ClientRoomserverAPI,
txnCache *transactions.Cache,
) util.JSONResponse {
verReq := api.QueryRoomVersionForRoomRequest{RoomID: roomID}
@@ -207,7 +207,7 @@ func generateSendEvent(
device *userapi.Device,
roomID, eventType string, stateKey *string,
cfg *config.ClientAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.ClientRoomserverAPI,
evTime time.Time,
) (*gomatrixserverlib.Event, *util.JSONResponse) {
// parse the incoming http request
diff --git a/clientapi/routing/sendtyping.go b/clientapi/routing/sendtyping.go
index 6a27ee61..3f92e422 100644
--- a/clientapi/routing/sendtyping.go
+++ b/clientapi/routing/sendtyping.go
@@ -32,7 +32,7 @@ type typingContentJSON struct {
// sends the typing events to client API typingProducer
func SendTyping(
req *http.Request, device *userapi.Device, roomID string,
- userID string, rsAPI roomserverAPI.RoomserverInternalAPI,
+ userID string, rsAPI roomserverAPI.ClientRoomserverAPI,
syncProducer *producers.SyncAPIProducer,
) util.JSONResponse {
if device.UserID != userID {
diff --git a/clientapi/routing/server_notices.go b/clientapi/routing/server_notices.go
index 47b0da7b..9c34f2e1 100644
--- a/clientapi/routing/server_notices.go
+++ b/clientapi/routing/server_notices.go
@@ -56,8 +56,8 @@ func SendServerNotice(
req *http.Request,
cfgNotices *config.ServerNotices,
cfgClient *config.ClientAPI,
- userAPI userapi.UserInternalAPI,
- rsAPI api.RoomserverInternalAPI,
+ userAPI userapi.ClientUserAPI,
+ rsAPI api.ClientRoomserverAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
device *userapi.Device,
senderDevice *userapi.Device,
@@ -276,7 +276,7 @@ func (r sendServerNoticeRequest) valid() (ok bool) {
// It returns an userapi.Device, which is used for building the event
func getSenderDevice(
ctx context.Context,
- userAPI userapi.UserInternalAPI,
+ userAPI userapi.ClientUserAPI,
cfg *config.ClientAPI,
) (*userapi.Device, error) {
var accRes userapi.PerformAccountCreationResponse
diff --git a/clientapi/routing/state.go b/clientapi/routing/state.go
index d25ee823..c6e9e91d 100644
--- a/clientapi/routing/state.go
+++ b/clientapi/routing/state.go
@@ -41,7 +41,7 @@ type stateEventInStateResp struct {
// TODO: Check if the user is in the room. If not, check if the room's history
// is publicly visible. Current behaviour is returning an empty array if the
// user cannot see the room's history.
-func OnIncomingStateRequest(ctx context.Context, device *userapi.Device, rsAPI api.RoomserverInternalAPI, roomID string) util.JSONResponse {
+func OnIncomingStateRequest(ctx context.Context, device *userapi.Device, rsAPI api.ClientRoomserverAPI, roomID string) util.JSONResponse {
var worldReadable bool
var wantLatestState bool
@@ -162,7 +162,7 @@ func OnIncomingStateRequest(ctx context.Context, device *userapi.Device, rsAPI a
// is then (by default) we return the content, otherwise a 404.
// If eventFormat=true, sends the whole event else just the content.
func OnIncomingStateTypeRequest(
- ctx context.Context, device *userapi.Device, rsAPI api.RoomserverInternalAPI,
+ ctx context.Context, device *userapi.Device, rsAPI api.ClientRoomserverAPI,
roomID, evType, stateKey string, eventFormat bool,
) util.JSONResponse {
var worldReadable bool
diff --git a/clientapi/routing/threepid.go b/clientapi/routing/threepid.go
index a4898ca4..94b658ee 100644
--- a/clientapi/routing/threepid.go
+++ b/clientapi/routing/threepid.go
@@ -40,7 +40,7 @@ type threePIDsResponse struct {
// RequestEmailToken implements:
// POST /account/3pid/email/requestToken
// POST /register/email/requestToken
-func RequestEmailToken(req *http.Request, threePIDAPI api.UserThreePIDAPI, cfg *config.ClientAPI) util.JSONResponse {
+func RequestEmailToken(req *http.Request, threePIDAPI api.ClientUserAPI, cfg *config.ClientAPI) util.JSONResponse {
var body threepid.EmailAssociationRequest
if reqErr := httputil.UnmarshalJSONRequest(req, &body); reqErr != nil {
return *reqErr
@@ -90,7 +90,7 @@ func RequestEmailToken(req *http.Request, threePIDAPI api.UserThreePIDAPI, cfg *
// CheckAndSave3PIDAssociation implements POST /account/3pid
func CheckAndSave3PIDAssociation(
- req *http.Request, threePIDAPI api.UserThreePIDAPI, device *api.Device,
+ req *http.Request, threePIDAPI api.ClientUserAPI, device *api.Device,
cfg *config.ClientAPI,
) util.JSONResponse {
var body threepid.EmailAssociationCheckRequest
@@ -158,7 +158,7 @@ func CheckAndSave3PIDAssociation(
// GetAssociated3PIDs implements GET /account/3pid
func GetAssociated3PIDs(
- req *http.Request, threepidAPI api.UserThreePIDAPI, device *api.Device,
+ req *http.Request, threepidAPI api.ClientUserAPI, device *api.Device,
) util.JSONResponse {
localpart, _, err := gomatrixserverlib.SplitID('@', device.UserID)
if err != nil {
@@ -182,7 +182,7 @@ func GetAssociated3PIDs(
}
// Forget3PID implements POST /account/3pid/delete
-func Forget3PID(req *http.Request, threepidAPI api.UserThreePIDAPI) util.JSONResponse {
+func Forget3PID(req *http.Request, threepidAPI api.ClientUserAPI) util.JSONResponse {
var body authtypes.ThreePID
if reqErr := httputil.UnmarshalJSONRequest(req, &body); reqErr != nil {
return *reqErr
diff --git a/clientapi/routing/upgrade_room.go b/clientapi/routing/upgrade_room.go
index 00bde36b..505bf8f5 100644
--- a/clientapi/routing/upgrade_room.go
+++ b/clientapi/routing/upgrade_room.go
@@ -40,8 +40,8 @@ type upgradeRoomResponse struct {
func UpgradeRoom(
req *http.Request, device *userapi.Device,
cfg *config.ClientAPI,
- roomID string, profileAPI userapi.UserProfileAPI,
- rsAPI roomserverAPI.RoomserverInternalAPI,
+ roomID string, profileAPI userapi.ClientUserAPI,
+ rsAPI roomserverAPI.ClientRoomserverAPI,
asAPI appserviceAPI.AppServiceQueryAPI,
) util.JSONResponse {
var r upgradeRoomRequest
diff --git a/clientapi/routing/userdirectory.go b/clientapi/routing/userdirectory.go
index ab73cf43..4d41da73 100644
--- a/clientapi/routing/userdirectory.go
+++ b/clientapi/routing/userdirectory.go
@@ -34,13 +34,13 @@ type UserDirectoryResponse struct {
func SearchUserDirectory(
ctx context.Context,
device *userapi.Device,
- userAPI userapi.UserInternalAPI,
- rsAPI api.RoomserverInternalAPI,
+ userAPI userapi.ClientUserAPI,
+ rsAPI api.ClientRoomserverAPI,
provider userapi.UserDirectoryProvider,
serverName gomatrixserverlib.ServerName,
searchString string,
limit int,
-) *util.JSONResponse {
+) util.JSONResponse {
if limit < 10 {
limit = 10
}
@@ -58,8 +58,7 @@ func SearchUserDirectory(
}
userRes := &userapi.QuerySearchProfilesResponse{}
if err := provider.QuerySearchProfiles(ctx, userReq, userRes); err != nil {
- errRes := util.ErrorResponse(fmt.Errorf("userAPI.QuerySearchProfiles: %w", err))
- return &errRes
+ return util.ErrorResponse(fmt.Errorf("userAPI.QuerySearchProfiles: %w", err))
}
for _, user := range userRes.Profiles {
@@ -94,8 +93,7 @@ func SearchUserDirectory(
}
stateRes := &api.QueryKnownUsersResponse{}
if err := rsAPI.QueryKnownUsers(ctx, stateReq, stateRes); err != nil && err != sql.ErrNoRows {
- errRes := util.ErrorResponse(fmt.Errorf("rsAPI.QueryKnownUsers: %w", err))
- return &errRes
+ return util.ErrorResponse(fmt.Errorf("rsAPI.QueryKnownUsers: %w", err))
}
for _, user := range stateRes.Users {
@@ -114,7 +112,7 @@ func SearchUserDirectory(
response.Results = append(response.Results, result)
}
- return &util.JSONResponse{
+ return util.JSONResponse{
Code: 200,
JSON: response,
}
diff --git a/clientapi/threepid/invites.go b/clientapi/threepid/invites.go
index eee6992f..6e7426a7 100644
--- a/clientapi/threepid/invites.go
+++ b/clientapi/threepid/invites.go
@@ -86,7 +86,7 @@ var (
func CheckAndProcessInvite(
ctx context.Context,
device *userapi.Device, body *MembershipRequest, cfg *config.ClientAPI,
- rsAPI api.RoomserverInternalAPI, db userapi.UserProfileAPI,
+ rsAPI api.ClientRoomserverAPI, db userapi.ClientUserAPI,
roomID string,
evTime time.Time,
) (inviteStoredOnIDServer bool, err error) {
@@ -136,7 +136,7 @@ func CheckAndProcessInvite(
// Returns an error if a check or a request failed.
func queryIDServer(
ctx context.Context,
- db userapi.UserProfileAPI, cfg *config.ClientAPI, device *userapi.Device,
+ userAPI userapi.ClientUserAPI, cfg *config.ClientAPI, device *userapi.Device,
body *MembershipRequest, roomID string,
) (lookupRes *idServerLookupResponse, storeInviteRes *idServerStoreInviteResponse, err error) {
if err = isTrusted(body.IDServer, cfg); err != nil {
@@ -152,7 +152,7 @@ func queryIDServer(
if lookupRes.MXID == "" {
// No Matrix ID matches with the given 3PID, ask the server to store the
// invite and return a token
- storeInviteRes, err = queryIDServerStoreInvite(ctx, db, cfg, device, body, roomID)
+ storeInviteRes, err = queryIDServerStoreInvite(ctx, userAPI, cfg, device, body, roomID)
return
}
@@ -163,7 +163,7 @@ func queryIDServer(
if lookupRes.NotBefore > now || now > lookupRes.NotAfter {
// If the current timestamp isn't in the time frame in which the association
// is known to be valid, re-run the query
- return queryIDServer(ctx, db, cfg, device, body, roomID)
+ return queryIDServer(ctx, userAPI, cfg, device, body, roomID)
}
// Check the request signatures and send an error if one isn't valid
@@ -205,7 +205,7 @@ func queryIDServerLookup(ctx context.Context, body *MembershipRequest) (*idServe
// Returns an error if the request failed to send or if the response couldn't be parsed.
func queryIDServerStoreInvite(
ctx context.Context,
- db userapi.UserProfileAPI, cfg *config.ClientAPI, device *userapi.Device,
+ userAPI userapi.ClientUserAPI, cfg *config.ClientAPI, device *userapi.Device,
body *MembershipRequest, roomID string,
) (*idServerStoreInviteResponse, error) {
// Retrieve the sender's profile to get their display name
@@ -217,7 +217,7 @@ func queryIDServerStoreInvite(
var profile *authtypes.Profile
if serverName == cfg.Matrix.ServerName {
res := &userapi.QueryProfileResponse{}
- err = db.QueryProfile(ctx, &userapi.QueryProfileRequest{UserID: device.UserID}, res)
+ err = userAPI.QueryProfile(ctx, &userapi.QueryProfileRequest{UserID: device.UserID}, res)
if err != nil {
return nil, err
}
@@ -337,7 +337,7 @@ func emit3PIDInviteEvent(
ctx context.Context,
body *MembershipRequest, res *idServerStoreInviteResponse,
device *userapi.Device, roomID string, cfg *config.ClientAPI,
- rsAPI api.RoomserverInternalAPI,
+ rsAPI api.ClientRoomserverAPI,
evTime time.Time,
) error {
builder := &gomatrixserverlib.EventBuilder{