@@ -104,6 +104,25 @@ type QueryEventsByIDResponse struct {
104
104
Events []gomatrixserverlib.Event `json:"events"`
105
105
}
106
106
107
+ // QueryMembershipForUserRequest is a request to QueryMembership
108
+ type QueryMembershipForUserRequest struct {
109
+ // ID of the room to fetch membership from
110
+ RoomID string `json:"room_id"`
111
+ // ID of the user sending the request
112
+ Sender string `json:"sender"`
113
+ }
114
+
115
+ // QueryMembershipForUserResponse is a response to QueryMembership
116
+ type QueryMembershipForUserResponse struct {
117
+ // The EventID of the latest "m.room.member" event for the sender,
118
+ // if HasBeenInRoom is true.
119
+ EventID string `json:"event_id"`
120
+ // True if the user has been in room before and has either stayed in it or left it.
121
+ HasBeenInRoom bool `json:"has_been_in_room"`
122
+ // True if the user is in room.
123
+ IsInRoom bool `json:"is_in_room"`
124
+ }
125
+
107
126
// QueryMembershipsForRoomRequest is a request to QueryMembershipsForRoom
108
127
type QueryMembershipsForRoomRequest struct {
109
128
// If true, only returns the membership events of "join" membership
@@ -222,6 +241,13 @@ type RoomserverQueryAPI interface {
222
241
response * QueryEventsByIDResponse ,
223
242
) error
224
243
244
+ // Query the membership event for an user for a room.
245
+ QueryMembershipForUser (
246
+ ctx context.Context ,
247
+ request * QueryMembershipForUserRequest ,
248
+ response * QueryMembershipForUserResponse ,
249
+ ) error
250
+
225
251
// Query a list of membership events for a room
226
252
QueryMembershipsForRoom (
227
253
ctx context.Context ,
@@ -269,6 +295,9 @@ const RoomserverQueryStateAfterEventsPath = "/api/roomserver/queryStateAfterEven
269
295
// RoomserverQueryEventsByIDPath is the HTTP path for the QueryEventsByID API.
270
296
const RoomserverQueryEventsByIDPath = "/api/roomserver/queryEventsByID"
271
297
298
+ // RoomserverQueryMembershipForUserPath is the HTTP path for the QueryMembershipForUser API.
299
+ const RoomserverQueryMembershipForUserPath = "/api/roomserver/queryMembershipForUser"
300
+
272
301
// RoomserverQueryMembershipsForRoomPath is the HTTP path for the QueryMembershipsForRoom API
273
302
const RoomserverQueryMembershipsForRoomPath = "/api/roomserver/queryMembershipsForRoom"
274
303
@@ -337,6 +366,19 @@ func (h *httpRoomserverQueryAPI) QueryEventsByID(
337
366
return postJSON (ctx , span , h .httpClient , apiURL , request , response )
338
367
}
339
368
369
+ // QueryMembershipForUser implements RoomserverQueryAPI
370
+ func (h * httpRoomserverQueryAPI ) QueryMembershipForUser (
371
+ ctx context.Context ,
372
+ request * QueryMembershipForUserRequest ,
373
+ response * QueryMembershipForUserResponse ,
374
+ ) error {
375
+ span , ctx := opentracing .StartSpanFromContext (ctx , "QueryMembershipForUser" )
376
+ defer span .Finish ()
377
+
378
+ apiURL := h .roomserverURL + RoomserverQueryMembershipForUserPath
379
+ return postJSON (ctx , span , h .httpClient , apiURL , request , response )
380
+ }
381
+
340
382
// QueryMembershipsForRoom implements RoomserverQueryAPI
341
383
func (h * httpRoomserverQueryAPI ) QueryMembershipsForRoom (
342
384
ctx context.Context ,
0 commit comments