Skip to content

Commit

Permalink
Merge branch 'develop' into omni/unread-counter-not-working
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jan 30, 2023
2 parents 4a99082 + 56aae78 commit ebb4d3b
Show file tree
Hide file tree
Showing 395 changed files with 5,789 additions and 4,681 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-title-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: thehanimo/pr-title-checker@v1.3.4
- uses: thehanimo/pr-title-checker@v1.3.6
with:
GITHUB_TOKEN: ${{ secrets.RC_TITLE_CHECKER }}
36 changes: 36 additions & 0 deletions .vscode/client.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Storybook stories module for React component": {
"scope": "typescriptreact",
"prefix": "sbmodule",
"body": [
"import type { ComponentMeta, ComponentStory } from '@storybook/react';",
"import React from 'react';",
"",
"import $1 from './$1';",
"",
"export default {",
"\ttitle: '$2',",
"\tcomponent: $1,",
"} as ComponentMeta<typeof $1>;",
"",
"export const Example: ComponentStory<typeof $1> = (args) => <$1 {...args} />;",
]
},
"Storybook meta": {
"scope": "typescriptreact",
"prefix": "sbmeta",
"body": [
"export default {",
"\ttitle: '$1',",
"\tcomponent: $2,",
"} as ComponentMeta<typeof $2>;"
]
},
"Storybook story": {
"scope": "typescriptreact",
"prefix": "sbstory",
"body": [
"export const $1: ComponentStory<typeof $2> = (args) => <$2 {...args} />;"
]
}
}
7 changes: 1 addition & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,5 @@
}
],
"typescript.tsdk": "./node_modules/typescript/lib",
"cSpell.words": [
"livechat",
"omnichannel",
"photoswipe",
"tmid"
]
"cSpell.words": ["katex", "livechat", "omnichannel", "photoswipe", "tmid"]
}
4 changes: 2 additions & 2 deletions apps/meteor/.mocharc.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ module.exports = {
exit: false,
slow: 200,
spec: [
'tests/unit/client/**/*.spec.ts',
'client/**/*.spec.{ts,tsx}',
'tests/unit/client/**/*.spec.{ts,tsx}',
'tests/unit/lib/**/*.tests.ts',
'tests/unit/client/**/*.test.ts',
'tests/unit/client/**/*.spec.tsx',
],
};
30 changes: 28 additions & 2 deletions apps/meteor/app/2fa/client/overrideMeteorCall.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Meteor } from 'meteor/meteor';

import { t } from '../../utils/client';
import { process2faReturn } from '../../../client/lib/2fa/process2faReturn';
import { process2faReturn, process2faAsyncReturn } from '../../../client/lib/2fa/process2faReturn';
import { isTotpInvalidError } from '../../../client/lib/2fa/utils';

const { call } = Meteor;
const { call, callAsync } = Meteor;

type Callback = {
(error: unknown): void;
Expand Down Expand Up @@ -34,8 +34,34 @@ const callWithoutTotp = (methodName: string, args: unknown[], callback: Callback
});
});

const callAsyncWithTotp =
(methodName: string, args: unknown[]) =>
async (twoFactorCode: string, twoFactorMethod: string): Promise<unknown> => {
try {
const result = await callAsync(methodName, ...args, { twoFactorCode, twoFactorMethod });

return result;
} catch (error: unknown) {
if (isTotpInvalidError(error)) {
throw new Error(twoFactorMethod === 'password' ? t('Invalid_password') : t('Invalid_two_factor_code'));
}

throw error;
}
};

Meteor.call = function (methodName: string, ...args: unknown[]): unknown {
const callback = args.length > 0 && typeof args[args.length - 1] === 'function' ? (args.pop() as Callback) : (): void => undefined;

return callWithoutTotp(methodName, args, callback)();
};

Meteor.callAsync = async function _callAsyncWithTotp(methodName: string, ...args: unknown[]): Promise<unknown> {
const promise = callAsync(methodName, ...args);

return process2faAsyncReturn({
promise,
onCode: callAsyncWithTotp(methodName, args),
emailOrUsername: undefined,
});
};
26 changes: 0 additions & 26 deletions apps/meteor/app/action-links/README.md

This file was deleted.

76 changes: 17 additions & 59 deletions apps/meteor/app/action-links/client/lib/actionLinks.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,28 @@
import { Meteor } from 'meteor/meteor';
import type { IMessage } from '@rocket.chat/core-typings';

import { dispatchToastMessage } from '../../../../client/lib/toast';
import { isLayoutEmbedded } from '../../../../client/lib/utils/isLayoutEmbedded';
import { fireGlobalEvent } from '../../../../client/lib/utils/fireGlobalEvent';

// Action Links namespace creation.
export const actionLinks = {
actions: new Map<
string,
(message: IMessage, params: string, instance?: Blaze.TemplateInstance | ((actionId: string, context: string) => void)) => void
>(),
register(
name: string,
fn: (message: IMessage, params: string, instance?: Blaze.TemplateInstance | ((actionId: string, context: string) => void)) => void,
): void {
actions: new Map<string, (message: IMessage, params: string) => void>(),
register(name: string, fn: (message: IMessage, params: string) => void): void {
actionLinks.actions.set(name, fn);
},
// getMessage(name, messageId) {
// const userId = Meteor.userId();
// if (!userId) {
// throw new Meteor.Error('error-invalid-user', 'Invalid user', {
// function: 'actionLinks.getMessage',
// });
// }

// const message = Messages.findOne({ _id: messageId });
// if (!message) {
// throw new Meteor.Error('error-invalid-message', 'Invalid message', {
// function: 'actionLinks.getMessage',
// });
// }

// const subscription = Subscriptions.findOne({
// 'rid': message.rid,
// 'u._id': userId,
// });
// if (!subscription) {
// throw new Meteor.Error('error-not-allowed', 'Not allowed', {
// function: 'actionLinks.getMessage',
// });
// }

// if (!message.actionLinks || !message.actionLinks[name]) {
// throw new Meteor.Error('error-invalid-actionlink', 'Invalid action link', {
// function: 'actionLinks.getMessage',
// });
// }
run(actionMethodId: string, message: IMessage): void {
const embedded = isLayoutEmbedded();

if (embedded) {
fireGlobalEvent('click-action-link', {
actionlink: actionMethodId,
value: message._id,
message,
});
return;
}

// return message;
// },
run(method: string, message: IMessage, instance?: Blaze.TemplateInstance | ((actionId: string, context: string) => void)): void {
const actionLink = message.actionLinks?.find((action) => action.method_id === method);
const actionLink = message.actionLinks?.find((action) => action.method_id === actionMethodId);

if (!actionLink) {
throw new Meteor.Error('error-invalid-actionlink', 'Invalid action link');
Expand All @@ -60,21 +33,6 @@ export const actionLinks = {
}

const fn = actionLinks.actions.get(actionLink.method_id);

let ranClient = false;

if (fn) {
// run just on client side
fn(message, actionLink.params, instance);

ranClient = true;
}

// and run on server side
Meteor.call('actionLinkHandler', name, message._id, (error: unknown) => {
if (error && !ranClient) {
dispatchToastMessage({ type: 'error', message: error });
}
});
fn?.(message, actionLink.params);
},
};
31 changes: 0 additions & 31 deletions apps/meteor/app/action-links/server/actionLinkHandler.ts

This file was deleted.

4 changes: 0 additions & 4 deletions apps/meteor/app/action-links/server/index.ts

This file was deleted.

45 changes: 0 additions & 45 deletions apps/meteor/app/action-links/server/lib/actionLinks.ts

This file was deleted.

35 changes: 35 additions & 0 deletions apps/meteor/app/api/server/v1/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import type { IUser } from '@rocket.chat/core-typings';

import { API } from '../api';
import { handleSuggestedGroupKey } from '../../../e2e/server/functions/handleSuggestedGroupKey';

API.v1.addRoute(
'e2e.fetchMyKeys',
Expand Down Expand Up @@ -195,3 +196,37 @@ API.v1.addRoute(
},
},
);

API.v1.addRoute(
'e2e.acceptSuggestedGroupKey',
{
authRequired: true,
validateParams: ise2eGetUsersOfRoomWithoutKeyParamsGET,
},
{
async post() {
const { rid } = this.bodyParams;

await handleSuggestedGroupKey('accept', rid, this.userId, 'e2e.acceptSuggestedGroupKey');

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

API.v1.addRoute(
'e2e.rejectSuggestedGroupKey',
{
authRequired: true,
validateParams: ise2eGetUsersOfRoomWithoutKeyParamsGET,
},
{
async post() {
const { rid } = this.bodyParams;

await handleSuggestedGroupKey('reject', rid, this.userId, 'e2e.rejectSuggestedGroupKey');

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

0 comments on commit ebb4d3b

Please sign in to comment.