Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 4cbc777
Author: Kevin Aleman <[email protected]>
Date:   Fri May 20 13:24:10 2022 -0600

    Chore: Rewrite autotranslate to ts (#25425)

commit 603ade2
Author: Rafael Tapia <[email protected]>
Date:   Fri May 20 13:47:17 2022 -0400

    [NEW] Add user events for apps (#25165)

    * Add user events for apps

    * Remove trycatch validation

    * Get the user entity after the update

    * Trigger events when the user updates his profile or deletes his account

    * Update Apps-Engine

    * Make update return doc after update

    * Find user after the update to trigger event with correct data

    * Change where clause to use userData instead of userId

    * Update apps-engine

commit 6aa09ec
Author: Pierre Lehnen <[email protected]>
Date:   Fri May 20 14:27:11 2022 -0300

    [FIX] Integrations avatar attribute misuse (#25283)

commit dd6acaf
Author: Allan RIbeiro <[email protected]>
Date:   Fri May 20 14:25:14 2022 -0300

    Chore: Converting orchestrator.js to ts (#25367)

commit 6d95144
Author: Matheus Lucca do Carmo <[email protected]>
Date:   Fri May 20 14:23:44 2022 -0300

    Chore: convert marketplace price display component to use typescript (#25504)

commit 45417ea
Author: Júlia Jaeger Foresti <[email protected]>
Date:   Fri May 20 14:17:58 2022 -0300

    Chore: Convert apps/meteor/client/components/UserAutoComplete (#25554)

    Co-authored-by: Guilherme Gazzo <[email protected]>

commit 8a3c928
Author: Aaron Ogle <[email protected]>
Date:   Fri May 20 08:35:44 2022 -0500

    [FIX] Initial User not added to default channel (#25544)

commit b893ffd
Author: Leonardo Ostjen Couto <[email protected]>
Date:   Thu May 19 20:39:38 2022 -0300

    [NEW] New stats rewrite (#25078)

    Co-authored-by: matheusbsilva137 <[email protected]>
    Co-authored-by: Diego Sampaio <[email protected]>

commit 42442d2
Author: Júlia Jaeger Foresti <[email protected]>
Date:   Thu May 19 18:42:27 2022 -0300

    Chore: Convert apps/meteor/client/views/admin/settings (#25565)

commit 59c52e3
Author: Cauê Felchar <[email protected]>
Date:   Thu May 19 16:32:06 2022 -0300

    [FIX] User abandonment setting is working again (#25520)

commit e851297
Author: souzaramon <[email protected]>
Date:   Thu May 19 01:04:54 2022 -0300

    Test: Migrate 13-permissions from cypress to playwright (#25558)

commit 0830814
Author: Filipe Marins <[email protected]>
Date:   Wed May 18 20:06:13 2022 -0300

    [FIX] Add open user card to user avatar (#25445)

commit e80d88f
Author: Guilherme Gazzo <[email protected]>
Date:   Wed May 18 19:28:37 2022 -0300

    [FIX] Dynamic load matrix is enabled and handle failure (#25495)

    Co-authored-by: Aaron Ogle <[email protected]>

commit 71d57bd
Author: Martin Schoeler <[email protected]>
Date:   Wed May 18 17:45:58 2022 -0300

    [FIX] One of the triggers was not working correctly (#25409)

    * [FIX] One of the triggers was not working correctly

    * fix html iteration

    * eslint fix

    Co-authored-by: Tiago Evangelista Pinto <[email protected]>

commit bbd534a
Author: Guilherme Gazzo <[email protected]>
Date:   Wed May 18 14:42:44 2022 -0300

    Regression: CI services build (#25555)

commit 45b46da
Author: Fábio Albuquerque <[email protected]>
Date:   Wed May 18 09:42:43 2022 -0300

    Chore: User set UTC offset (#25381)

    Co-authored-by: Guilherme Gazzo <[email protected]>

commit d170c48
Author: Guilherme Jun Grillo <[email protected]>
Date:   Wed May 18 09:11:44 2022 -0300

    [FIX] Rooms' names turn lower case on CSV import (#24612)

    * feat: change channel name 'rule' when importing

    * feat: add maintainCase in limax

    * fix: update special characters rule

    * fix: regression of settings use for import rules

commit 3ab9d8a
Author: Weslley Campos <[email protected]>
Date:   Tue May 17 21:34:38 2022 -0300

    Chore: migrate-to-pw-adjust-in-intermitences (#25542)

commit f975b2c
Author: Matheus Barbosa Silva <[email protected]>
Date:   Tue May 17 18:38:44 2022 -0300

    Add support to map a LDAP group to multiple roles (#23849)

    Co-authored-by: Pierre Lehnen <[email protected]>

commit 86c0131
Author: Guilherme Gazzo <[email protected]>
Date:   Tue May 17 17:05:44 2022 -0300

    Chore: Livechat change output level (#25522)

commit 93575bf
Author: Allan RIbeiro <[email protected]>
Date:   Tue May 17 16:11:51 2022 -0300

    [NEW] Adding app button on user dropdown (#25326)

    * feat: adding app button on user dropdown

    * chore: changing some implementations and adding comments

    * chore: fixing lint issues

    * Update apps/meteor/client/sidebar/header/UserDropdown.tsx

    * chore: change some method location

    * chore: fixing lint issues

    * fix: using local method

    * Refactor AccountBox to singleton

    Co-authored-by: Douglas Gubert <[email protected]>

commit fd40e3e
Author: Weslley Campos <[email protected]>
Date:   Tue May 17 13:33:19 2022 -0300

    Chore: migrate from cypress to pw 14-setting-permission (#25523)

commit 88710b2
Author: souzaramon <[email protected]>
Date:   Tue May 17 10:59:56 2022 -0300

    Chore: Tests with Playwright (task: ROC-31, 12-settings) (#25253)

commit 72db7a2
Author: souzaramon <[email protected]>
Date:   Tue May 17 09:35:07 2022 -0300

    Chore: Migrate 15-message-popup from cypress to playwright (#25462)

commit 99a3651
Author: Júlia Jaeger Foresti <[email protected]>
Date:   Mon May 16 16:56:01 2022 -0300

    Chore: Convert apps/meteor/client/views/admin/settings/inputs folder (#25427)

commit 75c7f4d
Author: Martin Schoeler <[email protected]>
Date:   Mon May 16 16:10:42 2022 -0300

    [FIX] UI/UX issues on Live Chat widget (#25407)

    * [FIX] UI/UX issues on Live Chat widget

    * Use @rocketchat/logo

    * READ THE ERRORS MARTIN

    * Remove old logo

    * Fix Reviews

    * chore: remove unnecessary class prop

    Co-authored-by: dougfabris <[email protected]>

commit bdeb54a
Author: Yash Rajpal <[email protected]>
Date:   Tue May 17 00:12:55 2022 +0530

    Chore: Convert Admin -> Rooms to TS (#25348)

    Co-authored-by: Guilherme Gazzo <[email protected]>

commit 394b4aa
Author: Hugo Costa <[email protected]>
Date:   Mon May 16 12:52:15 2022 -0300

    Chore: Migrate NotFoundPage to TS (#25509)

commit de7cd66
Author: Hugo Costa <[email protected]>
Date:   Mon May 16 12:10:48 2022 -0300

    [FIX] Unable to see channel member list by authorized channel roles (#25412)

commit 2d59aa9
Author: Guilherme Gazzo <[email protected]>
Date:   Mon May 16 11:08:28 2022 -0300

    Regression: Fix services-image-build-check (#25519)

    Co-authored-by: Diego Sampaio <[email protected]>

commit 3b9254e
Author: Kevin Aleman <[email protected]>
Date:   Mon May 16 05:55:35 2022 -0600

    Chore: Migrate spotify to ts (#25507)
  • Loading branch information
albuquerquefabio committed May 20, 2022
1 parent a767b14 commit 7ba724a
Show file tree
Hide file tree
Showing 80 changed files with 2,021 additions and 735 deletions.
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { IIntegration } from '@rocket.chat/core-typings';
import {
isIntegrationsCreateProps,
isIntegrationsHistoryProps,
isIntegrationsRemoveProps,
isIntegrationsGetProps,
isIntegrationsUpdateProps,
} from '@rocket.chat/rest-typings';

import { hasAtLeastOnePermission } from '../../../authorization/server';
import { Integrations, IntegrationHistory } from '../../../models/server/raw';
Expand All @@ -12,45 +20,32 @@ import { findOneIntegration } from '../lib/integrations';

API.v1.addRoute(
'integrations.create',
{ authRequired: true },
{ authRequired: true, validateParams: isIntegrationsCreateProps },
{
post() {
check(
this.bodyParams,
Match.ObjectIncluding({
type: String,
name: String,
enabled: Boolean,
username: String,
urls: Match.Maybe([String]),
channel: String,
event: Match.Maybe(String),
triggerWords: Match.Maybe([String]),
alias: Match.Maybe(String),
avatar: Match.Maybe(String),
emoji: Match.Maybe(String),
token: Match.Maybe(String),
scriptEnabled: Boolean,
script: Match.Maybe(String),
targetChannel: Match.Maybe(String),
}),
);

let integration;

switch (this.bodyParams.type) {
case 'webhook-outgoing':
Meteor.runAsUser(this.userId, () => {
integration = Meteor.call('addOutgoingIntegration', this.bodyParams);
});
break;
case 'webhook-incoming':
Meteor.runAsUser(this.userId, () => {
integration = Meteor.call('addIncomingIntegration', this.bodyParams);
});
break;
default:
return API.v1.failure('Invalid integration type.');
const { userId, bodyParams } = this;

const integration = ((): IIntegration | undefined => {
let integration: IIntegration | undefined;

switch (bodyParams.type) {
case 'webhook-outgoing':
Meteor.runAsUser(userId, () => {
integration = Meteor.call('addOutgoingIntegration', bodyParams);
});
break;
case 'webhook-incoming':
Meteor.runAsUser(userId, () => {
integration = Meteor.call('addIncomingIntegration', bodyParams);
});
break;
}

return integration;
})();

if (!integration) {
return API.v1.failure('Invalid integration type.');
}

return API.v1.success({ integration });
Expand All @@ -60,21 +55,23 @@ API.v1.addRoute(

API.v1.addRoute(
'integrations.history',
{ authRequired: true },
{ authRequired: true, validateParams: isIntegrationsHistoryProps },
{
get() {
if (!hasAtLeastOnePermission(this.userId, ['manage-outgoing-integrations', 'manage-own-outgoing-integrations'])) {
const { userId, queryParams } = this;

if (!hasAtLeastOnePermission(userId, ['manage-outgoing-integrations', 'manage-own-outgoing-integrations'])) {
return API.v1.unauthorized();
}

if (!this.queryParams.id || this.queryParams.id.trim() === '') {
if (!queryParams.id || queryParams.id.trim() === '') {
return API.v1.failure('Invalid integration id.');
}

const { id } = this.queryParams;
const { id } = queryParams;
const { offset, count } = this.getPaginationItems();
const { sort, fields: projection, query } = this.parseJsonQuery();
const ourQuery = Object.assign(mountIntegrationHistoryQueryBasedOnPermissions(this.userId, id), query);
const ourQuery = Object.assign(mountIntegrationHistoryQueryBasedOnPermissions(userId, id), query);

const cursor = IntegrationHistory.find(ourQuery, {
sort: sort || { _updatedAt: -1 },
Expand All @@ -90,6 +87,7 @@ API.v1.addRoute(
history,
offset,
items: history.length,
count: history.length,
total,
});
},
Expand Down Expand Up @@ -131,6 +129,7 @@ API.v1.addRoute(
integrations,
offset,
items: integrations.length,
count: integrations.length,
total,
});
},
Expand All @@ -139,7 +138,7 @@ API.v1.addRoute(

API.v1.addRoute(
'integrations.remove',
{ authRequired: true },
{ authRequired: true, validateParams: isIntegrationsRemoveProps },
{
post() {
if (
Expand All @@ -153,48 +152,51 @@ API.v1.addRoute(
return API.v1.unauthorized();
}

check(
this.bodyParams,
Match.ObjectIncluding({
type: String,
target_url: Match.Maybe(String),
integrationId: Match.Maybe(String),
}),
);

if (!this.bodyParams.target_url && !this.bodyParams.integrationId) {
return API.v1.failure('An integrationId or target_url needs to be provided.');
}
const { bodyParams } = this;

let integration;
switch (this.bodyParams.type) {
let integration: IIntegration | null = null;
switch (bodyParams.type) {
case 'webhook-outgoing':
if (this.bodyParams.target_url) {
integration = Promise.await(Integrations.findOne({ urls: this.bodyParams.target_url }));
} else if (this.bodyParams.integrationId) {
integration = Promise.await(Integrations.findOne({ _id: this.bodyParams.integrationId }));
if (!bodyParams.target_url && !bodyParams.integrationId) {
return API.v1.failure('An integrationId or target_url needs to be provided.');
}

if (bodyParams.target_url) {
integration = Promise.await(Integrations.findOne({ urls: bodyParams.target_url }));
} else if (bodyParams.integrationId) {
integration = Promise.await(Integrations.findOne({ _id: bodyParams.integrationId }));
}

if (!integration) {
return API.v1.failure('No integration found.');
}

const outgoingId = integration._id;

Meteor.runAsUser(this.userId, () => {
Meteor.call('deleteOutgoingIntegration', integration._id);
Meteor.call('deleteOutgoingIntegration', outgoingId);
});

return API.v1.success({
integration,
});
case 'webhook-incoming':
integration = Promise.await(Integrations.findOne({ _id: this.bodyParams.integrationId }));
check(
bodyParams,
Match.ObjectIncluding({
integrationId: String,
}),
);

integration = Promise.await(Integrations.findOne({ _id: bodyParams.integrationId }));

if (!integration) {
return API.v1.failure('No integration found.');
}

const incomingId = integration._id;
Meteor.runAsUser(this.userId, () => {
Meteor.call('deleteIncomingIntegration', integration._id);
Meteor.call('deleteIncomingIntegration', incomingId);
});

return API.v1.success({
Expand All @@ -209,7 +211,7 @@ API.v1.addRoute(

API.v1.addRoute(
'integrations.get',
{ authRequired: true },
{ authRequired: true, validateParams: isIntegrationsGetProps },
{
get() {
const { integrationId, createdBy } = this.queryParams;
Expand All @@ -232,58 +234,37 @@ API.v1.addRoute(

API.v1.addRoute(
'integrations.update',
{ authRequired: true },
{ authRequired: true, validateParams: isIntegrationsUpdateProps },
{
put() {
check(
this.bodyParams,
Match.ObjectIncluding({
type: String,
name: String,
enabled: Boolean,
username: String,
urls: Match.Maybe([String]),
channel: String,
event: Match.Maybe(String),
triggerWords: Match.Maybe([String]),
alias: Match.Maybe(String),
avatar: Match.Maybe(String),
emoji: Match.Maybe(String),
token: Match.Maybe(String),
scriptEnabled: Boolean,
script: Match.Maybe(String),
targetChannel: Match.Maybe(String),
integrationId: Match.Maybe(String),
target_url: Match.Maybe(String),
}),
);
const { bodyParams } = this;

let integration;
switch (this.bodyParams.type) {
switch (bodyParams.type) {
case 'webhook-outgoing':
if (this.bodyParams.target_url) {
integration = Promise.await(Integrations.findOne({ urls: this.bodyParams.target_url }));
} else if (this.bodyParams.integrationId) {
integration = Promise.await(Integrations.findOne({ _id: this.bodyParams.integrationId }));
if (bodyParams.target_url) {
integration = Promise.await(Integrations.findOne({ urls: bodyParams.target_url }));
} else if (bodyParams.integrationId) {
integration = Promise.await(Integrations.findOne({ _id: bodyParams.integrationId }));
}

if (!integration) {
return API.v1.failure('No integration found.');
}

Meteor.call('updateOutgoingIntegration', integration._id, this.bodyParams);
Meteor.call('updateOutgoingIntegration', integration._id, bodyParams);

return API.v1.success({
integration: Promise.await(Integrations.findOne({ _id: integration._id })),
});
case 'webhook-incoming':
integration = Promise.await(Integrations.findOne({ _id: this.bodyParams.integrationId }));
integration = Promise.await(Integrations.findOne({ _id: bodyParams.integrationId }));

if (!integration) {
return API.v1.failure('No integration found.');
}

Meteor.call('updateIncomingIntegration', integration._id, this.bodyParams);
Meteor.call('updateIncomingIntegration', integration._id, bodyParams);

return API.v1.success({
integration: Promise.await(Integrations.findOne({ _id: integration._id })),
Expand Down
Loading

0 comments on commit 7ba724a

Please sign in to comment.