Skip to content

Commit

Permalink
Merge branch 'develop' into chore/move-getUserDisplayName
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Feb 14, 2025
2 parents 80d9100 + a9956c0 commit ae290e6
Show file tree
Hide file tree
Showing 23 changed files with 726 additions and 218 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-starfishes-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes broken link and improves messaging for invalid apps banner.
5 changes: 5 additions & 0 deletions .changeset/purple-laws-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes an issue where non-Latin highlights were inconsistently applied, ensuring non-Latin characters are reliably detected and highlighted.
6 changes: 4 additions & 2 deletions apps/meteor/app/api/server/v1/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { saveRoomSettings } from '../../../channel-settings/server/methods/saveR
import { mountIntegrationQueryBasedOnPermissions } from '../../../integrations/server/lib/mountQueriesBasedOnPermission';
import { addUsersToRoomMethod } from '../../../lib/server/methods/addUsersToRoom';
import { createChannelMethod } from '../../../lib/server/methods/createChannel';
import { getChannelHistory } from '../../../lib/server/methods/getChannelHistory';
import { leaveRoomMethod } from '../../../lib/server/methods/leaveRoom';
import { settings } from '../../../settings/server';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
Expand Down Expand Up @@ -163,10 +164,11 @@ API.v1.addRoute(

const { count = 20, offset = 0 } = await getPaginationItems(this.queryParams);

const result = await Meteor.callAsync('getChannelHistory', {
const result = await getChannelHistory({
rid: findResult._id,
fromUserId: this.userId,
latest: latest ? new Date(latest) : new Date(),
oldest: oldest && new Date(oldest),
oldest: oldest ? new Date(oldest) : undefined,
inclusive: inclusive === 'true',
offset,
count,
Expand Down
9 changes: 5 additions & 4 deletions apps/meteor/app/api/server/v1/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Meteor } from 'meteor/meteor';

import { reportMessage } from '../../../../server/lib/moderation/reportMessage';
import { messageSearch } from '../../../../server/methods/messageSearch';
import { getMessageHistory } from '../../../../server/publications/messages';
import { roomAccessAttributes } from '../../../authorization/server';
import { canAccessRoomAsync, canAccessRoomIdAsync } from '../../../authorization/server/functions/canAccessRoom';
import { canSendMessageAsync } from '../../../authorization/server/functions/canSendMessage';
Expand Down Expand Up @@ -101,17 +102,17 @@ API.v1.addRoute(
...(type && { type }),
};

const result = await Meteor.callAsync('messages/get', roomId, getMessagesQuery);
const result = await getMessageHistory(roomId, this.userId, getMessagesQuery);

if (!result) {
return API.v1.failure();
}

return API.v1.success({
result: {
...(result.updated && { updated: await normalizeMessagesForUser(result.updated, this.userId) }),
...(result.deleted && { deleted: result.deleted }),
...(result.cursor && { cursor: result.cursor }),
updated: 'updated' in result ? await normalizeMessagesForUser(result.updated, this.userId) : [],
deleted: 'deleted' in result ? result.deleted : [],
cursor: 'cursor' in result ? result.cursor : undefined,
},
});
},
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/app/api/server/v1/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { hasAllPermissionAsync, hasPermissionAsync } from '../../../authorizatio
import { saveRoomSettings } from '../../../channel-settings/server/methods/saveRoomSettings';
import { mountIntegrationQueryBasedOnPermissions } from '../../../integrations/server/lib/mountQueriesBasedOnPermission';
import { createPrivateGroupMethod } from '../../../lib/server/methods/createPrivateGroup';
import { getChannelHistory } from '../../../lib/server/methods/getChannelHistory';
import { leaveRoomMethod } from '../../../lib/server/methods/leaveRoom';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
import { API } from '../api';
Expand Down Expand Up @@ -505,8 +506,9 @@ API.v1.addRoute(

const showThreadMessages = this.queryParams.showThreadMessages !== 'false';

const result = await Meteor.callAsync('getChannelHistory', {
const result = await getChannelHistory({
rid: findResult.rid,
fromUserId: this.userId,
latest: latestDate,
oldest: oldestDate,
inclusive,
Expand Down
6 changes: 4 additions & 2 deletions apps/meteor/app/api/server/v1/im.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { canAccessRoomIdAsync } from '../../../authorization/server/functions/ca
import { hasAtLeastOnePermissionAsync, hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { saveRoomSettings } from '../../../channel-settings/server/methods/saveRoomSettings';
import { getRoomByNameOrIdWithOptionToJoin } from '../../../lib/server/functions/getRoomByNameOrIdWithOptionToJoin';
import { getChannelHistory } from '../../../lib/server/methods/getChannelHistory';
import { settings } from '../../../settings/server';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
import { API } from '../api';
Expand Down Expand Up @@ -277,16 +278,17 @@ API.v1.addRoute(

const objectParams = {
rid: room._id,
fromUserId: this.userId,
latest: latest ? new Date(latest) : new Date(),
oldest: oldest && new Date(oldest),
oldest: oldest ? new Date(oldest) : undefined,
inclusive: inclusive === 'true',
offset,
count,
unreads: unreads === 'true',
showThreadMessages: showThreadMessages === 'true',
};

const result = await Meteor.callAsync('getChannelHistory', objectParams);
const result = await getChannelHistory(objectParams);

if (!result) {
return API.v1.forbidden();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { OauthConfig } from '@rocket.chat/core-typings';
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { useSetting } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';

import { CustomOAuth } from '../../custom-oauth/client/CustomOAuth';
import { settings } from '../../settings/client';
import { CustomOAuth } from '../../../custom-oauth/client/CustomOAuth';

// Drupal Server CallBack URL needs to be http(s)://{rocketchat.server}[:port]/_oauth/drupal
// In RocketChat -> Administration the URL needs to be http(s)://{drupal.server}/
Expand All @@ -26,11 +25,13 @@ const config: OauthConfig = {

const Drupal = new CustomOAuth('drupal', config);

Meteor.startup(() => {
Tracker.autorun(() => {
if (settings.get('API_Drupal_URL')) {
config.serverURL = settings.get('API_Drupal_URL');
export const useDrupal = () => {
const drupalUrl = useSetting('API_Drupal_URL') as string;

useEffect(() => {
if (drupalUrl) {
config.serverURL = drupalUrl;
Drupal.configure(config);
}
});
});
}, [drupalUrl]);
};
1 change: 0 additions & 1 deletion apps/meteor/app/drupal/client/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,18 @@ export function messageContainsHighlight(message: Pick<IMessage, 'msg'>, highlig
return false;
}

const leftBoundary = '(?<=^|[^\\p{L}\\p{N}_])';
const rightBoundary = '(?=$|[^\\p{L}\\p{N}_])';

return highlights.some((highlight: string) => {
const hl = escapeRegExp(highlight);
const regexp = new RegExp(`(?<!:)\\b${hl}\\b:|:\\b${hl}(?!:)\\b|\\b(?<!:)${hl}(?!:)\\b`, 'i');
// Due to unnecessary escaping in escapeRegExp, we need to remove the escape character for the following characters: - = ! :
// This is necessary because it was crashing the client due to Invalid regular expression error.
const hl = escapeRegExp(highlight).replace(/\\([-=!:])/g, '$1');
const pattern =
`(?<!:)${leftBoundary}${hl}${rightBoundary}:` +
`|:${leftBoundary}${hl}${rightBoundary}(?!:)` +
`|${leftBoundary}(?<!:)${hl}(?!:)${rightBoundary}`;
const regexp = new RegExp(pattern, 'iu');
return regexp.test(message.msg);
});
}
Loading

0 comments on commit ae290e6

Please sign in to comment.