mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Remove unused internal APIs (#1117)
This commit is contained in:
parent
89d61c4877
commit
25cd2dd1c9
11 changed files with 3 additions and 165 deletions
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -122,20 +122,6 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
|
|||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
}),
|
||||
)
|
||||
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue