Skip to content

Commit

Permalink
Merge branch 'develop' into feat/user-channel-uikit
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored May 24, 2024
2 parents c08d01e + 526cbf1 commit 719635a
Show file tree
Hide file tree
Showing 357 changed files with 1,500 additions and 669 deletions.
5 changes: 5 additions & 0 deletions .changeset/cold-beds-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes an issue not allowing override retention policy in channels
5 changes: 5 additions & 0 deletions .changeset/cuddly-owls-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed an issue that prevented CAS users from being merged with existing user data on login
6 changes: 6 additions & 0 deletions .changeset/ninety-rivers-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/rest-typings": minor
---

Fixed issue with "Export room as file" feature (`rooms.export` endpoint) generating an empty export when given an invalid date
6 changes: 6 additions & 0 deletions .changeset/real-bobcats-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/rest-typings': patch
'@rocket.chat/meteor': patch
---

Don't show Join default channels option on edit user form.
7 changes: 7 additions & 0 deletions .changeset/smooth-knives-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@rocket.chat/meteor": patch
---

Executing a logout and login action in the same "tab/instance", some streams were not being recreated, causing countless types of bugs.

PS: as a workaround reloading after logout or login in also solves the problem.
8 changes: 8 additions & 0 deletions .changeset/weak-turkeys-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@rocket.chat/meteor": patch
---

Fixed a bad behavior with the interaction between OTR system messages & trash collection. We use trash collection as a temporary storage that holds recently deleted items from some collections. Messages is one of those. This was causing "User joined OTR" messages to be viewable when querying the trash collection.
Since OTR messages are by definition private, code was updated to bypass trash collection when removing these special messages.

Note: this only applies to these system messages. OTR user's messages are not stored on the database.
5 changes: 5 additions & 0 deletions .changeset/wise-pianos-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed issue with external users being able to reset their passwords even when the "Allow Password Change for OAuth Users" setting is disabled
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ apps/meteor/server/startup/migrations @RocketChat/Architecture
/apps/meteor/ee/app/canned-responses @RocketChat/omnichannel
/apps/meteor/ee/app/livechat @RocketChat/omnichannel
/apps/meteor/ee/app/livechat-enterprise @RocketChat/omnichannel
/apps/meteor/ee/client/omnichannel @RocketChat/omnichannel
/apps/meteor/client/omnichannel @RocketChat/omnichannel
/apps/meteor/client/components/omnichannel @RocketChat/omnichannel
/apps/meteor/client/components/voip @RocketChat/omnichannel
2 changes: 1 addition & 1 deletion .github/workflows/pr-title-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: thehanimo/pr-title-checker@v1.3.7
- uses: thehanimo/pr-title-checker@v1.4.1
with:
GITHUB_TOKEN: ${{ secrets.RC_TITLE_CHECKER }}
1 change: 0 additions & 1 deletion apps/meteor/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
'../client/**/*.stories.{js,tsx}',
'../app/**/*.stories.{js,tsx}',
'../ee/app/**/*.stories.{js,tsx}',
'../ee/client/**/*.stories.{js,tsx}',
],
addons: [
'@storybook/addon-essentials',
Expand Down
20 changes: 4 additions & 16 deletions apps/meteor/app/api/server/v1/rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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, isRoomsMuteUnmuteUserProps } from '@rocket.chat/rest-typings';
import { isGETRoomsNameExists, isRoomsImagesProps, isRoomsMuteUnmuteUserProps, isRoomsExportProps } from '@rocket.chat/rest-typings';
import { Meteor } from 'meteor/meteor';

import { isTruthy } from '../../../../lib/isTruthy';
Expand Down Expand Up @@ -599,15 +599,11 @@ API.v1.addRoute(

API.v1.addRoute(
'rooms.export',
{ authRequired: true },
{ authRequired: true, validateParams: isRoomsExportProps },
{
async post() {
const { rid, type } = this.bodyParams;

if (!rid || !type || !['email', 'file'].includes(type)) {
throw new Meteor.Error('error-invalid-params');
}

if (!(await hasPermissionAsync(this.userId, 'mail-messages', rid))) {
throw new Meteor.Error('error-action-not-allowed', 'Mailing is not allowed');
}
Expand All @@ -627,12 +623,8 @@ API.v1.addRoute(
const { dateFrom, dateTo } = this.bodyParams;
const { format } = this.bodyParams;

if (!['html', 'json'].includes(format || '')) {
throw new Meteor.Error('error-invalid-format');
}

const convertedDateFrom = new Date(dateFrom || '');
const convertedDateTo = new Date(dateTo || '');
const convertedDateFrom = dateFrom ? new Date(dateFrom) : new Date(0);
const convertedDateTo = dateTo ? new Date(dateTo) : new Date();
convertedDateTo.setDate(convertedDateTo.getDate() + 1);

if (convertedDateFrom > convertedDateTo) {
Expand All @@ -658,10 +650,6 @@ API.v1.addRoute(
throw new Meteor.Error('error-invalid-recipient');
}

if (messages?.length === 0) {
throw new Meteor.Error('error-invalid-messages');
}

const result = await dataExport.sendViaEmail(
{
rid,
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/authorization/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { hasAllPermission, hasAtLeastOnePermission, hasPermission, userHasAllPermission } from './hasPermission';
import { hasRole, hasAnyRole } from './hasRole';
import './restrictedRoles';

export { hasAllPermission, hasAtLeastOnePermission, hasRole, hasAnyRole, hasPermission, userHasAllPermission };
12 changes: 12 additions & 0 deletions apps/meteor/app/authorization/client/restrictedRoles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Meteor } from 'meteor/meteor';

import { sdk } from '../../utils/client/lib/SDKClient';
import { AuthorizationUtils } from '../lib';

Meteor.startup(async () => {
const result = await sdk.call('license:isEnterprise');
if (result) {
// #ToDo: Load this from the server with an API call instead of having a duplicate list
AuthorizationUtils.addRolePermissionWhiteList('guest', ['view-d-room', 'view-joined-room', 'view-p-room', 'start-discussion']);
}
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { hasPermission } from '../../../../../app/authorization/client';
import { settings } from '../../../../../app/settings/client';
import { sdk } from '../../../../../app/utils/client/lib/SDKClient';
import { hasPermission } from '../../../authorization/client';
import { settings } from '../../../settings/client';
import { sdk } from '../../../utils/client/lib/SDKClient';
import { CannedResponse } from '../collections/CannedResponse';

const events = {
Expand Down
62 changes: 21 additions & 41 deletions apps/meteor/app/channel-settings/server/methods/saveRoomSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,74 +117,54 @@ const validators: RoomSettingsValidators = {
}
},
async retentionEnabled({ userId, value, room, rid }) {
if (!hasRetentionPolicy(room)) {
throw new Meteor.Error('error-action-not-allowed', 'Room does not have retention policy', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}

if (!(await hasPermissionAsync(userId, 'edit-room-retention-policy', rid)) && value !== room.retention.enabled) {
if (
!(await hasPermissionAsync(userId, 'edit-room-retention-policy', rid)) &&
(!hasRetentionPolicy(room) || value !== room.retention.enabled)
) {
throw new Meteor.Error('error-action-not-allowed', 'Editing room retention policy is not allowed', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}
},
async retentionMaxAge({ userId, value, room, rid }) {
if (!hasRetentionPolicy(room)) {
throw new Meteor.Error('error-action-not-allowed', 'Room does not have retention policy', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}

if (!(await hasPermissionAsync(userId, 'edit-room-retention-policy', rid)) && value !== room.retention.maxAge) {
if (
!(await hasPermissionAsync(userId, 'edit-room-retention-policy', rid)) &&
(!hasRetentionPolicy(room) || value !== room.retention.maxAge)
) {
throw new Meteor.Error('error-action-not-allowed', 'Editing room retention policy is not allowed', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}
},
async retentionExcludePinned({ userId, value, room, rid }) {
if (!hasRetentionPolicy(room)) {
throw new Meteor.Error('error-action-not-allowed', 'Room does not have retention policy', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}

if (!(await hasPermissionAsync(userId, 'edit-room-retention-policy', rid)) && value !== room.retention.excludePinned) {
if (
!(await hasPermissionAsync(userId, 'edit-room-retention-policy', rid)) &&
(!hasRetentionPolicy(room) || value !== room.retention.excludePinned)
) {
throw new Meteor.Error('error-action-not-allowed', 'Editing room retention policy is not allowed', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}
},
async retentionFilesOnly({ userId, value, room, rid }) {
if (!hasRetentionPolicy(room)) {
throw new Meteor.Error('error-action-not-allowed', 'Room does not have retention policy', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}

if (!(await hasPermissionAsync(userId, 'edit-room-retention-policy', rid)) && value !== room.retention.filesOnly) {
if (
!(await hasPermissionAsync(userId, 'edit-room-retention-policy', rid)) &&
(!hasRetentionPolicy(room) || value !== room.retention.filesOnly)
) {
throw new Meteor.Error('error-action-not-allowed', 'Editing room retention policy is not allowed', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}
},
async retentionIgnoreThreads({ userId, value, room, rid }) {
if (!hasRetentionPolicy(room)) {
throw new Meteor.Error('error-action-not-allowed', 'Room does not have retention policy', {
method: 'saveRoomSettings',
action: 'Editing_room',
});
}

if (!(await hasPermissionAsync(userId, 'edit-room-retention-policy', rid)) && value !== room.retention.ignoreThreads) {
if (
!(await hasPermissionAsync(userId, 'edit-room-retention-policy', rid)) &&
(!hasRetentionPolicy(room) || value !== room.retention.ignoreThreads)
) {
throw new Meteor.Error('error-action-not-allowed', 'Editing room retention policy is not allowed', {
method: 'saveRoomSettings',
action: 'Editing_room',
Expand Down Expand Up @@ -469,7 +449,7 @@ export async function saveRoomSettings(
rid,
});

if (setting === 'retentionOverrideGlobal') {
if (setting === 'retentionOverrideGlobal' && settings.retentionOverrideGlobal === false) {
delete settings.retentionMaxAge;
delete settings.retentionExcludePinned;
delete settings.retentionFilesOnly;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { queryClient } from '../../../../client/lib/queryClient';
import { fetchFeatures } from '../../../client/lib/fetchFeatures';
import { queryClient } from '../../../client/lib/queryClient';

export async function hasLicense(feature: string): Promise<boolean> {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { hasLicense } from '../../license/client';
import '../lib/messageTypes';
import './startup';

void hasLicense('livechat-enterprise').then((enabled) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import type { IMessage } from '@rocket.chat/core-typings';

import { MessageTypes } from '../../../../app/ui-utils/client';
import { t } from '../../../../app/utils/lib/i18n';
import { MessageTypes } from '../../ui-utils/client';
import { t } from '../../utils/lib/i18n';

MessageTypes.registerType({
id: 'livechat_transfer_history_fallback',
system: true,
message: 'New_chat_transfer_fallback',
data(message: any) {
if (!message.transferData) {
return {
fallback: 'SHOULD_NEVER_HAPPEN',
};
}
const from = message.transferData.prevDepartment;
const to = message.transferData.department.name;

return {
fallback: t('Livechat_transfer_failed_fallback', { from, to }),
};
},
});

MessageTypes.registerType({
id: 'omnichannel_priority_change_history',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Meteor } from 'meteor/meteor';

import { businessHourManager } from '../../../../app/livechat/client/views/app/business-hours/BusinessHours';
import type { IBusinessHourBehavior } from '../../../../app/livechat/client/views/app/business-hours/IBusinessHourBehavior';
import { SingleBusinessHourBehavior } from '../../../../app/livechat/client/views/app/business-hours/Single';
import { settings } from '../../../../app/settings/client';
import { hasLicense } from '../../license/client';
import { businessHourManager } from '../../livechat/client/views/app/business-hours/BusinessHours';
import type { IBusinessHourBehavior } from '../../livechat/client/views/app/business-hours/IBusinessHourBehavior';
import { SingleBusinessHourBehavior } from '../../livechat/client/views/app/business-hours/Single';
import { settings } from '../../settings/client';
import { MultipleBusinessHoursBehavior } from './views/business-hours/Multiple';

const businessHours: Record<string, IBusinessHourBehavior> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ILivechatBusinessHour } from '@rocket.chat/core-typings';
import { LivechatBusinessHourTypes } from '@rocket.chat/core-typings';

import type { IBusinessHourBehavior } from '../../../../../../app/livechat/client/views/app/business-hours/IBusinessHourBehavior';
import type { IBusinessHourBehavior } from '../../../../livechat/client/views/app/business-hours/IBusinessHourBehavior';

export class MultipleBusinessHoursBehavior implements IBusinessHourBehavior {
getView(): string {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hasPermission, hasAtLeastOnePermission } from '../../../../../app/authorization/client';
import { registerOmnichannelSidebarItem } from '../../../../../client/views/omnichannel/sidebarItems';
import { registerOmnichannelSidebarItem } from '../../../../client/views/omnichannel/sidebarItems';
import { hasPermission, hasAtLeastOnePermission } from '../../../authorization/client';

registerOmnichannelSidebarItem({
href: '/omnichannel/reports',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,6 @@ export class CachedCollection<T extends { _id: string }, U = T> extends Emitter<
this.trySync();
});

if (!this.userRelated) {
return this.setupListener();
}

CachedCollectionManager.onLogin(async () => {
await this.setupListener();
});
return this.setupListener();
}
}
10 changes: 9 additions & 1 deletion apps/meteor/app/utils/client/lib/SDKClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type EventMap<N extends StreamNames = StreamNames, K extends StreamKeys<N> = Str

type StreamMapValue = {
stop: () => void;
error: (cb: (...args: any[]) => void) => void;
onChange: ReturnType<ClientStream['subscribe']>['onChange'];
ready: () => Promise<void>;
isReady: boolean;
Expand All @@ -62,6 +63,7 @@ const createNewMeteorStream = (streamName: StreamNames, key: StreamKeys<StreamNa
const meta = {
ready: false,
};

const sub = Meteor.connection.subscribe(
`stream-${streamName}`,
key,
Expand All @@ -72,8 +74,8 @@ const createNewMeteorStream = (streamName: StreamNames, key: StreamKeys<StreamNa
ee.emit('ready', [undefined, args]);
},
onError: (err: any) => {
console.error(err);
ee.emit('ready', [err]);
ee.emit('error', err);
},
},
);
Expand Down Expand Up @@ -115,6 +117,11 @@ const createNewMeteorStream = (streamName: StreamNames, key: StreamKeys<StreamNa
stop: sub.stop,
onChange,
ready,
error: (cb: (...args: any[]) => void) =>
ee.once('error', (error) => {
cb(error);
}),

get isReady() {
return meta.ready;
},
Expand Down Expand Up @@ -179,6 +186,7 @@ const createStreamManager = () => {
if (!streams.has(eventLiteral)) {
streams.set(eventLiteral, stream);
}
stream.error(() => stop());

return {
id: '',
Expand Down
Loading

0 comments on commit 719635a

Please sign in to comment.