mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 21:32:46 +00:00
Move a couple of callers to helpers.IsServerCurrentlyInRoom over to the query API (#1912)
This commit is contained in:
parent
1ed732cc78
commit
acec6fa979
4 changed files with 29 additions and 5 deletions
|
@ -50,6 +50,10 @@ func UpdateToInviteMembership(
|
|||
return updates, nil
|
||||
}
|
||||
|
||||
// IsServerCurrentlyInRoom checks if a server is in a given room, based on the room
|
||||
// memberships. If the servername is not supplied then the local server will be
|
||||
// checked instead using a faster code path.
|
||||
// TODO: This should probably be replaced by an API call.
|
||||
func IsServerCurrentlyInRoom(ctx context.Context, db storage.Database, serverName gomatrixserverlib.ServerName, roomID string) (bool, error) {
|
||||
info, err := db.RoomInfo(ctx, roomID)
|
||||
if err != nil {
|
||||
|
@ -59,6 +63,10 @@ func IsServerCurrentlyInRoom(ctx context.Context, db storage.Database, serverNam
|
|||
return false, fmt.Errorf("unknown room %s", roomID)
|
||||
}
|
||||
|
||||
if serverName == "" {
|
||||
return db.GetLocalServerInRoom(ctx, info.RoomNID)
|
||||
}
|
||||
|
||||
eventNIDs, err := db.GetMembershipEventNIDsForRoom(ctx, info.RoomNID, true, false)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue