mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2025-03-14 05:10:14 +01:00
Fix updating rows on SQLite. Fixes #380
This commit is contained in:
parent
fad3a053b7
commit
7c7ac37ba7
2 changed files with 4 additions and 4 deletions
|
@ -162,7 +162,7 @@ func (msg *Message) Insert() {
|
|||
func (msg *Message) MarkSent(ts time.Time) {
|
||||
msg.Sent = true
|
||||
msg.Timestamp = ts
|
||||
_, err := msg.db.Exec("UPDATE message SET sent=true, timestamp=$4 WHERE chat_jid=$1 AND chat_receiver=$2 AND jid=$3", msg.Chat.JID, msg.Chat.Receiver, msg.JID, ts.Unix())
|
||||
_, err := msg.db.Exec("UPDATE message SET sent=true, timestamp=$1 WHERE chat_jid=$2 AND chat_receiver=$3 AND jid=$4", ts.Unix(), msg.Chat.JID, msg.Chat.Receiver, msg.JID)
|
||||
if err != nil {
|
||||
msg.log.Warnfln("Failed to update %s@%s: %v", msg.Chat, msg.JID, err)
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ func (msg *Message) MarkSent(ts time.Time) {
|
|||
func (msg *Message) UpdateMXID(mxid id.EventID, stillDecryptionError bool) {
|
||||
msg.MXID = mxid
|
||||
msg.DecryptionError = stillDecryptionError
|
||||
_, err := msg.db.Exec("UPDATE message SET mxid=$4, decryption_error=$5 WHERE chat_jid=$1 AND chat_receiver=$2 AND jid=$3", msg.Chat.JID, msg.Chat.Receiver, msg.JID, mxid, stillDecryptionError)
|
||||
_, err := msg.db.Exec("UPDATE message SET mxid=$1, decryption_error=$2 WHERE chat_jid=$3 AND chat_receiver=$4 AND jid=$5", mxid, stillDecryptionError, msg.Chat.JID, msg.Chat.Receiver, msg.JID)
|
||||
if err != nil {
|
||||
msg.log.Warnfln("Failed to update %s@%s: %v", msg.Chat, msg.JID, err)
|
||||
}
|
||||
|
|
|
@ -161,8 +161,8 @@ func (portal *Portal) Insert() {
|
|||
}
|
||||
|
||||
func (portal *Portal) Update() {
|
||||
_, err := portal.db.Exec("UPDATE portal SET mxid=$3, name=$4, topic=$5, avatar=$6, avatar_url=$7, encrypted=$8, first_event_id=$9, next_batch_id=$10, relay_user_id=$11 WHERE jid=$1 AND receiver=$2",
|
||||
portal.Key.JID, portal.Key.Receiver, portal.mxidPtr(), portal.Name, portal.Topic, portal.Avatar, portal.AvatarURL.String(), portal.Encrypted, portal.FirstEventID.String(), portal.NextBatchID.String(), portal.relayUserPtr())
|
||||
_, err := portal.db.Exec("UPDATE portal SET mxid=$1, name=$2, topic=$3, avatar=$4, avatar_url=$5, encrypted=$6, first_event_id=$7, next_batch_id=$8, relay_user_id=$9 WHERE jid=$10 AND receiver=$11",
|
||||
portal.mxidPtr(), portal.Name, portal.Topic, portal.Avatar, portal.AvatarURL.String(), portal.Encrypted, portal.FirstEventID.String(), portal.NextBatchID.String(), portal.relayUserPtr(), portal.Key.JID, portal.Key.Receiver)
|
||||
if err != nil {
|
||||
portal.log.Warnfln("Failed to update %s: %v", portal.Key, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue