Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
e4218c2
Bump version to 5.2.0-develop
Sep 2, 2022
33b3134
Merge pull request #26792 from RocketChat/develop-sync
sampaiodiego Sep 2, 2022
50b252b
Chore: Add E2E tests to missing omnichannel endpoints (#26730)
KevLehman Sep 2, 2022
839e386
i18n: Language update from LingoHub 🤖 on 2022-08-29Z (#26722)
lingohub[bot] Sep 2, 2022
bf91571
[FIX] Typo on new homepage (#26768)
Sep 3, 2022
8ebefd8
Chore: Test/improve reliability (#26724)
Sep 5, 2022
9a5604b
Chore: Add tests to cover issue fixed in #26720 (#26767)
murtaza98 Sep 5, 2022
78dbb69
Chore: Refactor message list context usage (#26748)
ggazzo Sep 5, 2022
9513629
[FIX] Livechat trigger messages covering all the website (#26776)
tiagoevanp Sep 5, 2022
d44b74e
[FIX] Restore current chats default table order (#26808)
MartinSchoeler Sep 5, 2022
94cc007
[FIX] Fix broken legacy message view (#26819)
hugocostadev Sep 6, 2022
5240f16
i18n: Language update from LingoHub 🤖 on 2022-09-05Z (#26805)
lingohub[bot] Sep 6, 2022
01c8786
[FIX] Menu options margin spacing (#26775)
guijun13 Sep 6, 2022
02d5f70
[IMPROVE] System messages' consistency (#26130)
matheusbsilva137 Sep 6, 2022
7acbb2a
[IMPROVE] OTR Message (#24297)
albuquerquefabio Sep 6, 2022
f8b62b1
[IMPROVE] Allow delete attachment description on message edit (#26673)
yash-rajpal Sep 6, 2022
d30e08e
[FIX] Sign in with Apple on mobile (#26827)
sampaiodiego Sep 8, 2022
343c5f1
Chore: add aria hidden if modal is open (#26826)
ggazzo Sep 8, 2022
19be3b1
Chore: Cleanup endpoint handlers (#26749)
KevLehman Sep 9, 2022
5fdf20b
Chore: first non-aggressive CSS removal (#26714)
ggazzo Sep 9, 2022
5f7d966
[NEW] Sections layout and featured apps for marketplace (#26514)
rique223 Sep 9, 2022
3b35f8b
Chore: `refactor/room` (#26675)
tassoevan Sep 9, 2022
7d35b72
Chore: Configure Prettier for `@rocket.chat/livechat` (#26846)
tiagoevanp Sep 10, 2022
f8294ef
Chore: Deprecate some omnichannel meteor methods which aren't getting…
murtaza98 Sep 12, 2022
5474569
[IMPROVE] Include `syncAvatars` on `ldap.syncNow` (#26824)
LucianoPierdona Sep 12, 2022
29a6276
[IMPROVE] Rounded video attachment (#26832)
yash-rajpal Sep 12, 2022
ddd1e87
i18n: Language update from LingoHub 🤖 on 2022-09-12Z (#26849)
lingohub[bot] Sep 12, 2022
3c2679b
[FIX] Check if messsage.replies exist on new message template (#26652)
Sep 13, 2022
fa9d85d
Chore: Add RocketChatDesktop function to open video calls when using …
jeanfbrito Sep 13, 2022
f7438d3
Chore: Rewrite apps WarningModal component to typescript (#26845)
rique223 Sep 13, 2022
ddd52cb
[FIX] Importer fails when file includes user without an email. (#26836)
pierre-lehnen-rc Sep 13, 2022
2bb9f22
Chore: Update fuselage to next version. (#26841)
gabriellsh Sep 14, 2022
bb37564
Chore: fix wrong `test.step` usage (#26873)
ggazzo Sep 14, 2022
e83f80e
Chore: Upgrading livechat's ui-kit package to latest version (#26709)
aleksandernsilva Sep 14, 2022
0d54185
[FIX] Expanded thread behind sidebar on small screens (#26852)
hugocostadev Sep 14, 2022
f4b5681
Chore: Bump fuselage dependencies and implement new tabs variant in m…
rique223 Sep 15, 2022
effda0e
[FIX] Unable to send native video recording to Whatsapp (#26669)
murtaza98 Sep 15, 2022
18b7b4b
[FIX] Incorrect filter on contact history search (#26813)
neo-clon Sep 15, 2022
5bfcc21
[FIX] Asset settings description not showing on admin (#26755)
Sep 15, 2022
c604e4b
Chore: Move Header to ui-client (#26757)
dougfabris Sep 15, 2022
8dc8817
[IMPROVE] Changed dial pad appearance to match original design (#26863)
aleksandernsilva Sep 15, 2022
6d3b20d
Chore: Move presence to package (#25541)
sampaiodiego Sep 15, 2022
34c07d2
Chore: Move Omnichannel Room Footer to react (#26864)
ggazzo Sep 15, 2022
2857441
[FIX] Check admin setting for whether to display roles or not (#26601)
debdutdeb Sep 16, 2022
40dd7bb
Chore: Fix API tests retry (#26860)
sampaiodiego Sep 16, 2022
f9676c6
Chore: merge all functions using autorun x useSubscription pattern (#…
ggazzo Sep 16, 2022
1e1b47e
Chore: Change BundleChips component appearance (#26686)
rique223 Sep 16, 2022
7905852
[IMPROVE] Updating voip tooltips and icons (#26834)
aleksandernsilva Sep 19, 2022
52437f8
[FIX] Upload fails when using WebDav as file storage (#26711)
pierre-lehnen-rc Sep 19, 2022
3023022
i18n: Language update from LingoHub 🤖 on 2022-09-19Z (#26896)
lingohub[bot] Sep 20, 2022
bde451e
Merge branch 'master' into develop
sampaiodiego Sep 21, 2022
aef67a2
[IMPROVE] Better descriptions for VoIP Settings (#26877)
MartinSchoeler Sep 21, 2022
5c26dd9
[NEW] Get moderators, owners and leaders from room scope via apps-eng…
debdutdeb Sep 21, 2022
414d3e3
[IMPROVE] Setting for login email notifications (#26831)
yash-rajpal Sep 21, 2022
6ae770b
[FIX] Error when mentioning a non-member of a public channel (#26917)
debdutdeb Sep 21, 2022
3e4b616
[FIX] [Livechat] Unread messages badge (#26843)
tiagoevanp Sep 22, 2022
21405eb
[FIX] MIME Type fallback for .mov File Extensions (#26921)
hugocostadev Sep 22, 2022
378ab34
[NEW] Add Markup to QuoteAttachment (#26751)
hugocostadev Sep 22, 2022
9090349
Chore: Omnichannel endpoints to ts (#26829)
KevLehman Sep 22, 2022
5ed3271
[IMPROVE] VideoConference Messages UI (#26548)
dougfabris Sep 22, 2022
1844151
[FIX] Old rooms without the associated unit will not be displayed on …
murtaza98 Sep 22, 2022
55e11c4
[FIX] Ephemeral messages not respecting katex setting (#26812)
gabriellsh Sep 22, 2022
548d8e6
[FIX] Message sequential after message thread preview (#26900)
Sep 22, 2022
9625a99
Chore: fix regressions for omnichannel due room refactor (#26912)
ggazzo Sep 23, 2022
4ab9c35
Chore: Move micro services to packages (#26884)
sampaiodiego Sep 23, 2022
0fc1828
Chore: Refactor omnichannel livechat tests (#26929)
ggazzo Sep 23, 2022
e1a4fb4
Bump actions/cache from 2 to 3.0.1 (#25003)
dependabot[bot] Sep 23, 2022
cfd738a
Regression: wrong permission on livechat/tags endpoints (#26928)
KevLehman Sep 23, 2022
d8e883b
Chore: Introduce `useQuery` as data source for the `Room` component (…
tassoevan Sep 23, 2022
0beec2f
Chore: Convert current-chats to useQuery (#26931)
ggazzo Sep 23, 2022
7407f62
Chore: Updating apps engine (#26924)
AllanPazRibeiro Sep 23, 2022
426c7ed
Regression: Fix open room from current chats (#26930)
ggazzo Sep 23, 2022
5d3a3d2
[FIX] `MongoInvalidArgumentError` on overwriting existing setting (#2…
debdutdeb Sep 23, 2022
71a4cb7
[NEW] Move administration links to an exclusive kebab menu (#26867)
Sep 23, 2022
ab3ed80
[NEW] Matrix Federation events coverage expansion (support for 5 more…
Sep 23, 2022
8ba1cb8
Chore: Bump vm2 to 3.9.11 (#26940)
ggazzo Sep 23, 2022
d142e13
Bump version to 5.2.0-rc.0
tassoevan Sep 24, 2022
ca43434
i18n: Language update from LingoHub 🤖 on 2022-09-26Z (#26948)
lingohub[bot] Sep 26, 2022
aefa44b
Chore: Missing Also_send_thread_message_to_channel setting translatio…
yash-rajpal Sep 26, 2022
6287004
Chore: Tests for EE features (#26939)
KevLehman Sep 26, 2022
74cd22b
Regression: Sidebar Room List not working properly. (#26950)
gabriellsh Sep 27, 2022
3a2b6da
[FIX] Adjusted livechat fallbacks to take null values into account (#…
aleksandernsilva Sep 27, 2022
1570665
Merge remote-tracking branch 'origin/develop' into release-candidate
tassoevan Sep 28, 2022
73bbe44
Bump version to 5.2.0-rc.1
tassoevan Sep 28, 2022
a2595bb
[FIX] Admin sidebar navigation (#26958)
juliajforesti Sep 28, 2022
e15b467
Revert "[IMPROVE] VideoConference Messages UI (#26548)" (#26961)
pierre-lehnen-rc Sep 29, 2022
4ecf45b
Regression: Typo on livechat/queue endpoint client call (#26962)
KevLehman Sep 29, 2022
4f27e21
Regression: Remove symbols from number before storing PBX event (#26969)
KevLehman Sep 29, 2022
d70fda2
Regression: Event handler blocking mention links (#26964)
tassoevan Sep 29, 2022
96290c9
Regression: Incorrect on-hold chat resume message (#26935)
murtaza98 Sep 30, 2022
0e6bc45
[IMPROVE] Results of user auto complete (#26687)
pierre-lehnen-rc Sep 30, 2022
26941d5
Regression: Composer not reactive when omnichannel room closed (#26983)
MartinSchoeler Oct 3, 2022
aa249a6
Regression: Handle `undefined` values on `useReactiveQuery`'s query f…
tassoevan Oct 4, 2022
67d5339
Regression: Fixed takeInquiry method not displaying error messages on…
aleksandernsilva Oct 4, 2022
0c1ab59
[IMPROVE] Use cached EE Cloud license on startup (#26987)
sampaiodiego Oct 4, 2022
3c96bc7
Regression: Omnichannel Contact Center empty on no filter search (#26…
tiagoevanp Oct 4, 2022
175d6a1
Regression: Remove section and replace icon on administration kebab m…
Oct 4, 2022
47fb22c
Merge remote-tracking branch 'origin/develop' into release-candidate
tassoevan Oct 4, 2022
562f09a
Bump version to 5.2.0-rc.2
tassoevan Oct 4, 2022
f44b2a3
Chore: `improve/media-recorder` (#26426)
tassoevan Oct 4, 2022
3715e0d
Regression: Use raw models instead of meteor ones on visitor inactivi…
KevLehman Oct 4, 2022
2b84e80
Merge remote-tracking branch 'origin/develop' into release-candidate
tassoevan Oct 4, 2022
1f9ab1a
Bump version to 5.2.0-rc.3
tassoevan Oct 4, 2022
4afcbf6
Chore: break LDAP manager into smaller pieces to improve unit tests (…
ggazzo Oct 5, 2022
c97f5e1
Merge remote-tracking branch 'origin/develop' into release-candidate
tassoevan Oct 5, 2022
c931d9e
Bump version to 5.2.0-rc.4
tassoevan Oct 5, 2022
fc71f80
Regression: Cannot edit messages in some environments. (#27023)
gabriellsh Oct 7, 2022
113d0b4
Regression: Double Table Cell Causing extra padding on Current Chats …
MartinSchoeler Oct 7, 2022
404cfff
Regression: VideoConf Actions Reactivity in SidebarItem (#27009)
dougfabris Oct 7, 2022
0679ff9
Merge remote-tracking branch 'origin/develop' into release-candidate
tassoevan Oct 10, 2022
d6dd22a
Bump version to 5.2.0-rc.5
tassoevan Oct 10, 2022
ff732f9
Chore: Bump fuselage to latest (#27042)
gabriellsh Oct 10, 2022
c678d38
Merge remote-tracking branch 'origin/develop' into release-candidate
tassoevan Oct 10, 2022
e5de91a
Bump version to 5.2.0-rc.6
tassoevan Oct 10, 2022
53acec8
Chore: Bump Apps-Engine version (#27059)
d-gubert Oct 13, 2022
648c859
Merge remote-tracking branch 'origin/release-candidate' into release-…
tassoevan Oct 13, 2022
952ee99
Bump version to 5.2.0
tassoevan Oct 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1,295 changes: 1,273 additions & 22 deletions .github/history.json

Large diffs are not rendered by default.

245 changes: 148 additions & 97 deletions .github/workflows/build_and_test.yml

Large diffs are not rendered by default.

417 changes: 414 additions & 3 deletions HISTORY.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/meteor/.docker/Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM registry.access.redhat.com/ubi8/nodejs-12

ENV RC_VERSION 5.1.4
ENV RC_VERSION 5.2.0

MAINTAINER buildmaster@rocket.chat

Expand Down
1 change: 1 addition & 0 deletions apps/meteor/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
...base, // see https://github.com/mochajs/mocha/issues/3916
exit: true,
spec: [
'ee/server/lib/ldap/*.spec.ts',
'ee/tests/**/*.tests.ts',
'ee/tests/**/*.spec.ts',
'tests/unit/app/**/*.spec.ts',
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/api/server/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ type ActionThis<TMethod extends Method, TPathPattern extends PathPattern, TOptio
me: IUser,
): TOptions extends { authRequired: true } ? UserInfo : TOptions extends { authOrAnonRequired: true } ? UserInfo | undefined : undefined;
composeRoomWithLastMessage(room: IRoom, userId: string): IRoom;
isWidget(): boolean;
} & (TOptions extends { authRequired: true }
? {
readonly user: IUser;
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/helpers/requestParams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { API } from '../api';

API.helperMethods.set('requestParams', function _requestParams(this: any) {
return ['POST', 'PUT'].includes(this.request.method) ? this.bodyParams : this.queryParams;
return ['POST', 'PUT', 'DELETE'].includes(this.request.method) ? this.bodyParams : this.queryParams;
});
21 changes: 2 additions & 19 deletions apps/meteor/app/api/server/lib/emailInbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ import type { IEmailInbox } from '@rocket.chat/core-typings';
import type { Filter, InsertOneResult, Sort, UpdateResult, WithId } from 'mongodb';
import { EmailInbox } from '@rocket.chat/models';

import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { Users } from '../../../models/server';

export const findEmailInboxes = async ({
userId,
query = {},
pagination: { offset, count, sort },
}: {
userId: string;
query?: Filter<IEmailInbox>;
pagination: {
offset: number;
Expand All @@ -23,9 +20,6 @@ export const findEmailInboxes = async ({
count: number;
offset: number;
}> => {
if (!(await hasPermissionAsync(userId, 'manage-email-inbox'))) {
throw new Error('error-not-allowed');
}
const { cursor, totalCount } = EmailInbox.findPaginated(query, {
sort: sort || { name: 1 },
skip: offset,
Expand All @@ -42,10 +36,7 @@ export const findEmailInboxes = async ({
};
};

export const findOneEmailInbox = async ({ userId, _id }: { userId: string; _id: string }): Promise<IEmailInbox | null> => {
if (!(await hasPermissionAsync(userId, 'manage-email-inbox'))) {
throw new Error('error-not-allowed');
}
export const findOneEmailInbox = async ({ _id }: { _id: string }): Promise<IEmailInbox | null> => {
return EmailInbox.findOneById(_id);
};
export const insertOneEmailInbox = async (
Expand All @@ -62,12 +53,11 @@ export const insertOneEmailInbox = async (
};

export const updateEmailInbox = async (
userId: string,
emailInboxParams: Pick<IEmailInbox, '_id' | 'active' | 'name' | 'email' | 'description' | 'senderInfo' | 'department' | 'smtp' | 'imap'>,
): Promise<InsertOneResult<WithId<IEmailInbox>> | UpdateResult> => {
const { _id, active, name, email, description, senderInfo, department, smtp, imap } = emailInboxParams;

const emailInbox = await findOneEmailInbox({ userId, _id });
const emailInbox = await findOneEmailInbox({ _id });

if (!emailInbox) {
throw new Error('error-invalid-email-inbox');
Expand All @@ -90,10 +80,3 @@ export const updateEmailInbox = async (

return EmailInbox.updateOne({ _id }, updateEmailInbox);
};

export const findOneEmailInboxByEmail = async ({ userId, email }: { userId: string; email: string }): Promise<IEmailInbox | null> => {
if (!(await hasPermissionAsync(userId, 'manage-email-inbox'))) {
throw new Error('error-not-allowed');
}
return EmailInbox.findOne({ email });
};
30 changes: 20 additions & 10 deletions apps/meteor/app/api/server/lib/users.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import { escapeRegExp } from '@rocket.chat/string-helpers';
import type { IUser } from '@rocket.chat/core-typings';
import type { Filter } from 'mongodb';
import { Users } from '@rocket.chat/models';
import { Users, Subscriptions } from '@rocket.chat/models';
import type { Mongo } from 'meteor/mongo';

import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { settings } from '../../../settings/server';

type UserAutoComplete = Required<Pick<IUser, '_id' | 'name' | 'username' | 'nickname' | 'status' | 'avatarETag'>>;

export async function findUsersToAutocomplete({
uid,
selector,
}: {
uid: string;
selector: {
exceptions: string[];
conditions: Filter<IUser>;
term: string;
};
selector: { exceptions: Required<IUser>['username'][]; conditions: Filter<IUser>; term: string };
}): Promise<{
items: UserAutoComplete[];
}> {
if (!(await hasPermissionAsync(uid, 'view-outside-room'))) {
return { items: [] };
}
const searchFields = settings.get<string>('Accounts_SearchFields').trim().split(',');
const exceptions = selector.exceptions || [];
const conditions = selector.conditions || {};
const options = {
Expand All @@ -39,6 +35,20 @@ export async function findUsersToAutocomplete({
limit: 10,
};

// Search on DMs first, to list known users before others.
const contacts = await Subscriptions.findConnectedUsersExcept(uid, selector.term, exceptions, searchFields, conditions, 10, 'd');
if (contacts.length >= options.limit) {
return { items: contacts as UserAutoComplete[] };
}

options.limit -= contacts.length;
contacts.forEach(({ username }) => exceptions.push(username));

if (!(await hasPermissionAsync(uid, 'view-outside-room'))) {
const users = await Subscriptions.findConnectedUsersExcept(uid, selector.term, exceptions, searchFields, conditions, 10);
return { items: contacts.concat(users) as UserAutoComplete[] };
}

const users = await Users.findActiveByUsernameOrNameRegexWithExceptionsAndConditions<UserAutoComplete>(
new RegExp(escapeRegExp(selector.term), 'i'),
exceptions,
Expand All @@ -47,7 +57,7 @@ export async function findUsersToAutocomplete({
).toArray();

return {
items: users,
items: (contacts as UserAutoComplete[]).concat(users),
};
}

Expand Down
34 changes: 9 additions & 25 deletions apps/meteor/app/api/server/v1/email-inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import { EmailInbox } from '@rocket.chat/models';

import { API } from '../api';
import { insertOneEmailInbox, findEmailInboxes, findOneEmailInbox, updateEmailInbox } from '../lib/emailInbox';
import { hasPermission } from '../../../authorization/server/functions/hasPermission';
import Users from '../../../models/server/models/Users';
import { sendTestEmailToInbox } from '../../../../server/features/EmailInbox/EmailInbox_Outgoing';

API.v1.addRoute(
'email-inbox.list',
{ authRequired: true },
{ authRequired: true, permissionsRequired: ['manage-email-inbox'] },
{
async get() {
const { offset, count } = this.getPaginationItems();
const { sort, query } = this.parseJsonQuery();
const emailInboxes = await findEmailInboxes({ userId: this.userId, query, pagination: { offset, count, sort } });
const emailInboxes = await findEmailInboxes({ query, pagination: { offset, count, sort } });

return API.v1.success(emailInboxes);
},
Expand All @@ -23,13 +22,9 @@ API.v1.addRoute(

API.v1.addRoute(
'email-inbox',
{ authRequired: true },
{ authRequired: true, permissionsRequired: ['manage-email-inbox'] },
{
async post() {
if (!hasPermission(this.userId, 'manage-email-inbox')) {
throw new Error('error-not-allowed');
}

check(this.bodyParams, {
_id: Match.Maybe(String),
active: Boolean,
Expand Down Expand Up @@ -64,7 +59,7 @@ API.v1.addRoute(
_id = emailInbox.insertedId.toString();
} else {
_id = emailInboxParams._id;
await updateEmailInbox(this.userId, { ...emailInboxParams, _id });
await updateEmailInbox({ ...emailInboxParams, _id });
}
return API.v1.success({ _id });
},
Expand All @@ -73,7 +68,7 @@ API.v1.addRoute(

API.v1.addRoute(
'email-inbox/:_id',
{ authRequired: true },
{ authRequired: true, permissionsRequired: ['manage-email-inbox'] },
{
async get() {
check(this.urlParams, {
Expand All @@ -84,15 +79,11 @@ API.v1.addRoute(
if (!_id) {
throw new Error('error-invalid-param');
}
// TODO: Chapter day backend - check if user has permission to view this email inbox instead of null values
const emailInboxes = await findOneEmailInbox({ userId: this.userId, _id });
const emailInboxes = await findOneEmailInbox({ _id });

return API.v1.success(emailInboxes);
},
async delete() {
if (!hasPermission(this.userId, 'manage-email-inbox')) {
throw new Error('error-not-allowed');
}
check(this.urlParams, {
_id: String,
});
Expand All @@ -103,7 +94,6 @@ API.v1.addRoute(
}

const emailInboxes = await EmailInbox.findOneById(_id);

if (!emailInboxes) {
return API.v1.notFound();
}
Expand All @@ -115,12 +105,9 @@ API.v1.addRoute(

API.v1.addRoute(
'email-inbox.search',
{ authRequired: true },
{ authRequired: true, permissionsRequired: ['manage-email-inbox'] },
{
async get() {
if (!hasPermission(this.userId, 'manage-email-inbox')) {
throw new Error('error-not-allowed');
}
check(this.queryParams, {
email: String,
});
Expand All @@ -138,12 +125,9 @@ API.v1.addRoute(

API.v1.addRoute(
'email-inbox.send-test/:_id',
{ authRequired: true },
{ authRequired: true, permissionsRequired: ['manage-email-inbox'] },
{
async post() {
if (!hasPermission(this.userId, 'manage-email-inbox')) {
throw new Error('error-not-allowed');
}
check(this.urlParams, {
_id: String,
});
Expand All @@ -152,7 +136,7 @@ API.v1.addRoute(
if (!_id) {
throw new Error('error-invalid-param');
}
const emailInbox = await findOneEmailInbox({ userId: this.userId, _id });
const emailInbox = await findOneEmailInbox({ _id });

if (!emailInbox) {
return API.v1.notFound();
Expand Down
24 changes: 20 additions & 4 deletions apps/meteor/app/api/server/v1/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Match, check } from 'meteor/check';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import type { IExportOperation, IPersonalAccessToken, IUser } from '@rocket.chat/core-typings';
import { Users as UsersRaw } from '@rocket.chat/models';
import type { Filter } from 'mongodb';

import { Users, Subscriptions } from '../../../models/server';
import { hasPermission } from '../../../authorization/server';
Expand All @@ -39,9 +40,9 @@ import { resetUserE2EEncriptionKey } from '../../../../server/lib/resetUserE2EKe
import { resetTOTP } from '../../../2fa/server/functions/resetTOTP';
import { Team } from '../../../../server/sdk';
import { isValidQuery } from '../lib/isValidQuery';
import { setUserStatus } from '../../../../imports/users-presence/server/activeUsers';
import { getURL } from '../../../utils/server';
import { getUploadFormData } from '../lib/getUploadFormData';
import { api } from '../../../../server/sdk/api';

API.v1.addRoute(
'users.getAvatar',
Expand Down Expand Up @@ -815,11 +816,22 @@ API.v1.addRoute(
{ authRequired: true, validateParams: isUsersAutocompleteProps },
{
async get() {
const { selector } = this.queryParams;
const { selector: selectorRaw } = this.queryParams;

const selector: { exceptions: Required<IUser>['username'][]; conditions: Filter<IUser>; term: string } = JSON.parse(selectorRaw);

try {
if (selector?.conditions && !isValidQuery(selector.conditions, ['*'], ['$or', '$and'])) {
throw new Error('error-invalid-query');
}
} catch (e) {
return API.v1.failure(e);
}

return API.v1.success(
await findUsersToAutocomplete({
uid: this.userId,
selector: JSON.parse(selector),
selector,
}),
);
},
Expand Down Expand Up @@ -1031,7 +1043,11 @@ API.v1.addRoute(
},
});

setUserStatus(user, status);
const { _id, username, statusText, roles, name } = user;
api.broadcast('presence.status', {
user: { status, _id, username, statusText, roles, name },
previousStatus: user.status,
});
} else {
throw new Meteor.Error('error-invalid-status', 'Valid status types include online, away, offline, and busy.', {
method: 'users.setStatus',
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/v1/voip/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { canAccessRoom } from '../../../../authorization/server';

API.v1.addRoute(
'voip/events',
{ authRequired: true },
{ authRequired: true, permissionsRequired: ['view-l-room'] },
{
async post() {
check(this.requestParams(), {
Expand Down
20 changes: 8 additions & 12 deletions apps/meteor/app/api/server/v1/voip/omnichannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { IUser, IVoipExtensionWithAgentInfo } from '@rocket.chat/core-typin
import { Users } from '@rocket.chat/models';

import { API } from '../../api';
import { hasPermission } from '../../../../authorization/server/index';
import { LivechatVoip } from '../../../../../server/sdk';
import { logger } from './logger';

Expand Down Expand Up @@ -31,12 +30,9 @@ const isUserIdndTypeParams = (p: any): p is { userId: string; type: 'free' | 'al

API.v1.addRoute(
'omnichannel/agent/extension',
{ authRequired: true },
{ authRequired: true, permissionsRequired: ['manage-agent-extension-association'] },
{
async post() {
if (!hasPermission(this.userId, 'manage-agent-extension-association')) {
return API.v1.unauthorized();
}
check(
this.bodyParams,
Match.OneOf(
Expand Down Expand Up @@ -94,13 +90,16 @@ API.v1.addRoute(

API.v1.addRoute(
'omnichannel/agent/extension/:username',
{ authRequired: true },
{
authRequired: true,
permissionsRequired: {
GET: ['view-agent-extension-association'],
DELETE: ['manage-agent-extension-association'],
},
},
{
// Get the extensions associated with the agent passed as request params.
async get() {
if (!hasPermission(this.userId, 'view-agent-extension-association')) {
return API.v1.unauthorized();
}
check(
this.urlParams,
Match.ObjectIncluding({
Expand Down Expand Up @@ -128,9 +127,6 @@ API.v1.addRoute(
},

async delete() {
if (!hasPermission(this.userId, 'manage-agent-extension-association')) {
return API.v1.unauthorized();
}
check(
this.urlParams,
Match.ObjectIncluding({
Expand Down
Loading