mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
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
This commit is contained in:
parent
3e50bac944
commit
c8408a6387
10 changed files with 90 additions and 13 deletions
|
@ -59,6 +59,7 @@ func NewRoomserverAPI(
|
|||
Queryer: &query.Queryer{
|
||||
DB: roomserverDB,
|
||||
Cache: caches,
|
||||
ServerName: cfg.Matrix.ServerName,
|
||||
ServerACLs: serverACLs,
|
||||
},
|
||||
Inputer: &input.Inputer{
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue