diff options
author | Kegsay <kegan@matrix.org> | 2020-06-11 15:07:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-11 15:07:16 +0100 |
commit | 25cd2dd1c925fa0c1eeb27a3cd71e668344102ad (patch) | |
tree | 9635d69896a9b8ff548a6708d6ad2e2430309d0d /roomserver | |
parent | 89d61c487751e4beca71d396d719758ae4a98332 (diff) |
Remove unused internal APIs (#1117)
Diffstat (limited to 'roomserver')
-rw-r--r-- | roomserver/api/api.go | 7 | ||||
-rw-r--r-- | roomserver/api/query.go | 17 | ||||
-rw-r--r-- | roomserver/internal/query.go | 34 | ||||
-rw-r--r-- | roomserver/inthttp/client.go | 14 | ||||
-rw-r--r-- | roomserver/inthttp/server.go | 14 |
5 files changed, 0 insertions, 86 deletions
diff --git a/roomserver/api/api.go b/roomserver/api/api.go index aefe55bc..3a2ad059 100644 --- a/roomserver/api/api.go +++ b/roomserver/api/api.go @@ -65,13 +65,6 @@ type RoomserverInternalAPI interface { response *QueryMembershipsForRoomResponse, ) error - // Query a list of invite event senders for a user in a room. - QueryInvitesForUser( - ctx context.Context, - request *QueryInvitesForUserRequest, - response *QueryInvitesForUserResponse, - ) error - // Query whether a server is allowed to see an event QueryServerAllowedToSeeEvent( ctx context.Context, diff --git a/roomserver/api/query.go b/roomserver/api/query.go index dc005c77..c9a46ae9 100644 --- a/roomserver/api/query.go +++ b/roomserver/api/query.go @@ -140,23 +140,6 @@ type QueryMembershipsForRoomResponse struct { HasBeenInRoom bool `json:"has_been_in_room"` } -// QueryInvitesForUserRequest is a request to QueryInvitesForUser -type QueryInvitesForUserRequest struct { - // The room ID to look up invites in. - RoomID string `json:"room_id"` - // The User ID to look up invites for. - TargetUserID string `json:"target_user_id"` -} - -// QueryInvitesForUserResponse is a response to QueryInvitesForUser -// This is used when accepting an invite or rejecting a invite to tell which -// remote matrix servers to contact. -type QueryInvitesForUserResponse struct { - // A list of matrix user IDs for each sender of an active invite targeting - // the requested user ID. - InviteSenderUserIDs []string `json:"invite_sender_user_ids"` -} - // QueryServerAllowedToSeeEventRequest is a request to QueryServerAllowedToSeeEvent type QueryServerAllowedToSeeEventRequest struct { // The event ID to look up invites in. diff --git a/roomserver/internal/query.go b/roomserver/internal/query.go index 9fb67e7e..aea93388 100644 --- a/roomserver/internal/query.go +++ b/roomserver/internal/query.go @@ -353,40 +353,6 @@ func getMembershipsAtState( return events, nil } -// QueryInvitesForUser implements api.RoomserverInternalAPI -func (r *RoomserverInternalAPI) QueryInvitesForUser( - ctx context.Context, - request *api.QueryInvitesForUserRequest, - response *api.QueryInvitesForUserResponse, -) error { - roomNID, err := r.DB.RoomNID(ctx, request.RoomID) - if err != nil { - return err - } - - targetUserNIDs, err := r.DB.EventStateKeyNIDs(ctx, []string{request.TargetUserID}) - if err != nil { - return err - } - targetUserNID := targetUserNIDs[request.TargetUserID] - - senderUserNIDs, err := r.DB.GetInvitesForUser(ctx, roomNID, targetUserNID) - if err != nil { - return err - } - - senderUserIDs, err := r.DB.EventStateKeys(ctx, senderUserNIDs) - if err != nil { - return err - } - - for _, senderUserID := range senderUserIDs { - response.InviteSenderUserIDs = append(response.InviteSenderUserIDs, senderUserID) - } - - return nil -} - // QueryServerAllowedToSeeEvent implements api.RoomserverInternalAPI func (r *RoomserverInternalAPI) QueryServerAllowedToSeeEvent( ctx context.Context, diff --git a/roomserver/inthttp/client.go b/roomserver/inthttp/client.go index 5cc2537e..6f5e882e 100644 --- a/roomserver/inthttp/client.go +++ b/roomserver/inthttp/client.go @@ -33,7 +33,6 @@ const ( RoomserverQueryEventsByIDPath = "/roomserver/queryEventsByID" RoomserverQueryMembershipForUserPath = "/roomserver/queryMembershipForUser" RoomserverQueryMembershipsForRoomPath = "/roomserver/queryMembershipsForRoom" - RoomserverQueryInvitesForUserPath = "/roomserver/queryInvitesForUser" RoomserverQueryServerAllowedToSeeEventPath = "/roomserver/queryServerAllowedToSeeEvent" RoomserverQueryMissingEventsPath = "/roomserver/queryMissingEvents" RoomserverQueryStateAndAuthChainPath = "/roomserver/queryStateAndAuthChain" @@ -236,19 +235,6 @@ func (h *httpRoomserverInternalAPI) QueryMembershipsForRoom( return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response) } -// QueryInvitesForUser implements RoomserverQueryAPI -func (h *httpRoomserverInternalAPI) QueryInvitesForUser( - ctx context.Context, - request *api.QueryInvitesForUserRequest, - response *api.QueryInvitesForUserResponse, -) error { - span, ctx := opentracing.StartSpanFromContext(ctx, "QueryInvitesForUser") - defer span.Finish() - - apiURL := h.roomserverURL + RoomserverQueryInvitesForUserPath - return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response) -} - // QueryServerAllowedToSeeEvent implements RoomserverQueryAPI func (h *httpRoomserverInternalAPI) QueryServerAllowedToSeeEvent( ctx context.Context, diff --git a/roomserver/inthttp/server.go b/roomserver/inthttp/server.go index 9a58a30b..3a13ce37 100644 --- a/roomserver/inthttp/server.go +++ b/roomserver/inthttp/server.go @@ -123,20 +123,6 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) { }), ) internalAPIMux.Handle( - RoomserverQueryInvitesForUserPath, - internal.MakeInternalAPI("queryInvitesForUser", func(req *http.Request) util.JSONResponse { - var request api.QueryInvitesForUserRequest - var response api.QueryInvitesForUserResponse - if err := json.NewDecoder(req.Body).Decode(&request); err != nil { - return util.ErrorResponse(err) - } - if err := r.QueryInvitesForUser(req.Context(), &request, &response); err != nil { - return util.ErrorResponse(err) - } - return util.JSONResponse{Code: http.StatusOK, JSON: &response} - }), - ) - internalAPIMux.Handle( RoomserverQueryServerAllowedToSeeEventPath, internal.MakeInternalAPI("queryServerAllowedToSeeEvent", func(req *http.Request) util.JSONResponse { var request api.QueryServerAllowedToSeeEventRequest |