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()
|
_ = 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)
|
stmt, err := tx.Prepare(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -1945,11 +1945,11 @@ func (db sqlitePersistence) SaveDiscordMessages(messages []*protobuf.DiscordMess
|
||||||
for _, msg := range messages {
|
for _, msg := range messages {
|
||||||
_, err = stmt.Exec(
|
_, err = stmt.Exec(
|
||||||
msg.GetId(),
|
msg.GetId(),
|
||||||
|
msg.Author.GetId(),
|
||||||
msg.GetType(),
|
msg.GetType(),
|
||||||
msg.GetTimestamp(),
|
msg.GetTimestamp(),
|
||||||
msg.GetTimestampEdited(),
|
msg.GetTimestampEdited(),
|
||||||
msg.GetContent(),
|
msg.GetContent(),
|
||||||
msg.Author.GetId(),
|
|
||||||
msg.Reference.GetMessageId(),
|
msg.Reference.GetMessageId(),
|
||||||
msg.Reference.GetChannelId(),
|
msg.Reference.GetChannelId(),
|
||||||
msg.Reference.GetGuildId(),
|
msg.Reference.GetGuildId(),
|
||||||
|
|
|
@ -1452,5 +1452,6 @@ func TestSaveDiscordMessages(t *testing.T) {
|
||||||
dm := m.GetDiscordMessage()
|
dm := m.GetDiscordMessage()
|
||||||
require.NotNil(t, dm)
|
require.NotNil(t, dm)
|
||||||
require.EqualValues(t, id, dm.Id)
|
require.EqualValues(t, id, dm.Id)
|
||||||
|
require.EqualValues(t, "2", dm.Author.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue