fix(message_persistence): ensure discord message author id is stored correctly
This commit is contained in:
parent
3f987cc565
commit
16feb64671
|
@ -1935,7 +1935,7 @@ func (db sqlitePersistence) SaveDiscordMessages(messages []*protobuf.DiscordMess
|
|||
_ = tx.Rollback()
|
||||
}()
|
||||
|
||||
query := "INSERT INTO discord_messages(id, author_id, type, timestamp, timestamp_edited, content, reference_message_id, reference_channel_id, reference_guild_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
query := "INSERT OR REPLACE INTO discord_messages(id, author_id, type, timestamp, timestamp_edited, content, reference_message_id, reference_channel_id, reference_guild_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||
stmt, err := tx.Prepare(query)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -1945,11 +1945,11 @@ func (db sqlitePersistence) SaveDiscordMessages(messages []*protobuf.DiscordMess
|
|||
for _, msg := range messages {
|
||||
_, err = stmt.Exec(
|
||||
msg.GetId(),
|
||||
msg.Author.GetId(),
|
||||
msg.GetType(),
|
||||
msg.GetTimestamp(),
|
||||
msg.GetTimestampEdited(),
|
||||
msg.GetContent(),
|
||||
msg.Author.GetId(),
|
||||
msg.Reference.GetMessageId(),
|
||||
msg.Reference.GetChannelId(),
|
||||
msg.Reference.GetGuildId(),
|
||||
|
|
|
@ -1452,5 +1452,6 @@ func TestSaveDiscordMessages(t *testing.T) {
|
|||
dm := m.GetDiscordMessage()
|
||||
require.NotNil(t, dm)
|
||||
require.EqualValues(t, id, dm.Id)
|
||||
require.EqualValues(t, "2", dm.Author.Id)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue