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 all 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
68 changes: 0 additions & 68 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 @@ -83,73 +82,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');
}

const snippet = await Messages.findOne({ _id: messageId, snippeted: true });

if (!snippet) {
throw new Error('invalid-message');
}

const room = await Rooms.findOneById(snippet.rid);

if (!room) {
throw new Error('invalid-message');
}

if (!(await canAccessRoomAsync(room, { _id: uid }))) {
throw new Error('error-not-allowed');
}

return snippet;
}

export async function findSnippetedMessages({
uid,
roomId,
pagination: { offset, count, sort },
}: {
uid: string;
roomId: string;
pagination: { offset: number; count: number; sort: FindOptions<IMessage>['sort'] };
}): Promise<{
messages: IMessage[];
count: number;
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 }))) {
throw new Error('error-not-allowed');
}

const { cursor, totalCount } = Messages.findSnippetedByRoom(roomId, {
sort: sort || { ts: -1 },
skip: offset,
limit: count,
});

const [messages, total] = await Promise.all([cursor.toArray(), totalCount]);

return {
messages,
count: messages.length,
offset,
total,
};
}

export async function findDiscussionsFromRoom({
uid,
roomId,
Expand Down
57 changes: 1 addition & 56 deletions apps/meteor/app/api/server/v1/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ import Rooms from '../../../models/server/models/Rooms';
import Users from '../../../models/server/models/Users';
import Subscriptions from '../../../models/server/models/Subscriptions';
import { settings } from '../../../settings/server';
import {
findMentionedMessages,
findStarredMessages,
findSnippetedMessageById,
findSnippetedMessages,
findDiscussionsFromRoom,
} from '../lib/messages';
import { findMentionedMessages, findStarredMessages, findDiscussionsFromRoom } from '../lib/messages';

API.v1.addRoute(
'chat.delete',
Expand Down Expand Up @@ -786,55 +780,6 @@ API.v1.addRoute(
},
);

API.v1.addRoute(
'chat.getSnippetedMessageById',
{ authRequired: true },
{
get() {
const { messageId } = this.queryParams;

if (!messageId) {
throw new Meteor.Error('error-invalid-params', 'The required "messageId" query param is missing.');
}
const message = Promise.await(
findSnippetedMessageById({
uid: this.userId,
messageId,
}),
);
return API.v1.success(message);
},
},
);

API.v1.addRoute(
'chat.getSnippetedMessages',
{ authRequired: true },
{
get() {
const { roomId } = this.queryParams;
const { sort } = this.parseJsonQuery();
const { offset, count } = this.getPaginationItems();

if (!roomId) {
throw new Meteor.Error('error-invalid-params', 'The required "roomId" query param is missing.');
}
const messages = Promise.await(
findSnippetedMessages({
uid: this.userId,
roomId,
pagination: {
offset,
count,
sort,
},
}),
);
return API.v1.success(messages);
},
},
);

API.v1.addRoute(
'chat.getDiscussions',
{ authRequired: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export const upsertPermissions = async (): Promise<void> => {
{ _id: 'manage-sounds', roles: ['admin'] },
{ _id: 'access-mailer', roles: ['admin'] },
{ _id: 'pin-message', roles: ['owner', 'moderator', 'admin'] },
{ _id: 'snippet-message', roles: ['owner', 'moderator', 'admin'] },
{ _id: 'mobile-upload-file', roles: ['user', 'admin'] },
{ _id: 'send-mail', roles: ['admin'] },
{ _id: 'view-federation-data', roles: ['admin'] },
Expand Down
58 changes: 0 additions & 58 deletions apps/meteor/app/autolinker/client/client.js

This file was deleted.

1 change: 0 additions & 1 deletion apps/meteor/app/autolinker/client/index.js

This file was deleted.

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
14 changes: 0 additions & 14 deletions apps/meteor/app/issuelinks/client/client.js

This file was deleted.

1 change: 0 additions & 1 deletion apps/meteor/app/issuelinks/client/index.js

This file was deleted.

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
Loading