From 33f5a416dd0ce410375c35aee809cdfe1fed26de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20J=C3=A4gle?= Date: Tue, 25 Sep 2018 15:39:56 +0200 Subject: [PATCH] Create htreading-messages despite no-sys-messages (#534) --- .../server/methods/createThread.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/assistify-threading/server/methods/createThread.js b/packages/assistify-threading/server/methods/createThread.js index 408c059956c97..1e40cc7612591 100644 --- a/packages/assistify-threading/server/methods/createThread.js +++ b/packages/assistify-threading/server/methods/createThread.js @@ -98,7 +98,18 @@ export class ThreadBuilder { linkMessage.urls = [{url: this._getMessageUrl(repostedMessage._id)}]; - return RocketChat.models.Messages.createWithTypeRoomIdMessageAndUser('create-thread', parentRoom._id, this._getMessageUrl(repostedMessage._id), this.rocketCatUser, linkMessage, {ts: this._openingQuestion.ts}); + // we want to create a system message for linking the thread from the parent room - so the parent room + // has to support system messages at least for this interaction + if (!parentRoom.sysMes) { + RocketChat.models.Rooms.setSystemMessagesById(parentRoom._id, true); + } + RocketChat.models.Messages.createWithTypeRoomIdMessageAndUser('create-thread', parentRoom._id, this._getMessageUrl(repostedMessage._id), this.rocketCatUser, linkMessage, {ts: this._openingQuestion.ts}); + + // reset it if necessary + if (!parentRoom.sysMes) { + RocketChat.models.Rooms.setSystemMessagesById(parentRoom._id, false); + } + return true; } }