Propagate staff reply edits/deletions to the DB

cshd
Dragory 2020-07-19 14:28:32 +03:00
parent e74363a55c
commit ce8ebbfc2f
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
1 changed files with 25 additions and 2 deletions

View File

@ -136,8 +136,8 @@ class Thread {
}
/**
* @param {string} id
* @param {Object} data
* @param {number} id
* @param {object} data
* @returns {Promise<void>}
* @private
*/
@ -147,6 +147,17 @@ class Thread {
.update(data);
}
/**
* @param {number} id
* @returns {Promise<void>}
* @private
*/
async _deleteThreadMessage(id) {
await knex('thread_messages')
.where('id', id)
.delete();
}
/**
* @returns {string}
* @private
@ -561,6 +572,14 @@ class Thread {
{ isAnonymous: threadMessage.is_anonymous }
);
// FIXME: Fix attachment links disappearing by moving them off the main message content in the DB
const formattedLog = formatters.formatStaffReplyLogMessage(
moderator,
newText,
threadMessage.message_number,
{ isAnonymous: threadMessage.is_anonymous }
);
await bot.editMessage(threadMessage.dm_channel_id, threadMessage.dm_message_id, formattedDM);
await bot.editMessage(this.channel_id, threadMessage.inbox_message_id, formattedThreadMessage);
@ -569,6 +588,8 @@ class Thread {
const logNotification = formatters.formatStaffReplyEditNotificationLogMessage(moderator, threadMessage, newText);
await this.postSystemMessage(threadNotification, null, { logBody: logNotification });
}
await this._updateThreadMessage(threadMessage.id, { body: formattedLog });
}
/**
@ -587,6 +608,8 @@ class Thread {
const logNotification = formatters.formatStaffReplyDeletionNotificationLogMessage(moderator, threadMessage);
await this.postSystemMessage(threadNotification, null, { logBody: logNotification });
}
await this._deleteThreadMessage(threadMessage.id);
}
/**