forked from MirrorHub/mautrix-whatsapp
history sync: store timestamp when the message got put into the DB
This will be useful for debugging issues with missing messages
This commit is contained in:
parent
1d70cbff48
commit
17c697445d
2 changed files with 19 additions and 3 deletions
|
@ -249,10 +249,10 @@ func (hsq *HistorySyncQuery) NewMessageWithValues(userID id.UserID, conversation
|
|||
|
||||
func (hsm *HistorySyncMessage) Insert() {
|
||||
_, err := hsm.db.Exec(`
|
||||
INSERT INTO history_sync_message (user_mxid, conversation_id, message_id, timestamp, data)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
INSERT INTO history_sync_message (user_mxid, conversation_id, message_id, timestamp, data, inserted_time)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
ON CONFLICT (user_mxid, conversation_id, message_id) DO NOTHING
|
||||
`, hsm.UserID, hsm.ConversationID, hsm.MessageID, hsm.Timestamp, hsm.Data)
|
||||
`, hsm.UserID, hsm.ConversationID, hsm.MessageID, hsm.Timestamp, hsm.Data, time.Now())
|
||||
if err != nil {
|
||||
hsm.log.Warnfln("Failed to insert history sync message %s/%s: %v", hsm.ConversationID, hsm.Timestamp, err)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package upgrades
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
func init() {
|
||||
upgrades[46] = upgrade{"Add inserted time to history sync message", func(tx *sql.Tx, ctx context) error {
|
||||
// Add the inserted time TIMESTAMP column to history_sync_message
|
||||
_, err := tx.Exec(`
|
||||
ALTER TABLE history_sync_message
|
||||
ADD COLUMN inserted_time TIMESTAMP
|
||||
`)
|
||||
return err
|
||||
}}
|
||||
}
|
Loading…
Reference in a new issue