Skip to content

Commit

Permalink
[BREAK] Removed deprecated settings for Legacy Messages, Marked, Snip…
Browse files Browse the repository at this point in the history
…pet Messages, Autolinker and IssueLinks (#27902)
  • Loading branch information
LucianoPierdona authored Feb 10, 2023
1 parent d49c975 commit 58898f0
Show file tree
Hide file tree
Showing 68 changed files with 82 additions and 1,508 deletions.
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'))) {
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';

// 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

0 comments on commit 58898f0

Please sign in to comment.