mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 06:12:45 +00:00
Define component interfaces based on consumers (1/2) (#2423)
* Specify interfaces used by appservice, do half of clientapi * convert more deps of clientapi to finer-grained interfaces * Convert mediaapi and rest of clientapi * Somehow this got missed
This commit is contained in:
parent
d9e71b93b6
commit
506de4bb3d
57 changed files with 414 additions and 372 deletions
|
@ -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,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue