mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-11 17:03:10 -06:00
Rename for more accuracy
This commit is contained in:
parent
135a811fc7
commit
41b6411389
|
|
@ -62,7 +62,7 @@ const selectLatestEventNIDsForUpdateSQL = "" +
|
||||||
const selectVisibilityForRoomNIDSQL = "" +
|
const selectVisibilityForRoomNIDSQL = "" +
|
||||||
"SELECT visibility FROM roomserver_rooms WHERE room_nid = $1"
|
"SELECT visibility FROM roomserver_rooms WHERE room_nid = $1"
|
||||||
|
|
||||||
const selectVisibleRoomIDsSQL = "" +
|
const selectPublicRoomIDsSQL = "" +
|
||||||
"SELECT room_id FROM roomserver_rooms WHERE visibility = true"
|
"SELECT room_id FROM roomserver_rooms WHERE visibility = true"
|
||||||
|
|
||||||
const updateLatestEventNIDsSQL = "" +
|
const updateLatestEventNIDsSQL = "" +
|
||||||
|
|
@ -77,7 +77,7 @@ type roomStatements struct {
|
||||||
selectLatestEventNIDsStmt *sql.Stmt
|
selectLatestEventNIDsStmt *sql.Stmt
|
||||||
selectLatestEventNIDsForUpdateStmt *sql.Stmt
|
selectLatestEventNIDsForUpdateStmt *sql.Stmt
|
||||||
selectVisibilityForRoomNIDStmt *sql.Stmt
|
selectVisibilityForRoomNIDStmt *sql.Stmt
|
||||||
selectVisibleRoomIDsStmt *sql.Stmt
|
selectPublicRoomIDsStmt *sql.Stmt
|
||||||
updateLatestEventNIDsStmt *sql.Stmt
|
updateLatestEventNIDsStmt *sql.Stmt
|
||||||
updateVisibilityForRoomNIDStmt *sql.Stmt
|
updateVisibilityForRoomNIDStmt *sql.Stmt
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +93,7 @@ func (s *roomStatements) prepare(db *sql.DB) (err error) {
|
||||||
{&s.selectLatestEventNIDsStmt, selectLatestEventNIDsSQL},
|
{&s.selectLatestEventNIDsStmt, selectLatestEventNIDsSQL},
|
||||||
{&s.selectLatestEventNIDsForUpdateStmt, selectLatestEventNIDsForUpdateSQL},
|
{&s.selectLatestEventNIDsForUpdateStmt, selectLatestEventNIDsForUpdateSQL},
|
||||||
{&s.selectVisibilityForRoomNIDStmt, selectVisibilityForRoomNIDSQL},
|
{&s.selectVisibilityForRoomNIDStmt, selectVisibilityForRoomNIDSQL},
|
||||||
{&s.selectVisibleRoomIDsStmt, selectVisibleRoomIDsSQL},
|
{&s.selectPublicRoomIDsStmt, selectPublicRoomIDsSQL},
|
||||||
{&s.updateLatestEventNIDsStmt, updateLatestEventNIDsSQL},
|
{&s.updateLatestEventNIDsStmt, updateLatestEventNIDsSQL},
|
||||||
{&s.updateVisibilityForRoomNIDStmt, updateVisibilityForRoomNIDSQL},
|
{&s.updateVisibilityForRoomNIDStmt, updateVisibilityForRoomNIDSQL},
|
||||||
}.prepare(db)
|
}.prepare(db)
|
||||||
|
|
@ -148,9 +148,9 @@ func (s *roomStatements) selectVisibilityForRoomNID(roomNID types.RoomNID) (bool
|
||||||
return visibility, err
|
return visibility, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *roomStatements) selectVisibleRoomIDs() ([]string, error) {
|
func (s *roomStatements) selectPublicRoomIDs() ([]string, error) {
|
||||||
roomIDs := []string{}
|
roomIDs := []string{}
|
||||||
rows, err := s.selectVisibleRoomIDsStmt.Query()
|
rows, err := s.selectPublicRoomIDsStmt.Query()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return roomIDs, err
|
return roomIDs, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -370,9 +370,7 @@ func (d *Database) GetAliasesFromRoomID(roomID string) ([]string, error) {
|
||||||
return d.statements.selectAliasesFromRoomID(roomID)
|
return d.statements.selectAliasesFromRoomID(roomID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAliasesFromRoomIDs returns a map of the aliases bound to a given set of
|
// GetAliasesFromRoomIDs implements publicroom.RoomserverPublicRoomAPIDB
|
||||||
// room IDs, ordered by room ID (ie map[roomID] = []alias)
|
|
||||||
// Returns an error if the retrieval failed
|
|
||||||
func (d *Database) GetAliasesFromRoomIDs(roomIDs []string) (map[string][]string, error) {
|
func (d *Database) GetAliasesFromRoomIDs(roomIDs []string) (map[string][]string, error) {
|
||||||
return d.statements.selectAliasesFromRoomIDs(roomIDs)
|
return d.statements.selectAliasesFromRoomIDs(roomIDs)
|
||||||
}
|
}
|
||||||
|
|
@ -389,26 +387,17 @@ func (d *Database) StateEntriesForTuples(
|
||||||
return d.statements.bulkSelectFilteredStateBlockEntries(stateBlockNIDs, stateKeyTuples)
|
return d.statements.bulkSelectFilteredStateBlockEntries(stateBlockNIDs, stateKeyTuples)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsRoomVisibleFromRoomNID checks the visibility of the room identified by the
|
// IsRoomPublic implements publicroom.RoomserverPublicRoomAPIDB
|
||||||
// given numeric ID. Returns true if the room is publicly visible, returns false
|
func (d *Database) IsRoomPublic(roomNID types.RoomNID) (bool, error) {
|
||||||
// if not.
|
|
||||||
// If there's no room matching this numeric ID, or if the retrieval failed,
|
|
||||||
// returns an error.
|
|
||||||
func (d *Database) IsRoomVisibleFromRoomNID(roomNID types.RoomNID) (bool, error) {
|
|
||||||
return d.statements.selectVisibilityForRoomNID(roomNID)
|
return d.statements.selectVisibilityForRoomNID(roomNID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetVisibleRoomIDs returns an array of string containing the room IDs of the
|
// GetPublicRoomIDs implements publicroom.RoomserverPublicRoomAPIDB
|
||||||
// rooms that are publicly visible.
|
func (d *Database) GetPublicRoomIDs() ([]string, error) {
|
||||||
// Returns an error if the retrieval failed.
|
return d.statements.selectPublicRoomIDs()
|
||||||
func (d *Database) GetVisibleRoomIDs() ([]string, error) {
|
|
||||||
return d.statements.selectVisibleRoomIDs()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRoomVisibility updates the visibility for a room to the given value:
|
// UpdateRoomVisibility implements publicroom.RoomserverPublicRoomAPIDB
|
||||||
// true means that the room is publicly visible, false means that the room isn't
|
|
||||||
// publicly visible.
|
|
||||||
// Returns an error if the update failed.
|
|
||||||
func (d *Database) UpdateRoomVisibility(roomNID types.RoomNID, visibility bool) error {
|
func (d *Database) UpdateRoomVisibility(roomNID types.RoomNID, visibility bool) error {
|
||||||
return d.statements.updateVisibilityForRoomNID(roomNID, visibility)
|
return d.statements.updateVisibilityForRoomNID(roomNID, visibility)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue