Rename for more accuracy

This commit is contained in:
Brendan Abolivier 2017-08-08 18:41:35 +01:00
parent 135a811fc7
commit 41b6411389
No known key found for this signature in database
GPG key ID: 8EF1500759F70623
2 changed files with 12 additions and 23 deletions

View file

@ -62,7 +62,7 @@ const selectLatestEventNIDsForUpdateSQL = "" +
const selectVisibilityForRoomNIDSQL = "" +
"SELECT visibility FROM roomserver_rooms WHERE room_nid = $1"
const selectVisibleRoomIDsSQL = "" +
const selectPublicRoomIDsSQL = "" +
"SELECT room_id FROM roomserver_rooms WHERE visibility = true"
const updateLatestEventNIDsSQL = "" +
@ -77,7 +77,7 @@ type roomStatements struct {
selectLatestEventNIDsStmt *sql.Stmt
selectLatestEventNIDsForUpdateStmt *sql.Stmt
selectVisibilityForRoomNIDStmt *sql.Stmt
selectVisibleRoomIDsStmt *sql.Stmt
selectPublicRoomIDsStmt *sql.Stmt
updateLatestEventNIDsStmt *sql.Stmt
updateVisibilityForRoomNIDStmt *sql.Stmt
}
@ -93,7 +93,7 @@ func (s *roomStatements) prepare(db *sql.DB) (err error) {
{&s.selectLatestEventNIDsStmt, selectLatestEventNIDsSQL},
{&s.selectLatestEventNIDsForUpdateStmt, selectLatestEventNIDsForUpdateSQL},
{&s.selectVisibilityForRoomNIDStmt, selectVisibilityForRoomNIDSQL},
{&s.selectVisibleRoomIDsStmt, selectVisibleRoomIDsSQL},
{&s.selectPublicRoomIDsStmt, selectPublicRoomIDsSQL},
{&s.updateLatestEventNIDsStmt, updateLatestEventNIDsSQL},
{&s.updateVisibilityForRoomNIDStmt, updateVisibilityForRoomNIDSQL},
}.prepare(db)
@ -148,9 +148,9 @@ func (s *roomStatements) selectVisibilityForRoomNID(roomNID types.RoomNID) (bool
return visibility, err
}
func (s *roomStatements) selectVisibleRoomIDs() ([]string, error) {
func (s *roomStatements) selectPublicRoomIDs() ([]string, error) {
roomIDs := []string{}
rows, err := s.selectVisibleRoomIDsStmt.Query()
rows, err := s.selectPublicRoomIDsStmt.Query()
if err != nil {
return roomIDs, err
}

View file

@ -370,9 +370,7 @@ func (d *Database) GetAliasesFromRoomID(roomID string) ([]string, error) {
return d.statements.selectAliasesFromRoomID(roomID)
}
// GetAliasesFromRoomIDs returns a map of the aliases bound to a given set of
// room IDs, ordered by room ID (ie map[roomID] = []alias)
// Returns an error if the retrieval failed
// GetAliasesFromRoomIDs implements publicroom.RoomserverPublicRoomAPIDB
func (d *Database) GetAliasesFromRoomIDs(roomIDs []string) (map[string][]string, error) {
return d.statements.selectAliasesFromRoomIDs(roomIDs)
}
@ -389,26 +387,17 @@ func (d *Database) StateEntriesForTuples(
return d.statements.bulkSelectFilteredStateBlockEntries(stateBlockNIDs, stateKeyTuples)
}
// IsRoomVisibleFromRoomNID checks the visibility of the room identified by the
// given numeric ID. Returns true if the room is publicly visible, returns false
// 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) {
// IsRoomPublic implements publicroom.RoomserverPublicRoomAPIDB
func (d *Database) IsRoomPublic(roomNID types.RoomNID) (bool, error) {
return d.statements.selectVisibilityForRoomNID(roomNID)
}
// GetVisibleRoomIDs returns an array of string containing the room IDs of the
// rooms that are publicly visible.
// Returns an error if the retrieval failed.
func (d *Database) GetVisibleRoomIDs() ([]string, error) {
return d.statements.selectVisibleRoomIDs()
// GetPublicRoomIDs implements publicroom.RoomserverPublicRoomAPIDB
func (d *Database) GetPublicRoomIDs() ([]string, error) {
return d.statements.selectPublicRoomIDs()
}
// UpdateRoomVisibility updates the visibility for a room to the given value:
// true means that the room is publicly visible, false means that the room isn't
// publicly visible.
// Returns an error if the update failed.
// UpdateRoomVisibility implements publicroom.RoomserverPublicRoomAPIDB
func (d *Database) UpdateRoomVisibility(roomNID types.RoomNID, visibility bool) error {
return d.statements.updateVisibilityForRoomNID(roomNID, visibility)
}