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

[BREAK] Removed deprecated settings for Legacy Messages, Marked, Snippet Messages, Autolinker and IssueLinks #27902

Merged
merged 26 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
740b3e8
removed deprecated settings from message parser
LucianoPierdona Jan 31, 2023
a4ea222
updates
LucianoPierdona Feb 1, 2023
8576b34
Merge branch 'develop' into break/remove-deprecated-settings-message-…
LucianoPierdona Feb 1, 2023
5ca47ae
removed additional settings and fixed conditions
LucianoPierdona Feb 3, 2023
4ffd80a
lint
LucianoPierdona Feb 3, 2023
1d1a004
removed places where preference for legacy message settings was still…
LucianoPierdona Feb 3, 2023
78d345e
linting
LucianoPierdona Feb 3, 2023
7a58f07
removed unused callbacks
LucianoPierdona Feb 3, 2023
084e1df
Merge branch 'develop' into break/remove-deprecated-settings-message-…
LucianoPierdona Feb 7, 2023
2093c84
removed duplicates
LucianoPierdona Feb 8, 2023
0a4c3e2
Merge remote-tracking branch 'origin/develop' into break/remove-depre…
LucianoPierdona Feb 8, 2023
322254b
Merge remote-tracking branch 'origin/develop' into break/remove-depre…
LucianoPierdona Feb 9, 2023
4dac5cd
linting
LucianoPierdona Feb 9, 2023
23eb25e
Merge remote-tracking branch 'origin/develop' into break/remove-depre…
LucianoPierdona Feb 9, 2023
70ac898
Merge branch 'develop' into break/remove-deprecated-settings-message-…
LucianoPierdona Feb 10, 2023
4013e23
re-added embed settings
LucianoPierdona Feb 10, 2023
701f076
linting
LucianoPierdona Feb 10, 2023
73cbd66
re-added API_EmbedDisabledFor
LucianoPierdona Feb 10, 2023
0abd45d
removed autolinker and issuelinks
LucianoPierdona Feb 10, 2023
aa92f80
removed snippeted properties from messages
LucianoPierdona Feb 10, 2023
e4a1e76
removed snippet page
LucianoPierdona Feb 10, 2023
3cfffdc
removed API_EmbedDisabledFor
LucianoPierdona Feb 10, 2023
a6ec44b
move old embed settings line location
LucianoPierdona Feb 10, 2023
5d3447e
updated migration and removed unused variables
LucianoPierdona Feb 10, 2023
34d1bab
removed marked parser and smaller updates
LucianoPierdona Feb 10, 2023
52e24a7
removed not needed options
LucianoPierdona Feb 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions apps/meteor/app/api/server/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { IMessage, IUser } from '@rocket.chat/core-typings';
import { Rooms, Messages, Users } from '@rocket.chat/models';

import { canAccessRoomAsync } from '../../../authorization/server/functions/canAccessRoom';
import { getValue } from '../../../settings/server/raw';

export async function findMentionedMessages({
uid,
Expand Down Expand Up @@ -84,10 +83,6 @@ export async function findStarredMessages({
}

export async function findSnippetedMessageById({ uid, messageId }: { uid: string; messageId: string }): Promise<IMessage> {
if (!(await getValue('Message_AllowSnippeting'))) {
rodrigok marked this conversation as resolved.
Show resolved Hide resolved
throw new Error('error-not-allowed');
}

if (!uid) {
throw new Error('invalid-user');
}
Expand Down Expand Up @@ -125,9 +120,6 @@ export async function findSnippetedMessages({
offset: number;
total: number;
}> {
if (!(await getValue('Message_AllowSnippeting'))) {
throw new Error('error-not-allowed');
}
const room = await Rooms.findOneById(roomId);

if (!room || !(await canAccessRoomAsync(room, { _id: uid }))) {
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/app/autolinker/server/index.js

This file was deleted.

78 changes: 0 additions & 78 deletions apps/meteor/app/autolinker/server/settings.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/meteor/app/autotranslate/server/autotranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export abstract class AutoTranslate {
tokenizeURLs(message: IMessage): IMessage {
let count = message.tokens?.length || 0;

const schemes = settings.get<string>('Markdown_SupportSchemesForLink')?.split(',').join('|');
const schemes = 'http,https';
LucianoPierdona marked this conversation as resolved.
Show resolved Hide resolved

// Support ![alt text](http://image url) and [text](http://link)
message.msg = message.msg.replace(
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/app/issuelinks/server/index.js

This file was deleted.

21 changes: 0 additions & 21 deletions apps/meteor/app/issuelinks/server/settings.ts

This file was deleted.

7 changes: 0 additions & 7 deletions apps/meteor/app/lib/server/functions/loadMessageHistory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { settings } from '../../../settings/server';
import { Messages, Rooms } from '../../../models/server';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
import { getHiddenSystemMessages } from '../lib/getHiddenSystemMessages';
Expand Down Expand Up @@ -34,12 +33,6 @@ export function loadMessageHistory({
fields: {},
};

if (!settings.get('Message_ShowEditedStatus')) {
options.fields = {
editedAt: 0,
};
}

const records =
end != null
? Messages.findVisibleByRoomIdBeforeTimestampNotContainingTypes(rid, end, hiddenMessageTypes, options, showThreadMessages).fetch()
Expand Down
5 changes: 0 additions & 5 deletions apps/meteor/app/lib/server/methods/getChannelHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import _ from 'underscore';

import { canAccessRoom, hasPermission } from '../../../authorization/server';
import { Subscriptions, Messages, Rooms } from '../../../models/server';
import { settings } from '../../../settings/server';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
import { getHiddenSystemMessages } from '../lib/getHiddenSystemMessages';

Expand Down Expand Up @@ -59,10 +58,6 @@ Meteor.methods({
limit: count,
};

if (!settings.get('Message_ShowEditedStatus')) {
options.fields = { editedAt: 0 };
}

const records = _.isUndefined(oldest)
? Messages.findVisibleByRoomIdBeforeTimestampNotContainingTypes(
rid,
Expand Down
43 changes: 0 additions & 43 deletions apps/meteor/app/lib/server/startup/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,6 @@ settingsRegistry.addGroup('Accounts', function () {
public: true,
i18nLabel: 'Notifications_Sound_Volume',
});

this.add('Accounts_Default_User_Preferences_useLegacyMessageTemplate', false, {
type: 'boolean',
public: true,
i18nLabel: 'Use_Legacy_Message_Template',
alert: 'This_is_a_deprecated_feature_alert',
});
});

this.section('Avatar', function () {
Expand Down Expand Up @@ -1159,13 +1152,6 @@ settingsRegistry.addGroup('General', function () {

settingsRegistry.addGroup('Message', function () {
this.section('Message_Attachments', function () {
this.add('Message_Attachments_GroupAttach', false, {
type: 'boolean',
public: true,
i18nDescription: 'Message_Attachments_GroupAttachDescription',
alert: 'This_is_a_deprecated_feature_alert',
});

this.add('Message_Attachments_Thumbnails_Enabled', true, {
type: 'boolean',
public: true,
Expand Down Expand Up @@ -1240,11 +1226,6 @@ settingsRegistry.addGroup('Message', function () {
this.add('Message_AlwaysSearchRegExp', false, {
type: 'boolean',
});
this.add('Message_ShowEditedStatus', true, {
type: 'boolean',
public: true,
alert: 'This_is_a_deprecated_feature_alert',
});
this.add('Message_ShowDeletedStatus', false, {
type: 'boolean',
public: true,
Expand Down Expand Up @@ -1277,14 +1258,6 @@ settingsRegistry.addGroup('Message', function () {
type: 'boolean',
public: true,
});
/**
* @deprecated
*/
this.add('Message_ShowFormattingTips', true, {
type: 'boolean',
public: true,
alert: 'This_is_a_deprecated_feature_alert',
});
this.add('Message_GroupingPeriod', 300, {
type: 'int',
public: true,
Expand All @@ -1311,22 +1284,6 @@ settingsRegistry.addGroup('Message', function () {
actionText: 'clear',
i18nLabel: 'clear_cache_now',
});
// TODO: deprecate this setting in favor of App
this.add('API_EmbedDisabledFor', '', {
type: 'string',
public: true,
i18nDescription: 'API_EmbedDisabledFor_Description',
alert: 'This_is_a_deprecated_feature_alert',
});
// TODO: deprecate this setting in favor of App
this.add('API_EmbedIgnoredHosts', 'localhost, 127.0.0.1, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16', {
type: 'string',
i18nDescription: 'API_EmbedIgnoredHosts_Description',
});
// TODO: deprecate this setting in favor of App
this.add('API_EmbedSafePorts', '80, 443', {
type: 'string',
});
LucianoPierdona marked this conversation as resolved.
Show resolved Hide resolved
this.add('Message_TimeFormat', 'LT', {
type: 'string',
public: true,
Expand Down
37 changes: 5 additions & 32 deletions apps/meteor/app/markdown/lib/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { marked } from './parser/marked/marked';
import { original } from './parser/original/original';
import { filtered } from './parser/filtered/filtered';
import { code } from './parser/original/code';
import { settings } from '../../settings';

const parsers = {
original,
Expand All @@ -33,29 +32,11 @@ class MarkdownClass {
}

parseMessageNotEscaped(message) {
const parser = settings.get('Markdown_Parser');

if (parser === 'disabled') {
return message;
}

const options = {
supportSchemesForLink: settings.get('Markdown_SupportSchemesForLink'),
headers: settings.get('Markdown_Headers'),
rootUrl: Meteor.absoluteUrl(),
marked: {
gfm: settings.get('Markdown_Marked_GFM'),
tables: settings.get('Markdown_Marked_Tables'),
breaks: settings.get('Markdown_Marked_Breaks'),
pedantic: settings.get('Markdown_Marked_Pedantic'),
smartLists: settings.get('Markdown_Marked_SmartLists'),
smartypants: settings.get('Markdown_Marked_Smartypants'),
},
};

const parse = typeof parsers[parser] === 'function' ? parsers[parser] : parsers.original;

return parse(message, options);
return parsers.original(message, options);
LucianoPierdona marked this conversation as resolved.
Show resolved Hide resolved
}

mountTokensBackRecursively(message, tokenList, useHtml = true) {
Expand Down Expand Up @@ -91,30 +72,22 @@ class MarkdownClass {
}

filterMarkdownFromMessage(message) {
return parsers.filtered(message, {
supportSchemesForLink: settings.get('Markdown_SupportSchemesForLink'),
});
return parsers.filtered(message);
}
}

export const Markdown = new MarkdownClass();

export const filterMarkdown = (message) => Markdown.filterMarkdownFromMessage(message);

export const createMarkdownMessageRenderer = ({ parser, ...options }) => {
if (!parser || parser === 'disabled') {
return (message) => message;
}

const parse = typeof parsers[parser] === 'function' ? parsers[parser] : parsers.original;

export const createMarkdownMessageRenderer = ({ ...options }) => {
return (message) => {
if (!message?.html?.trim()) {
return message;
}

return parse(message, options);
return parsers.original(message, options);
LucianoPierdona marked this conversation as resolved.
Show resolved Hide resolved
};
};

export const createMarkdownNotificationRenderer = (options) => (message) => parsers.filtered(message, options);
export const createMarkdownNotificationRenderer = () => (message) => parsers.filtered(message);
17 changes: 1 addition & 16 deletions apps/meteor/app/markdown/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,20 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { callbacks } from '../../../lib/callbacks';
import { settings } from '../../settings/server';
import { createMarkdownMessageRenderer, createMarkdownNotificationRenderer } from '../lib/markdown';
import './settings';

export { Markdown } from '../lib/markdown';

Meteor.startup(() => {
Tracker.autorun(() => {
const options = {
parser: settings.get('Markdown_Parser'),
supportSchemesForLink: settings.get('Markdown_SupportSchemesForLink'),
headers: settings.get('Markdown_Headers'),
rootUrl: Meteor.absoluteUrl(),
marked: {
gfm: settings.get('Markdown_Marked_GFM'),
tables: settings.get('Markdown_Marked_Tables'),
breaks: settings.get('Markdown_Marked_Breaks'),
pedantic: settings.get('Markdown_Marked_Pedantic'),
smartLists: settings.get('Markdown_Marked_SmartLists'),
smartypants: settings.get('Markdown_Marked_Smartypants'),
},
};

const renderMessage = createMarkdownMessageRenderer(options);
callbacks.add('renderMessage', renderMessage, callbacks.priority.HIGH, 'markdown');
});

const renderNotification = createMarkdownNotificationRenderer({
supportSchemesForLink: settings.get('Markdown_SupportSchemesForLink'),
});
const renderNotification = createMarkdownNotificationRenderer();
callbacks.add('renderNotification', renderNotification, callbacks.priority.HIGH, 'filter-markdown');
});
Loading