Skip to content

Commit

Permalink
Merge branch 'feat/federation-feat-2' of github.com:RocketChat/Rocket…
Browse files Browse the repository at this point in the history
….Chat into matrixSearch

* 'feat/federation-feat-2' of github.com:RocketChat/Rocket.Chat: (31 commits)
  fix: removing file wrongly merged on update merge
  [NEW] Federation search public rooms in the Matrix network (#27434)
  Chore: Refactor other kinds of message - Phase 2 (#27927)
  Chore: improve some e2e selectors (#27936)
  [NEW] Warning Popup reinforcing Zapier deprecation on Integrations Admin settings (#27744)
  Chore: Notify Marketplace on App Install (#27925)
  i18n: Language update from LingoHub 🤖 on 2023-01-23Z (#27814)
  [FIX][ENTERPRISE] DDP streamer sending data to destroyed streams (#27929)
  Chore: Migrate cached collections to TypeScript (#27909)
  i18n: Language update from LingoHub 🤖 on 2023-01-09Z (#27705)
  [FIX] Reduce re-subscription on `notify-room/user-activity` stream event (#27911)
  [FIX] Unread Message count not displayed for new messages in Omni-Rooms (#27539)
  Chore: Improve service's licence check (#27872)
  [IMPROVE] Livechat Persian translation (#27825)
  Chore(deps): Bump thehanimo/pr-title-checker from 1.3.4 to 1.3.6 (#27884)
  Chore: use useQuery in place of deprecated useEndpointData (#27673)
  Chore: Update Some Composer Icons (#27862)
  Regression: Undefined default message context (#27870)
  Chore: Remove OS version for device management (#27786)
  [BREAK] Remove less theming (#27647)
  ...
  • Loading branch information
gabriellsh committed Feb 6, 2023
2 parents 06bf9fa + 1ced7db commit 9155710
Show file tree
Hide file tree
Showing 448 changed files with 6,930 additions and 6,422 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} />;"
]
}
}
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',
],
};
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.

2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function findStarredMessages({
}): Promise<{
messages: IMessage[];
count: number;
offset: any;
offset: number;
total: number;
}> {
const room = await Rooms.findOneById(roomId);
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/apps/client/communication/websockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { Emitter } from '@rocket.chat/emitter';

import { slashCommands, APIClient } from '../../../utils';
import { CachedCollectionManager } from '../../../ui-cached-collection';
import { CachedCollectionManager } from '../../../ui-cached-collection/client';
import { loadButtons } from '../../../ui-message/client/ActionButtonSyncer';

export const AppEvents = Object.freeze({
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/apps/client/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { AppScreenshot, AppRequestFilter, Pagination, IRestResponse, Serial
import type { App } from '../../../client/views/admin/apps/types';
import { dispatchToastMessage } from '../../../client/lib/toast';
import { settings } from '../../settings/client';
import { CachedCollectionManager } from '../../ui-cached-collection';
import { CachedCollectionManager } from '../../ui-cached-collection/client';
import { createDeferredValue } from '../lib/misc/DeferredValue';
import type {
// IAppFromMarketplace,
Expand Down
7 changes: 7 additions & 0 deletions apps/meteor/app/apps/server/communication/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Apps } from '../orchestrator';
import { formatAppInstanceForRest } from '../../lib/misc/formatAppInstanceForRest';
import { actionButtonsHandler } from './endpoints/actionButtonsHandler';
import { fetch } from '../../../../server/lib/http/fetch';
import { notifyAppInstall } from '../marketplace/appInstall';

const rocketChatVersion = Info.version;
const appsEngineVersionForMarketplace = Info.marketplaceApiVersion.replace(/-.*/g, '');
Expand Down Expand Up @@ -273,6 +274,8 @@ export class AppsRestApi {

info.status = aff.getApp().getStatus();

notifyAppInstall(orchestrator.getMarketplaceUrl(), 'install', info);

return API.v1.success({
app: info,
implemented: aff.getImplementedInferfaces(),
Expand Down Expand Up @@ -558,6 +561,8 @@ export class AppsRestApi {

info.status = aff.getApp().getStatus();

notifyAppInstall(orchestrator.getMarketplaceUrl(), 'update', info);

return API.v1.success({
app: info,
implemented: aff.getImplementedInferfaces(),
Expand All @@ -578,6 +583,8 @@ export class AppsRestApi {
const info = prl.getInfo();
info.status = prl.getStatus();

notifyAppInstall(orchestrator.getMarketplaceUrl(), 'uninstall', info);

return API.v1.success({ app: info });
},
},
Expand Down
46 changes: 46 additions & 0 deletions apps/meteor/app/apps/server/marketplace/appInstall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { IAppInfo } from '@rocket.chat/apps-engine/definition/metadata';

import { getWorkspaceAccessToken } from '../../../cloud/server';
import { settings } from '../../../settings/server';
import { Info } from '../../../utils/server';

export type installAction = 'install' | 'update' | 'uninstall';

export async function notifyAppInstall(marketplaceBaseUrl: string, action: installAction, appInfo: IAppInfo): Promise<void> {
const headers: { Authorization?: string } = {};

try {
const token = await getWorkspaceAccessToken();
headers.Authorization = `Bearer ${token}`;

// eslint-disable-next-line no-empty
} catch {}

let siteUrl = '';
try {
siteUrl = settings.get<string>('Site_Url');

// eslint-disable-next-line no-empty
} catch {}

const data = {
action,
appName: appInfo.name,
appSlug: appInfo.nameSlug,
appVersion: appInfo.version,
rocketChatVersion: Info.version,
engineVersion: Info.marketplaceApiVersion,
siteUrl,
};

const pendingSentUrl = `${marketplaceBaseUrl}/v1/apps/${appInfo.id}/install`;

try {
HTTP.post(pendingSentUrl, {
headers,
data,
});

// eslint-disable-next-line no-empty
} catch {}
}
Loading

0 comments on commit 9155710

Please sign in to comment.