diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-10-04 15:01:17 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-10-05 17:36:50 +0200 |
commit | c7fed3599c3a0bf60587670457a3c55b931ade14 (patch) | |
tree | 35b6c126d2961865fd9d6f63237d1aa77cad86bb | |
parent | 67ccbed911b76a66670facec5b10e8b0fc4b889e (diff) | |
download | server-c7fed3599c3a0bf60587670457a3c55b931ade14.tar.gz |
Use unixepoch in chat log messages.
-rw-r--r-- | public/common/play.js | 4 | ||||
-rw-r--r-- | server.js | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/public/common/play.js b/public/common/play.js index 2fe3e2e..25f237a 100644 --- a/public/common/play.js +++ b/public/common/play.js @@ -193,7 +193,7 @@ function save_chat() { window.localStorage.setItem(chat.key, chat.log) } -function update_chat(chat_id, utc_date, user, message) { +function update_chat(chat_id, raw_date, user, message) { function format_time(date) { let mm = date.getMinutes() let hh = date.getHours() @@ -215,7 +215,7 @@ function update_chat(chat_id, utc_date, user, message) { } if (chat_id > chat.log) { chat.log = chat_id - let date = new Date(utc_date + "Z") + let date = new Date(raw_date * 1000) let day = date.toDateString() if (day !== chat.last_day) { add_date_line(day) @@ -1060,11 +1060,11 @@ load_rules() const SQL_INSERT_GAME = SQL("INSERT INTO games (owner_id,title_id,scenario,options,is_private,is_random,description) VALUES (?,?,?,?,?,?,?)") const SQL_DELETE_GAME = SQL("DELETE FROM games WHERE game_id=? AND owner_id=?") -const SQL_SELECT_USER_CHAT = SQL("SELECT game_id,time,name,message FROM game_chat_view WHERE game_id IN ( SELECT DISTINCT game_id FROM players WHERE user_id=? ) ORDER BY chat_id DESC").raw() -const SQL_SELECT_USER_CHAT_N = SQL("SELECT game_id,time,name,message FROM game_chat_view WHERE game_id IN ( SELECT DISTINCT game_id FROM players WHERE user_id=? ) ORDER BY chat_id DESC LIMIT ?").raw() +const SQL_SELECT_USER_CHAT = SQL("SELECT game_id,unixepoch(time),name,message FROM game_chat_view WHERE game_id IN ( SELECT DISTINCT game_id FROM players WHERE user_id=? ) ORDER BY chat_id DESC").raw() +const SQL_SELECT_USER_CHAT_N = SQL("SELECT game_id,unixepoch(time),name,message FROM game_chat_view WHERE game_id IN ( SELECT DISTINCT game_id FROM players WHERE user_id=? ) ORDER BY chat_id DESC LIMIT ?").raw() -const SQL_SELECT_GAME_CHAT = SQL("SELECT chat_id,time,name,message FROM game_chat_view WHERE game_id=? AND chat_id>?").raw() -const SQL_INSERT_GAME_CHAT = SQL("INSERT INTO game_chat (game_id,user_id,message) VALUES (?,?,?) RETURNING chat_id,time,'',message").raw() +const SQL_SELECT_GAME_CHAT = SQL("SELECT chat_id,unixepoch(time),name,message FROM game_chat_view WHERE game_id=? AND chat_id>?").raw() +const SQL_INSERT_GAME_CHAT = SQL("INSERT INTO game_chat (game_id,user_id,message) VALUES (?,?,?) RETURNING chat_id,unixepoch(time),NULL,message").raw() const SQL_SELECT_GAME_NOTE = SQL("SELECT note FROM game_notes WHERE game_id=? AND role=?").pluck() const SQL_UPDATE_GAME_NOTE = SQL("INSERT OR REPLACE INTO game_notes (game_id,role,note) VALUES (?,?,?)") |