Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into jb-convert-client-…
Browse files Browse the repository at this point in the history
…sidebar
  • Loading branch information
ggazzo committed May 24, 2022
2 parents 61cc2ed + 574e82d commit e48bca1
Show file tree
Hide file tree
Showing 343 changed files with 8,422 additions and 5,118 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ yarn-error.log*
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.nvmrc
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"changeProcessCWD": true
}
],
"typescript.tsdk": "./node_modules/typescript/lib"
"typescript.tsdk": "./node_modules/typescript/lib",
"cSpell.words": ["photoswipe"]
}
2 changes: 1 addition & 1 deletion _templates/package/new/package.json.ejs.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ to: packages/<%= name %>/package.json
"eslint": "^8.12.0",
"jest": "^27.5.1",
"ts-jest": "^27.1.4",
"typescript": "~4.3.5"
"typescript": "~4.3.4"
},
"scripts": {
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ spacebars
standard-minifier-js@2.8.0
tracker@1.2.0

#rocketchat:google-natural-language
rocketchat:livechat
rocketchat:streamer
rocketchat:version
Expand Down
9 changes: 6 additions & 3 deletions apps/meteor/app/api/server/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
PathPattern,
UrlParams,
} from '@rocket.chat/rest-typings';
import type { IUser, IMethodConnection } from '@rocket.chat/core-typings';
import type { IUser, IMethodConnection, IRoom } from '@rocket.chat/core-typings';
import type { ValidateFunction } from 'ajv';

import { ITwoFactorOptions } from '../../2fa/server/code';
Expand Down Expand Up @@ -96,19 +96,22 @@ type ActionThis<TMethod extends Method, TPathPattern extends PathPattern, TOptio
? T
: Partial<OperationParams<TMethod, TPathPattern>>;
readonly request: Request;
/* @deprecated */
requestParams(): OperationParams<TMethod, TPathPattern>;
getLoggedInUser(): IUser | undefined;
getPaginationItems(): {
readonly offset: number;
readonly count: number;
};
parseJsonQuery(): {
sort: Record<string, unknown>;
fields: Record<string, unknown>;
sort: Record<string, 1 | -1>;
fields: Record<string, 0 | 1>;
query: Record<string, unknown>;
};
/* @deprecated */
getUserFromParams(): IUser;
insertUserObject<T>({ object, userId }: { object: { [key: string]: unknown }; userId: string }): { [key: string]: unknown } & T;
composeRoomWithLastMessage(room: IRoom, userId: string): IRoom;
} & (TOptions extends { authRequired: true }
? {
readonly user: IUser;
Expand Down
15 changes: 15 additions & 0 deletions apps/meteor/app/api/server/helpers/parseJsonQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ API.helperMethods.set('parseJsonQuery', function _parseJsonQuery() {
if (this.queryParams.sort) {
try {
sort = JSON.parse(this.queryParams.sort);
Object.entries(sort).forEach(([key, value]) => {
if (value !== 1 && value !== -1) {
throw new Meteor.Error('error-invalid-sort-parameter', `Invalid sort parameter: ${key}`, {
helperMethod: 'parseJsonQuery',
});
}
});
} catch (e) {
this.logger.warn(`Invalid sort parameter provided "${this.queryParams.sort}":`, e);
throw new Meteor.Error('error-invalid-sort', `Invalid sort parameter provided: "${this.queryParams.sort}"`, {
Expand All @@ -27,6 +34,14 @@ API.helperMethods.set('parseJsonQuery', function _parseJsonQuery() {
if (this.queryParams.fields) {
try {
fields = JSON.parse(this.queryParams.fields);

Object.entries(fields).forEach(([key, value]) => {
if (value !== 1 && value !== 0) {
throw new Meteor.Error('error-invalid-sort-parameter', `Invalid fields parameter: ${key}`, {
helperMethod: 'parseJsonQuery',
});
}
});
} catch (e) {
this.logger.warn(`Invalid fields parameter provided "${this.queryParams.fields}":`, e);
throw new Meteor.Error('error-invalid-fields', `Invalid fields parameter provided: "${this.queryParams.fields}"`, {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/lib/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const findOneIntegration = async ({
}: {
userId: string;
integrationId: string;
createdBy: IUser;
createdBy?: IUser['_id'];
}): Promise<IIntegration> => {
const integration = await Integrations.findOneByIdAndCreatedByIfExists({
_id: integrationId,
Expand Down
7 changes: 3 additions & 4 deletions apps/meteor/app/api/server/v1/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ API.v1.addRoute(
'chat.getMessageReadReceipts',
{ authRequired: true },
{
get() {
async get() {
const { messageId } = this.queryParams;
if (!messageId) {
return API.v1.failure({
Expand All @@ -384,9 +384,8 @@ API.v1.addRoute(
}

try {
const messageReadReceipts = Meteor.runAsUser(this.userId, () => Meteor.call('getReadReceipts', { messageId }));
return API.v1.success({
receipts: messageReadReceipts,
receipts: await Meteor.call('getReadReceipts', { messageId }),
});
} catch (error) {
return API.v1.failure({
Expand All @@ -411,7 +410,7 @@ API.v1.addRoute(
return API.v1.failure('The required "description" param is missing.');
}

Meteor.runAsUser(this.userId, () => Meteor.call('reportMessage', messageId, description));
Meteor.call('reportMessage', messageId, description);

return API.v1.success();
},
Expand Down
Loading

0 comments on commit e48bca1

Please sign in to comment.