Update presence table

This commit is contained in:
Till Faelligen 2021-07-31 19:18:01 +02:00
parent ca7a6c9eb9
commit 017d9fc687

View file

@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS presence_presences (
-- The actual presence -- The actual presence
presence INT NOT NULL, presence INT NOT NULL,
-- The status message -- The status message
status_msg TEXT, status_msg TEXT NOT NULL,
-- The last time an action was received by this user -- The last time an action was received by this user
last_active_ts BIGINT NOT NULL, last_active_ts BIGINT NOT NULL,
CONSTRAINT presence_presences_unique UNIQUE (user_id) CONSTRAINT presence_presences_unique UNIQUE (user_id)
@ -102,13 +102,7 @@ func (p *presenceStatements) UpsertPresence(
lastActiveTS int64, lastActiveTS int64,
) (pos int64, err error) { ) (pos int64, err error) {
stmt := sqlutil.TxStmt(txn, p.upsertPresenceStmt) stmt := sqlutil.TxStmt(txn, p.upsertPresenceStmt)
msg := &statusMsg err = stmt.QueryRowContext(ctx, userID, presence, statusMsg, lastActiveTS).Scan(&pos)
// avoid clearing status_msg when going idle
// makes it impossible to delete status_msg, though..
if statusMsg == "" {
msg = nil
}
err = stmt.QueryRowContext(ctx, userID, presence, msg, lastActiveTS).Scan(&pos)
return return
} }