Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Adds settings to limit chain of quotes #7273

Merged
merged 9 commits into from
Jun 30, 2017
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,7 @@
"Message_MaxAll": "Maximum channel size for ALL message",
"Message_MaxAllowedSize": "Maximum Allowed Message Size",
"Message_pinning": "Message pinning",
"Message_QuoteChainLimit": "Maximum Number of Chained Quotes",
"Message_removed": "Message removed",
"Message_SetNameToAliasEnabled": "Set a user name to alias in message",
"Message_SetNameToAliasEnabled_Description": "Only if not already set alias. The old messages alias not changed if user has changed the name.",
Expand Down
5 changes: 5 additions & 0 deletions packages/rocketchat-lib/server/startup/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ RocketChat.settings.addGroup('Message', function() {
'public': true,
i18nDescription: 'Message_TimeAndDateFormat_Description'
});
this.add('Message_QuoteChainLimit', 2, {
type: 'int',
'public': true
});
this.add('Message_HideType_uj', false, {
type: 'boolean',
'public': true
Expand All @@ -822,6 +826,7 @@ RocketChat.settings.addGroup('Message', function() {
type: 'boolean',
'public': true
});

return this.add('Message_HideType_mute_unmute', false, {
type: 'boolean',
'public': true
Expand Down
11 changes: 11 additions & 0 deletions packages/rocketchat-oembed/server/jumpToMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ RocketChat.callbacks.add('beforeSaveMessage', (msg) => {
if (_.isString(queryString.msg)) { // Jump-to query param
const jumpToMessage = RocketChat.models.Messages.findOneById(queryString.msg);
if (jumpToMessage) {
let chainQuotes = jumpToMessage;
let index = 1;
while (chainQuotes && 'attachments' in chainQuotes) {
if (index >= RocketChat.settings.get('Message_QuoteChainLimit')) {
delete(chainQuotes.attachments);
break;
}
chainQuotes = chainQuotes.attachments[0];
index++;
}

msg.attachments = msg.attachments || [];
msg.attachments.push({
'text' : jumpToMessage.msg,
Expand Down