diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2021-07-09 17:49:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-09 17:49:59 +0100 |
commit | acec6fa979a754c41fa83f7d887bfaf55946e17b (patch) | |
tree | 81f8c423d2dfb5bce62cad477f2e234eca1d9274 /roomserver/internal/helpers/helpers.go | |
parent | 1ed732cc783e079feeaf637e23120b027fb7d70b (diff) |
Move a couple of callers to helpers.IsServerCurrentlyInRoom over to the query API (#1912)
Diffstat (limited to 'roomserver/internal/helpers/helpers.go')
-rw-r--r-- | roomserver/internal/helpers/helpers.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/roomserver/internal/helpers/helpers.go b/roomserver/internal/helpers/helpers.go index a829bffc..a389cc89 100644 --- a/roomserver/internal/helpers/helpers.go +++ b/roomserver/internal/helpers/helpers.go @@ -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 |