From e6d22aab1910a9b75531f27b04da843e4ef84e06 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Thu, 12 Sep 2019 00:05:51 -0700 Subject: [PATCH] pass serverId back to the server --- js/modules/loki_public_chat_api.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/js/modules/loki_public_chat_api.js b/js/modules/loki_public_chat_api.js index d0f70ba04..48c5de136 100644 --- a/js/modules/loki_public_chat_api.js +++ b/js/modules/loki_public_chat_api.js @@ -1,5 +1,5 @@ /* global log, textsecure, libloki, Signal, Whisper, Headers, ConversationController, -clearTimeout */ +clearTimeout, MessageController */ const EventEmitter = require('events'); const nodeFetch = require('node-fetch'); const { URL, URLSearchParams } = require('url'); @@ -639,6 +639,25 @@ class LokiPublicChannelAPI { }, ], }; + if (quote.id) { + // copied from model/message.js copyFromQuotedMessage + const collection = await Signal.Data.getMessagesBySentAt(quote.id, { + MessageCollection: Whisper.MessageCollection, + }); + const found = collection.find(item => { + const messageAuthor = item.getContact(); + + return messageAuthor && quote.author === messageAuthor.id; + }); + + if (found) { + const queryMessage = MessageController.register(found.id, found); + const replyTo = queryMessage.get('serverId'); + if (replyTo) { + payload.reply_to = replyTo; + } + } + } const res = await this.serverRequest(`${this.baseChannelUrl}/messages`, { method: 'POST', objBody: payload,