Skip to content

Commit

Permalink
Merge branch 'develop' into rewrite/marketplace-app-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoevanp authored Apr 24, 2024
2 parents fc251fb + 86ec6f7 commit 08352ff
Show file tree
Hide file tree
Showing 112 changed files with 1,574 additions and 202 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-starfishes-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes error `audio.pause() is not a function` and makes the continuous new room notification (livechat) respect the volume set in user preferences.
5 changes: 5 additions & 0 deletions .changeset/fifty-planets-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Deprecate muteUserInRoom and unmuteUserInRoom meteor methods
5 changes: 5 additions & 0 deletions .changeset/flat-socks-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed wrong `Business hours` validations between different weeks
6 changes: 6 additions & 0 deletions .changeset/lovely-trainers-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/rest-typings': minor
'@rocket.chat/meteor': minor
---

Convert mute/unmute meteor methods to endpoints
5 changes: 5 additions & 0 deletions .changeset/silent-dodos-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": minor
---

Added a new notification provider in light of the old FCM API deprecation, now you can choose to use the new provider or the old via the `Push_UseLegacy` setting
5 changes: 5 additions & 0 deletions .changeset/tame-ducks-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed a problem that caused `afterCreateUser` callback to be called without new user's roles inside. This caused Omnichannel Business Hour manager to ignore these users from assigning open business hours until the manager restarted or the business hour restarted.
2 changes: 1 addition & 1 deletion .github/workflows/ci-test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
mongodb-version: ${{ fromJSON(inputs.mongodb-version) }}
shard: ${{ fromJSON(inputs.shard) }}

name: MongoDB ${{ matrix.mongodb-version }} (${{ matrix.shard }}/${{ inputs.total-shard }})
name: MongoDB ${{ matrix.mongodb-version }} (${{ matrix.shard }}/${{ inputs.total-shard }})${{ matrix.mongodb-version == '6.0' && ' - Alpine' || '' }}

steps:
- name: Login to GitHub Container Registry
Expand Down
46 changes: 46 additions & 0 deletions apps/meteor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
# @rocket.chat/meteor

## 6.7.1

### Patch Changes

- Bump @rocket.chat/meteor version.

- Bump @rocket.chat/meteor version.

- ([#32253](https://github.com/RocketChat/Rocket.Chat/pull/32253)) Increased the timeout between calls for the three remaining Omnichannel Agenda Jobs. This should make them happen less often and reduce the load on MongoDB

- ([#32252](https://github.com/RocketChat/Rocket.Chat/pull/32252)) Fixes an issue that forces the focus on the last message when interacting by mouse on message list

- ([#32256](https://github.com/RocketChat/Rocket.Chat/pull/32256)) Fixed open expanded view (galery mode) for image attachments sent by livechat widget

- ([#32254](https://github.com/RocketChat/Rocket.Chat/pull/32254)) Fixed an issue where Rocket.Chat would ask admins to confirm fingerprint change (new workspace vs configuration update), even when `AUTO_ACCEPT_FINGERPRINT` environment variable set to `"true"`.

- ([#32265](https://github.com/RocketChat/Rocket.Chat/pull/32265)) Fixed supported versions not being updated in airgapped environments

- ([#32251](https://github.com/RocketChat/Rocket.Chat/pull/32251)) Fixes an issue where message reactions are vertically misaligned when zooming out

- <details><summary>Updated dependencies []:</summary>

- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
- @rocket.chat/[email protected]
</details>

## 6.7.0

### Minor Changes
Expand Down
41 changes: 40 additions & 1 deletion apps/meteor/app/api/server/v1/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { Media } from '@rocket.chat/core-services';
import type { IRoom, IUpload } from '@rocket.chat/core-typings';
import { Messages, Rooms, Users, Uploads } from '@rocket.chat/models';
import type { Notifications } from '@rocket.chat/rest-typings';
import { isGETRoomsNameExists, isRoomsImagesProps } from '@rocket.chat/rest-typings';
import { isGETRoomsNameExists, isRoomsImagesProps, isRoomsMuteUnmuteUserProps } from '@rocket.chat/rest-typings';
import { Meteor } from 'meteor/meteor';

import { isTruthy } from '../../../../lib/isTruthy';
import * as dataExport from '../../../../server/lib/dataExport';
import { eraseRoom } from '../../../../server/methods/eraseRoom';
import { muteUserInRoom } from '../../../../server/methods/muteUserInRoom';
import { unmuteUserInRoom } from '../../../../server/methods/unmuteUserInRoom';
import { canAccessRoomAsync, canAccessRoomIdAsync } from '../../../authorization/server/functions/canAccessRoom';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { saveRoomSettings } from '../../../channel-settings/server/methods/saveRoomSettings';
Expand All @@ -19,6 +21,7 @@ import { settings } from '../../../settings/server';
import { API } from '../api';
import { composeRoomWithLastMessage } from '../helpers/composeRoomWithLastMessage';
import { getPaginationItems } from '../helpers/getPaginationItems';
import { getUserFromParams } from '../helpers/getUserFromParams';
import { getUploadFormData } from '../lib/getUploadFormData';
import {
findAdminRoom,
Expand Down Expand Up @@ -678,3 +681,39 @@ API.v1.addRoute(
},
},
);

API.v1.addRoute(
'rooms.muteUser',
{ authRequired: true, validateParams: isRoomsMuteUnmuteUserProps },
{
async post() {
const user = await getUserFromParams(this.bodyParams);

if (!user.username) {
return API.v1.failure('Invalid user');
}

await muteUserInRoom(this.userId, { rid: this.bodyParams.roomId, username: user.username });

return API.v1.success();
},
},
);

API.v1.addRoute(
'rooms.unmuteUser',
{ authRequired: true, validateParams: isRoomsMuteUnmuteUserProps },
{
async post() {
const user = await getUserFromParams(this.bodyParams);

if (!user.username) {
return API.v1.failure('Invalid user');
}

await unmuteUserInRoom(this.userId, { rid: this.bodyParams.roomId, username: user.username });

return API.v1.success();
},
},
);
15 changes: 10 additions & 5 deletions apps/meteor/app/authentication/server/startup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,14 @@ Accounts.onCreateUser(function (...args) {

const { insertUserDoc } = Accounts;
const insertUserDocAsync = async function (options, user) {
const globalRoles = [];
const globalRoles = new Set();

if (Match.test(options.globalRoles, [String]) && options.globalRoles.length > 0) {
options.globalRoles.map((role) => globalRoles.add(role));
}

if (Match.test(user.globalRoles, [String]) && user.globalRoles.length > 0) {
globalRoles.push(...user.globalRoles);
user.globalRoles.map((role) => globalRoles.add(role));
}

delete user.globalRoles;
Expand All @@ -277,11 +281,12 @@ const insertUserDocAsync = async function (options, user) {
const defaultAuthServiceRoles = parseCSV(settings.get('Accounts_Registration_AuthenticationServices_Default_Roles') || '');

if (defaultAuthServiceRoles.length > 0) {
globalRoles.push(...defaultAuthServiceRoles);
defaultAuthServiceRoles.map((role) => globalRoles.add(role));
}
}

const roles = getNewUserRoles(globalRoles);
const arrayGlobalRoles = [...globalRoles];
const roles = options.skipNewUserRolesSetting ? arrayGlobalRoles : getNewUserRoles(arrayGlobalRoles);

if (!user.type) {
user.type = 'user';
Expand Down Expand Up @@ -326,7 +331,7 @@ const insertUserDocAsync = async function (options, user) {
await addUserRolesAsync(_id, roles);

// Make user's roles to be present on callback
user = await Users.findOneById(_id, { projection: { username: 1, type: 1 } });
user = await Users.findOneById(_id, { projection: { username: 1, type: 1, roles: 1 } });

if (user.username) {
if (options.joinDefaultChannels !== false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function getWorkspaceAccessTokenWithScope(scope = '', throwOnError
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
method: 'POST',
body,
timeout: 3000,
timeout: 5000,
});

payload = await response.json();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const getSupportedVersionsFromCloud = async () => {
const response = await handleResponse<SupportedVersions>(
fetch(releaseEndpoint, {
headers,
timeout: 3000,
timeout: 5000,
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const fetchWorkspaceClientPayload = async ({
Authorization: `Bearer ${token}`,
},
body: workspaceRegistrationData,
timeout: 3000,
timeout: 5000,
});

if (!response.ok) {
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/app/lib/server/functions/saveUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ const saveNewUser = async function (userData, sendPassword) {
password: userData.password,
joinDefaultChannels: userData.joinDefaultChannels,
isGuest,
globalRoles: roles,
skipNewUserRolesSetting: true,
};
if (userData.email) {
createUser.email = userData.email;
Expand All @@ -285,7 +287,6 @@ const saveNewUser = async function (userData, sendPassword) {

const updateUser = {
$set: {
roles,
...(typeof userData.name !== 'undefined' && { name: userData.name }),
settings: userData.settings || {},
},
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/app/livechat/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '../lib/messageTypes';
import './voip';
import './ui';
import './startup/notifyUnreadRooms';
import './stylesheets/livechat.css';
import './externalFrame';
37 changes: 0 additions & 37 deletions apps/meteor/app/livechat/client/startup/notifyUnreadRooms.js

This file was deleted.

24 changes: 2 additions & 22 deletions apps/meteor/app/livechat/server/business-hour/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,9 @@ import moment from 'moment';

import { businessHourLogger } from '../lib/logger';
import { createDefaultBusinessHourRow } from './LivechatBusinessHours';
import { filterBusinessHoursThatMustBeOpened } from './filterBusinessHoursThatMustBeOpened';

export const filterBusinessHoursThatMustBeOpened = async (
businessHours: ILivechatBusinessHour[],
): Promise<Pick<ILivechatBusinessHour, '_id' | 'type'>[]> => {
const currentTime = moment(moment().format('dddd:HH:mm:ss'), 'dddd:HH:mm:ss');

return businessHours
.filter(
(businessHour) =>
businessHour.active &&
businessHour.workHours
.filter((hour) => hour.open)
.some((hour) => {
const localTimeStart = moment(`${hour.start.cron.dayOfWeek}:${hour.start.cron.time}:00`, 'dddd:HH:mm:ss');
const localTimeFinish = moment(`${hour.finish.cron.dayOfWeek}:${hour.finish.cron.time}:00`, 'dddd:HH:mm:ss');
return currentTime.isSameOrAfter(localTimeStart) && currentTime.isBefore(localTimeFinish);
}),
)
.map((businessHour) => ({
_id: businessHour._id,
type: businessHour.type,
}));
};
export { filterBusinessHoursThatMustBeOpened };

export const filterBusinessHoursThatMustBeOpenedByDay = async (
businessHours: ILivechatBusinessHour[],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { LivechatBusinessHourTypes } from '@rocket.chat/core-typings';

import { filterBusinessHoursThatMustBeOpened } from './filterBusinessHoursThatMustBeOpened';

describe('different timezones between server and business hours', () => {
beforeEach(() => jest.useFakeTimers().setSystemTime(new Date('2024-04-20T20:10:11Z')));
afterEach(() => jest.useRealTimers());
it('should return a bh when the finish time resolves to a different day on server', async () => {
const bh = await filterBusinessHoursThatMustBeOpened([
{
_id: '65c40fa9052d6750ae25df83',
name: '',
active: true,
type: LivechatBusinessHourTypes.DEFAULT,
workHours: [
{
day: 'Sunday',
start: {
time: '00:00',
utc: {
dayOfWeek: 'Saturday',
time: '18:30',
},
cron: {
dayOfWeek: 'Saturday',
time: '15:30',
},
},
finish: {
time: '23:59',
utc: {
dayOfWeek: 'Sunday',
time: '18:29',
},
cron: {
dayOfWeek: 'Sunday',
time: '15:29',
},
},
open: true,
code: '',
},
],
timezone: {
name: 'Asia/Kolkata',
utc: '+05:30',
},
ts: new Date(),
},
]);

expect(bh.length).toEqual(1);
});
});
Loading

0 comments on commit 08352ff

Please sign in to comment.