Undo some changes to client API that shouldn't be needed

This commit is contained in:
Neil Alexander 2021-03-03 12:49:17 +00:00
parent 74cfc37116
commit 441ccf04d1
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 5 additions and 26 deletions

View file

@ -80,11 +80,10 @@ func GetEvent(
stateReq := api.QueryStateAfterEventsRequest{
RoomID: r.requestedEvent.RoomID(),
PrevEventIDs: r.requestedEvent.PrevEventIDs(),
// XXX: Appservices require you to fetch the lot
// StateToFetch: []gomatrixserverlib.StateKeyTuple{{
// EventType: gomatrixserverlib.MRoomMember,
// StateKey: device.UserID,
// }},
StateToFetch: []gomatrixserverlib.StateKeyTuple{{
EventType: gomatrixserverlib.MRoomMember,
StateKey: device.UserID,
}},
}
var stateResp api.QueryStateAfterEventsResponse
if err := rsAPI.QueryStateAfterEvents(req.Context(), &stateReq, &stateResp); err != nil {
@ -104,24 +103,9 @@ func GetEvent(
JSON: jsonerror.NotFound("The event was not found or you do not have permission to read this event"),
}
}
var appService *config.ApplicationService
if device.AppserviceID != "" {
for _, as := range cfg.Derived.ApplicationServices {
if as.ID == device.AppserviceID {
appService = &as
break
}
}
}
for _, stateEvent := range stateResp.StateEvents {
if stateEvent.Type() != gomatrixserverlib.MRoomMember {
continue
}
// Allow appservices to fetch events
if appService != nil && !appService.IsInterestedInUserID(*stateEvent.StateKey()) {
continue
} else if stateEvent.StateKeyEquals(device.UserID) {
if stateEvent.StateKeyEquals(device.UserID) {
continue
}
membership, err := stateEvent.Membership()

View file

@ -57,11 +57,6 @@ func GetMemberships(
_ *config.ClientAPI,
rsAPI api.RoomserverInternalAPI,
) util.JSONResponse {
resErr := checkMemberInRoom(req.Context(), rsAPI, device.UserID, roomID)
if resErr != nil {
return *resErr
}
queryReq := api.QueryMembershipsForRoomRequest{
JoinedOnly: joinedOnly,
RoomID: roomID,