Fixed DMs
This commit is contained in:
@@ -48,7 +48,6 @@ func InitDB() {
|
||||
FOREIGN KEY (room_id) REFERENCES rooms(id),
|
||||
FOREIGN KEY (username) REFERENCES users(username)
|
||||
);
|
||||
-- Stores the encrypted room key for a specific user for a specific epoch
|
||||
CREATE TABLE IF NOT EXISTS user_room_keys (
|
||||
username TEXT,
|
||||
room_id TEXT,
|
||||
@@ -132,6 +131,12 @@ func getRoomIDByName(name string) (string, error) {
|
||||
return id, err
|
||||
}
|
||||
|
||||
func getRoomCreator(roomID string) (string, error) {
|
||||
var creator string
|
||||
err := db.QueryRow("SELECT creator FROM rooms WHERE id = ?", roomID).Scan(&creator)
|
||||
return creator, err
|
||||
}
|
||||
|
||||
func getRoomCurrentEpoch(roomID string) (int, error) {
|
||||
var epoch int
|
||||
err := db.QueryRow("SELECT current_epoch FROM rooms WHERE id = ?", roomID).Scan(&epoch)
|
||||
@@ -140,7 +145,6 @@ func getRoomCurrentEpoch(roomID string) (int, error) {
|
||||
|
||||
func incrementRoomEpoch(roomID string) (int, error) {
|
||||
var newEpoch int
|
||||
// Atomic increment
|
||||
err := db.QueryRow("UPDATE rooms SET current_epoch = current_epoch + 1 WHERE id = ? RETURNING current_epoch", roomID).Scan(&newEpoch)
|
||||
return newEpoch, err
|
||||
}
|
||||
@@ -175,7 +179,6 @@ func leaveRoom(roomID, username string) error {
|
||||
}
|
||||
|
||||
func joinRoomMember(roomID, username string) error {
|
||||
// Check if already joined
|
||||
var count int
|
||||
db.QueryRow("SELECT COUNT(*) FROM room_members WHERE room_id = ? AND username = ?", roomID, username).Scan(&count)
|
||||
if count > 0 {
|
||||
|
||||
Reference in New Issue
Block a user