fix: ensure discord attachment existence is checked with message ID
This commit is contained in:
parent
f7faebe775
commit
9bb1e75939
|
@ -1806,8 +1806,8 @@ func (db sqlitePersistence) SaveDiscordMessages(messages []*protobuf.DiscordMess
|
|||
return
|
||||
}
|
||||
|
||||
func (db sqlitePersistence) HasDiscordMessageAttachmentPayload(id string) (hasPayload bool, err error) {
|
||||
err = db.db.QueryRow(`SELECT EXISTS(SELECT 1 FROM discord_message_attachments WHERE id = ? AND payload NOT NULL)`, id).Scan(&hasPayload)
|
||||
func (db sqlitePersistence) HasDiscordMessageAttachmentPayload(id string, messageID string) (hasPayload bool, err error) {
|
||||
err = db.db.QueryRow(`SELECT EXISTS(SELECT 1 FROM discord_message_attachments WHERE id = ? AND discord_message_id = ? AND payload NOT NULL)`, id, messageID).Scan(&hasPayload)
|
||||
return hasPayload, err
|
||||
}
|
||||
|
||||
|
|
|
@ -4179,7 +4179,7 @@ func (m *Messenger) prepareMessage(msg *common.Message, s *server.MediaServer) {
|
|||
|
||||
for idx, attachment := range dm.Attachments {
|
||||
if strings.Contains(attachment.ContentType, "image") {
|
||||
hasPayload, err := m.persistence.HasDiscordMessageAttachmentPayload(attachment.Id)
|
||||
hasPayload, err := m.persistence.HasDiscordMessageAttachmentPayload(attachment.Id, dm.Id)
|
||||
if err != nil {
|
||||
m.logger.Error("failed to check if message attachment exist", zap.Error(err))
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue