Skip to content

Commit

Permalink
Use correct id for reply stubs
Browse files Browse the repository at this point in the history
If we use only replyId the persistence layer doesn't know (without more
context we probably don't want it to need to dig around for) which kind
of id this is. We have a decent idea when we're creating the stub so
just do it there.
  • Loading branch information
singpolyma committed Dec 10, 2024
1 parent 832dcd5 commit 8cf0d49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions snikket/Message.hx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ class Message {
final replyToMessage = new ChatMessage();
replyToMessage.from = replyToJid == null ? null : JID.parse(replyToJid);
replyToMessage.replyId = replyToID;
if (isGroupchat) {
replyToMessage.serverId = replyToID;
} else {
replyToMessage.localId = replyToID;
}
msg.replyToMessage = replyToMessage;
}
}
Expand Down
2 changes: 1 addition & 1 deletion snikket/persistence/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ const browser = (dbname, tokenize, stemmer) => {
if (message.serverId && !message.serverIdBy) throw "Cannot store a message with a server id and no by";
new Promise((resolve) =>
// Hydrate reply stubs
message.replyToMessage && !message.replyToMessage.serverIdBy ? this.getMessage(account, message.chatId(), message.replyToMessage.getReplyId(), message.replyToMessage.getReplyId(), resolve) : resolve(message.replyToMessage)
message.replyToMessage && !message.replyToMessage.serverIdBy ? this.getMessage(account, message.chatId(), message.replyToMessage.serverId, message.replyToMessage.localId, resolve) : resolve(message.replyToMessage)
).then((replyToMessage) => {
message.replyToMessage = replyToMessage;
const tx = db.transaction(["messages", "reactions"], "readwrite");
Expand Down

0 comments on commit 8cf0d49

Please sign in to comment.