aboutsummaryrefslogtreecommitdiff
path: root/roomserver/storage/postgres/storage.go
diff options
context:
space:
mode:
Diffstat (limited to 'roomserver/storage/postgres/storage.go')
-rw-r--r--roomserver/storage/postgres/storage.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/roomserver/storage/postgres/storage.go b/roomserver/storage/postgres/storage.go
index 6f2b9661..5b5c61b0 100644
--- a/roomserver/storage/postgres/storage.go
+++ b/roomserver/storage/postgres/storage.go
@@ -471,6 +471,23 @@ func (d *Database) RoomNID(ctx context.Context, roomID string) (types.RoomNID, e
return roomNID, err
}
+// RoomNIDExcludingStubs implements query.RoomserverQueryAPIDB
+func (d *Database) RoomNIDExcludingStubs(ctx context.Context, roomID string) (roomNID types.RoomNID, err error) {
+ roomNID, err = d.RoomNID(ctx, roomID)
+ if err != nil {
+ return
+ }
+ latestEvents, _, err := d.statements.selectLatestEventNIDs(ctx, roomNID)
+ if err != nil {
+ return
+ }
+ if len(latestEvents) == 0 {
+ roomNID = 0
+ return
+ }
+ return
+}
+
// LatestEventIDs implements query.RoomserverQueryAPIDatabase
func (d *Database) LatestEventIDs(
ctx context.Context, roomNID types.RoomNID,