mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-23 14:53:10 -06:00
Distinguish between room not existing and room being abandoned on this server
This commit is contained in:
parent
e846ae0e5d
commit
1c6bd5fa80
|
|
@ -89,10 +89,16 @@ func MakeJoin(
|
||||||
util.GetLogger(httpReq.Context()).WithError(err).Error("rsAPI.QueryServerJoinedToRoom failed")
|
util.GetLogger(httpReq.Context()).WithError(err).Error("rsAPI.QueryServerJoinedToRoom failed")
|
||||||
return jsonerror.InternalServerError()
|
return jsonerror.InternalServerError()
|
||||||
}
|
}
|
||||||
|
if !inRoomRes.RoomExists {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusNotFound,
|
||||||
|
JSON: jsonerror.NotFound(fmt.Sprintf("Room ID %q was not found on this server", roomID)),
|
||||||
|
}
|
||||||
|
}
|
||||||
if !inRoomRes.IsInRoom {
|
if !inRoomRes.IsInRoom {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusNotFound,
|
Code: http.StatusNotFound,
|
||||||
JSON: jsonerror.NotFound("There are no remaining users in this room"),
|
JSON: jsonerror.NotFound(fmt.Sprintf("Room ID %q has no remaining users on this server", roomID)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,8 @@ type QueryServerJoinedToRoomRequest struct {
|
||||||
|
|
||||||
// QueryMembershipsForRoomResponse is a response to QueryServerJoinedToRoom
|
// QueryMembershipsForRoomResponse is a response to QueryServerJoinedToRoom
|
||||||
type QueryServerJoinedToRoomResponse struct {
|
type QueryServerJoinedToRoomResponse struct {
|
||||||
|
// True if the room exists on the server
|
||||||
|
RoomExists bool `json:"room_exists"`
|
||||||
// True if we still believe that we are participating in the room
|
// True if we still believe that we are participating in the room
|
||||||
IsInRoom bool `json:"is_in_room"`
|
IsInRoom bool `json:"is_in_room"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -237,9 +237,10 @@ func (r *Queryer) QueryServerJoinedToRoom(
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("r.DB.RoomInfo: %w", err)
|
return fmt.Errorf("r.DB.RoomInfo: %w", err)
|
||||||
}
|
}
|
||||||
if info == nil {
|
if info == nil || info.IsStub {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
response.RoomExists = true
|
||||||
|
|
||||||
eventNIDs, err := r.DB.GetMembershipEventNIDsForRoom(ctx, info.RoomNID, true, false)
|
eventNIDs, err := r.DB.GetMembershipEventNIDsForRoom(ctx, info.RoomNID, true, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue