aboutsummaryrefslogtreecommitdiff
path: root/roomserver/internal/query
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2021-07-09 16:36:45 +0100
committerGitHub <noreply@github.com>2021-07-09 16:36:45 +0100
commitc8408a6387f6d155fe4e0547cbfdde7123832c84 (patch)
treedafecdf16214eefcb995e75734c60421eb6304e8 /roomserver/internal/query
parent3e50bac9441ae43387fee510d5838039bc07e0bb (diff)
Add more optimised code path for checking if we're in a room (#1909)
* Add more optimised code path for checking if we're in a room * Fix database queries * Fix federation API test * Fix logging * Review comments * Make separate API call for room membership
Diffstat (limited to 'roomserver/internal/query')
-rw-r--r--roomserver/internal/query/query.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/roomserver/internal/query/query.go b/roomserver/internal/query/query.go
index 408f9766..ccd09372 100644
--- a/roomserver/internal/query/query.go
+++ b/roomserver/internal/query/query.go
@@ -36,6 +36,7 @@ import (
type Queryer struct {
DB storage.Database
Cache caching.RoomServerCaches
+ ServerName gomatrixserverlib.ServerName
ServerACLs *acls.ServerACLs
}
@@ -328,6 +329,16 @@ func (r *Queryer) QueryServerJoinedToRoom(
}
response.RoomExists = true
+ if request.ServerName == r.ServerName || request.ServerName == "" {
+ var joined bool
+ joined, err = r.DB.GetLocalServerInRoom(ctx, info.RoomNID)
+ if err != nil {
+ return fmt.Errorf("r.DB.GetLocalServerInRoom: %w", err)
+ }
+ response.IsInRoom = joined
+ return nil
+ }
+
eventNIDs, err := r.DB.GetMembershipEventNIDsForRoom(ctx, info.RoomNID, true, false)
if err != nil {
return fmt.Errorf("r.DB.GetMembershipEventNIDsForRoom: %w", err)