Skip to content

Commit

Permalink
Merge branch 'develop' into chore/system-messages-update
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusbsilva137 authored Jun 7, 2023
2 parents 57e9292 + 29556cb commit 83e6367
Show file tree
Hide file tree
Showing 168 changed files with 1,366 additions and 697 deletions.
8 changes: 8 additions & 0 deletions .changeset/early-turtles-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@rocket.chat/api-client": patch
"@rocket.chat/ddp-client": patch
"@rocket.chat/livechat": patch
"@rocket.chat/rest-typings": patch
---

chore: New Livechat SDK Implementation
5 changes: 5 additions & 0 deletions .changeset/friendly-spies-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: message deletion fails if has files attached on filesystem storage
5 changes: 5 additions & 0 deletions .changeset/modern-terms-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/agenda": patch
---

fix: Saving Business hour throws an alert
5 changes: 5 additions & 0 deletions .changeset/pretty-dots-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

fix: Room history scrollbar position
5 changes: 5 additions & 0 deletions .changeset/quiet-kids-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Fixed invalid message draft issue.
5 changes: 5 additions & 0 deletions .changeset/sixty-owls-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fix seats counter including apps
6 changes: 6 additions & 0 deletions .changeset/slow-maps-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
---

fix: Imported messages are not displayed
fix: Importer agent is added as a member of every imported room
5 changes: 5 additions & 0 deletions .changeset/soft-kings-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Added emoji popup trigger length of 3 characters.
5 changes: 5 additions & 0 deletions .changeset/violet-beans-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fix visitor's query when both email & phone number are empty
10 changes: 6 additions & 4 deletions apps/meteor/app/api/server/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { parseJsonQuery } from './helpers/parseJsonQuery';
import { Logger } from '../../logger/server';
import { getUserInfo } from './helpers/getUserInfo';
import { hasPermissionAsync } from '../../authorization/server/functions/hasPermission';
import { apiDeprecationLogger } from '../../lib/server/lib/deprecationWarningLogger';

const logger = new Logger('API');

Expand Down Expand Up @@ -177,10 +178,7 @@ export class APIClass<TBasePath extends string = ''> extends Restivus {
}

async parseJsonQuery(this: PartialThis) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;

return parseJsonQuery(this.request.route, self.userId, self.queryParams, self.logger, self.queryFields, self.queryOperations);
return parseJsonQuery(this);
}

public addAuthMethod(func: (this: PartialThis, ...args: any[]) => any): void {
Expand Down Expand Up @@ -581,6 +579,10 @@ export class APIClass<TBasePath extends string = ''> extends Restivus {
};

try {
if (options.deprecationVersion) {
apiDeprecationLogger.endpoint(this.request.route, options.deprecationVersion, this.response);
}

await api.enforceRateLimit(objectForRateLimitMatch, this.request, this.response, this.userId);

if (_options.validateParams) {
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/api/server/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export type Options = (
) & {
validateParams?: ValidateFunction | { [key in Method]?: ValidateFunction };
authOrAnonRequired?: true;
deprecationVersion?: string;
};

export type PartialThis = {
Expand Down
26 changes: 0 additions & 26 deletions apps/meteor/app/api/server/helpers/deprecationWarning.ts

This file was deleted.

37 changes: 15 additions & 22 deletions apps/meteor/app/api/server/helpers/parseJsonQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,30 @@ import ejson from 'ejson';
import { isValidQuery } from '../lib/isValidQuery';
import { clean } from '../lib/cleanQuery';
import { API } from '../api';
import type { Logger } from '../../../logger/server';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { apiDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
import type { PartialThis } from '../definition';

const pathAllowConf = {
'/api/v1/users.list': ['$or', '$regex', '$and'],
'def': ['$or', '$and', '$regex'],
};

const warnFields =
process.env.NODE_ENV !== 'production' || process.env.SHOW_WARNINGS === 'true'
? (...rest: any): void => {
console.warn(...rest, new Error().stack);
}
: new Function();

export async function parseJsonQuery(
route: string,
userId: string,
params: {
query?: string;
sort?: string;
fields?: string;
},
logger: Logger,
queryFields?: string[],
queryOperations?: string[],
): Promise<{
export async function parseJsonQuery(api: PartialThis): Promise<{
sort: Record<string, 1 | -1>;
fields: Record<string, 0 | 1>;
query: Record<string, unknown>;
}> {
const {
request: { route },
userId,
queryParams: params,
logger,
queryFields,
queryOperations,
response,
} = api;

let sort;
if (params.sort) {
try {
Expand All @@ -56,7 +49,7 @@ export async function parseJsonQuery(

let fields: Record<string, 0 | 1> | undefined;
if (params.fields) {
warnFields('attribute fields is deprecated');
apiDeprecationLogger.parameter(route, 'fields', '7.0.0', response);
try {
fields = JSON.parse(params.fields) as Record<string, 0 | 1>;

Expand Down Expand Up @@ -107,7 +100,7 @@ export async function parseJsonQuery(

let query: Record<string, any> = {};
if (params.query) {
warnFields('attribute query is deprecated');
apiDeprecationLogger.parameter(route, 'query', '7.0.0', response);

try {
query = ejson.parse(params.query);
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/app/api/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import './helpers/composeRoomWithLastMessage';
import './helpers/deprecationWarning';
import './helpers/getLoggedInUser';
import './helpers/getPaginationItems';
import './helpers/getUserFromParams';
Expand Down
13 changes: 4 additions & 9 deletions apps/meteor/app/api/server/v1/oauthapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { OAuthApps } from '@rocket.chat/models';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { API } from '../api';
import { addOAuthApp } from '../../../oauth2-server-config/server/admin/functions/addOAuthApp';
import { deprecationWarning } from '../helpers/deprecationWarning';
import { apiDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';

API.v1.addRoute(
'oauth-apps.list',
Expand Down Expand Up @@ -32,16 +32,11 @@ API.v1.addRoute(
if (!oauthApp) {
return API.v1.failure('OAuth app not found.');
}

if ('appId' in this.queryParams) {
return API.v1.success(
deprecationWarning({
endpoint: 'oauth-apps.get',
warningMessage: ({ versionWillBeRemoved, endpoint }) =>
`appId get parameter from "${endpoint}" is deprecated and will be removed after version ${versionWillBeRemoved}. Use _id instead.`,
response: { oauthApp },
}),
);
apiDeprecationLogger.parameter(this.request.route, 'appId', '7.0.0', this.response);
}

return API.v1.success({
oauthApp,
});
Expand Down
13 changes: 10 additions & 3 deletions apps/meteor/app/api/server/v1/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ API.v1.addRoute(
return API.v1.failure('error-invalid-role-properties');
}

apiDeprecationLogger.warn(`Assigning roles by name is deprecated and will be removed on the next major release of Rocket.Chat`);
apiDeprecationLogger.parameter(this.request.route, 'roleName', '7.0.0', this.response);
}

const role = roleId ? await Roles.findOneById(roleId) : await Roles.findOneByIdOrName(roleName as string);
Expand Down Expand Up @@ -123,7 +123,14 @@ API.v1.addRoute(
throw new Meteor.Error('error-invalid-roleId');
}

apiDeprecationLogger.warn(`Querying roles by name is deprecated and will be removed on the next major release of Rocket.Chat`);
apiDeprecationLogger.deprecatedParameterUsage(
this.request.route,
'role',
'7.0.0',
this.response,
({ parameter, endpoint, version }) =>
`Querying \`${parameter}\` by name is deprecated in ${endpoint} and will be removed on the removed on version ${version}`,
);
}

const { cursor, totalCount } = await getUsersInRolePaginated(roleData._id, roomId, {
Expand Down Expand Up @@ -198,7 +205,7 @@ API.v1.addRoute(
return API.v1.failure('error-invalid-role-properties');
}

apiDeprecationLogger.warn(`Unassigning roles by name is deprecated and will be removed on the next major release of Rocket.Chat`);
apiDeprecationLogger.parameter(this.request.route, 'roleName', '7.0.0', this.response);
}

const user = await Users.findOneByUsername(username);
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/assets/server/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ declare module '@rocket.chat/ui-contexts' {
Meteor.methods<ServerMethods>({
async refreshClients() {
const uid = Meteor.userId();
methodDeprecationLogger.warn('refreshClients will be deprecated in future versions of Rocket.Chat');
methodDeprecationLogger.method('refreshClients', '7.0.0');

if (!uid) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
Expand Down
10 changes: 7 additions & 3 deletions apps/meteor/app/authorization/server/methods/addUserToRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ServerMethods } from '@rocket.chat/ui-contexts';

import { settings } from '../../../settings/server';
import { hasPermissionAsync } from '../functions/hasPermission';
import { apiDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';

declare module '@rocket.chat/ui-contexts' {
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down Expand Up @@ -41,8 +41,12 @@ Meteor.methods<ServerMethods>({
method: 'authorization:addUserToRole',
});
}

apiDeprecationLogger.warn(`Calling authorization:addUserToRole with role names will be deprecated in future versions of Rocket.Chat`);
methodDeprecationLogger.deprecatedParameterUsage(
'authorization:addUserToRole',
'role',
'7.0.0',
({ parameter, method, version }) => `Calling ${method} with \`${parameter}\` names is deprecated and will be removed ${version}`,
);
}

if (role._id === 'admin' && !(await hasPermissionAsync(userId, 'assign-admin-role'))) {
Expand Down
9 changes: 7 additions & 2 deletions apps/meteor/app/authorization/server/methods/deleteRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ServerMethods } from '@rocket.chat/ui-contexts';
import type { DeleteResult } from 'mongodb';

import { hasPermissionAsync } from '../functions/hasPermission';
import { apiDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';

declare module '@rocket.chat/ui-contexts' {
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down Expand Up @@ -42,7 +42,12 @@ Meteor.methods<ServerMethods>({
});
}

apiDeprecationLogger.warn(`Calling authorization:deleteRole with role names will be deprecated in future versions of Rocket.Chat`);
methodDeprecationLogger.deprecatedParameterUsage(
'authorization:deleteRole',
'role',
'7.0.0',
({ parameter, method, version }) => `Calling ${method} with ${parameter} names is deprecated and will be removed ${version}`,
);
}

if (role.protected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ServerMethods } from '@rocket.chat/ui-contexts';

import { settings } from '../../../settings/server';
import { hasPermissionAsync } from '../functions/hasPermission';
import { apiDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';

declare module '@rocket.chat/ui-contexts' {
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down Expand Up @@ -41,8 +41,11 @@ Meteor.methods<ServerMethods>({
});
}

apiDeprecationLogger.warn(
`Calling authorization:removeUserFromRole with role names will be deprecated in future versions of Rocket.Chat`,
methodDeprecationLogger.deprecatedParameterUsage(
'authorization:removeUserFromRole',
'role',
'7.0.0',
({ parameter, method, version }) => `Calling ${method} with ${parameter} names is deprecated and will be removed ${version}`,
);
}

Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/app/autotranslate/client/lib/actionButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
hasTranslationLanguageInMessage,
} from '../../../../client/views/room/MessageList/lib/autoTranslate';
import { roomCoordinator } from '../../../../client/lib/rooms/roomCoordinator';
import { sdk } from '../../../utils/client/lib/SDKClient';

Meteor.startup(() => {
AutoTranslate.init();
Expand All @@ -29,7 +30,7 @@ Meteor.startup(() => {
if (!hasTranslationLanguageInMessage(message, language) && !hasTranslationLanguageInAttachments(message.attachments, language)) {
(AutoTranslate.messageIdsToWait as any)[message._id] = true;
Messages.update({ _id: message._id }, { $set: { autoTranslateFetching: true } });
Meteor.call('autoTranslate.translateMessage', message, language);
void sdk.call('autoTranslate.translateMessage', message, language);
}
const action = 'autoTranslateShowInverse' in message ? '$unset' : '$set';
Messages.update({ _id: message._id }, { [action]: { autoTranslateShowInverse: true } });
Expand Down Expand Up @@ -63,7 +64,7 @@ Meteor.startup(() => {
if (!hasTranslationLanguageInMessage(message, language) && !hasTranslationLanguageInAttachments(message.attachments, language)) {
(AutoTranslate.messageIdsToWait as any)[message._id] = true;
Messages.update({ _id: message._id }, { $set: { autoTranslateFetching: true } });
Meteor.call('autoTranslate.translateMessage', message, language);
void sdk.call('autoTranslate.translateMessage', message, language);
}
const action = 'autoTranslateShowInverse' in message ? '$unset' : '$set';
Messages.update({ _id: message._id }, { [action]: { autoTranslateShowInverse: true } });
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/autotranslate/client/lib/autotranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { isTranslatedMessageAttachment } from '@rocket.chat/core-typings';

import { Subscriptions, Messages } from '../../../models/client';
import { hasPermission } from '../../../authorization/client';
import { call } from '../../../../client/lib/utils/call';
import {
hasTranslationLanguageInAttachments,
hasTranslationLanguageInMessage,
} from '../../../../client/views/room/MessageList/lib/autoTranslate';
import { sdk } from '../../../utils/client/lib/SDKClient';

let userLanguage = 'en';
let username = '';
Expand Down Expand Up @@ -110,8 +110,8 @@ export const AutoTranslate = {

try {
[this.providersMetadata, this.supportedLanguages] = await Promise.all([
call('autoTranslate.getProviderUiMetadata'),
call('autoTranslate.getSupportedLanguages', 'en'),
sdk.call('autoTranslate.getProviderUiMetadata'),
sdk.call('autoTranslate.getSupportedLanguages', 'en'),
]);
} catch (e: unknown) {
// Avoid unwanted error message on UI when autotranslate is disabled while fetching data
Expand Down
Loading

0 comments on commit 83e6367

Please sign in to comment.