Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
92f85fa
Regression messageAttachments
ggazzo Nov 4, 2019
2560bdd
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into develop
ggazzo Nov 5, 2019
0462c06
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into develop
ggazzo Nov 6, 2019
e9cf70d
Dummy endpoint
sampaiodiego Nov 7, 2019
43b14e7
created new blocks
ggazzo Nov 7, 2019
44c12e8
Fix stylelint issues
tassoevan Nov 7, 2019
427baaf
Add TODOs
tassoevan Nov 7, 2019
b3e3552
Implement modal.push helper
tassoevan Nov 7, 2019
f179dbe
camelcase
ggazzo Nov 8, 2019
fe29c05
more fix
ggazzo Nov 8, 2019
1ef5427
Merge branch 'blockit-chat' of github.com:RocketChat/Rocket.Chat into…
ggazzo Nov 8, 2019
76081b5
button accessory
ggazzo Nov 8, 2019
d6b385a
Message blocks
sampaiodiego Nov 8, 2019
6f4e27a
Add blocks field to message converter (again)
d-gubert Nov 8, 2019
4b35c2f
value buttons
ggazzo Nov 8, 2019
58bc797
fix url action
ggazzo Nov 8, 2019
ff122eb
Add app responde
sampaiodiego Nov 8, 2019
6c11421
ModalBlock
ggazzo Nov 8, 2019
f34f0e6
Undo tigragem
tassoevan Nov 8, 2019
2c89c20
actionId
ggazzo Nov 8, 2019
761afa4
messageId
ggazzo Nov 8, 2019
bdbb85d
Move response to app
sampaiodiego Nov 8, 2019
410a1c6
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into bloc…
ggazzo Nov 14, 2019
a9893ca
more components
ggazzo Nov 14, 2019
9ea30f2
Merge branch 'develop' into blockit-chat
sampaiodiego Nov 21, 2019
b2cc75d
handle form
ggazzo Nov 21, 2019
fa1d150
Merge branch 'blockit-chat' of github.com:RocketChat/Rocket.Chat into…
ggazzo Nov 21, 2019
310122b
Fix submit
sampaiodiego Nov 21, 2019
475e783
call trigger view submit
ggazzo Nov 21, 2019
457ad0f
Send appId
sampaiodiego Nov 21, 2019
f58ddaf
Merge branch 'master' into blockit-chat
sampaiodiego Nov 29, 2019
d5f6f44
Merge remote-tracking branch 'origin/develop' into blockit-chat
sampaiodiego Dec 3, 2019
89016ad
Revert package-lock
sampaiodiego Dec 3, 2019
ad47fd2
Validate user session
sampaiodiego Dec 3, 2019
760ae90
Provide user and message objects
sampaiodiego Dec 3, 2019
6c3b483
using fuselage
ggazzo Dec 4, 2019
3e76bca
Merge branch 'blockit-chat' of github.com:RocketChat/Rocket.Chat into…
ggazzo Dec 4, 2019
d83c854
Fix some issues
sampaiodiego Dec 4, 2019
b162661
more bugs
ggazzo Dec 5, 2019
b2f4d50
Modal update
ggazzo Dec 5, 2019
b8e2b84
Send rid
sampaiodiego Dec 5, 2019
81d73f2
Add room and view objects
sampaiodiego Dec 5, 2019
b1fc1aa
modal close
ggazzo Dec 5, 2019
a89df3c
ui-kit version
ggazzo Dec 7, 2019
a249608
temporary markdown
ggazzo Dec 10, 2019
940a595
removed nnr
ggazzo Dec 10, 2019
9208a1a
fix scroll after blockit render
ggazzo Dec 10, 2019
89ab2db
=remove old elements
ggazzo Dec 10, 2019
f5968bb
fix issues
ggazzo Dec 11, 2019
bd33494
Merge branch 'develop' into blockit-chat
sampaiodiego Dec 11, 2019
8d3ef55
Implement UI Interaction Streamer
sampaiodiego Dec 11, 2019
4491983
update package-lock
sampaiodiego Dec 12, 2019
f630590
Merge remote-tracking branch 'origin/develop' into blockit-chat
ggazzo Dec 20, 2019
b4eb600
fix build
ggazzo Dec 20, 2019
0ffb658
update ui-kit
ggazzo Dec 20, 2019
964f284
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into bloc…
tassoevan Dec 20, 2019
43d7cf5
Update PageNotFound
tassoevan Dec 20, 2019
45f757c
Update some Fuselage components
tassoevan Dec 20, 2019
598d0df
Update names to match Apps-Engine
d-gubert Dec 19, 2019
1ea301a
Merge branch 'develop' into uikit
sampaiodiego Dec 26, 2019
6029248
Use fuselage dev version
sampaiodiego Dec 26, 2019
c54b15e
Fix fuselage-ui-kit
sampaiodiego Dec 26, 2019
a6a5aa4
Fix modal data
sampaiodiego Dec 26, 2019
3ad51b7
Merge branch 'blockit-chat' of github.com:RocketChat/Rocket.Chat into…
ggazzo Dec 27, 2019
5118ebd
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into bloc…
ggazzo Dec 27, 2019
cccb20e
Merge branch 'blockit-chat' into uikit
sampaiodiego Dec 27, 2019
fa3ffc2
Get viewId from payload
sampaiodiego Dec 27, 2019
9dde05f
Fix not used var
sampaiodiego Dec 27, 2019
2d865b4
updated fuselage uikit
ggazzo Dec 30, 2019
c11d673
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into uikit
ggazzo Dec 30, 2019
7a95895
uikit cancel finish and fuselage update
ggazzo Dec 30, 2019
59ba808
fuselage update
ggazzo Dec 30, 2019
22d6e31
add triggerId
ggazzo Jan 2, 2020
a49f2b3
Add triggerId to the slash command endpoints
d-gubert Jan 5, 2020
f605e0a
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into uikit
ggazzo Jan 6, 2020
32e140d
update fuselage
ggazzo Jan 6, 2020
c587637
Merge branch 'develop' into uikit
sampaiodiego Jan 7, 2020
47f73f3
Fix triggerId for slash commands
sampaiodiego Jan 7, 2020
536e6f5
Update package-lock
sampaiodiego Jan 7, 2020
474ab5a
Merge remote-tracking branch 'origin/develop' into uikit
d-gubert Jan 8, 2020
095577c
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into uikit
ggazzo Jan 14, 2020
c21b185
Merge branch 'uikit' of github.com:RocketChat/Rocket.Chat into uikit
ggazzo Jan 14, 2020
40a0596
Merge branch 'develop' into uikit
sampaiodiego Jan 14, 2020
c1fc9e9
fix modal
ggazzo Jan 14, 2020
586e273
fix modal
ggazzo Jan 14, 2020
13f1268
Merge branch 'uikit' of github.com:RocketChat/Rocket.Chat into uikit
d-gubert Jan 14, 2020
5a189bd
fix modal rendering
ggazzo Jan 16, 2020
182341e
modal trap focus
ggazzo Jan 16, 2020
b109766
Update ActionManager to use UIKit definitions from Apps-Engine
d-gubert Jan 16, 2020
76d4fe4
Merge branch 'uikit' of github.com:RocketChat/Rocket.Chat into uikit
d-gubert Jan 16, 2020
58cffd4
Update to Apps-Engine
d-gubert Jan 16, 2020
af626ae
modal focus trap improvements
ggazzo Jan 17, 2020
cbe77a8
Merge branch 'uikit' of github.com:RocketChat/Rocket.Chat into uikit
d-gubert Jan 17, 2020
a39b277
update fuselage ui-kit
ggazzo Jan 17, 2020
57b8174
Merge branch 'uikit' of github.com:RocketChat/Rocket.Chat into uikit
ggazzo Jan 17, 2020
647dcfc
Update Apps-Engine
d-gubert Jan 17, 2020
66fef47
initial value
ggazzo Jan 18, 2020
0eed5e3
Merge remote-tracking branch 'origin/develop' into uikit
d-gubert Jan 27, 2020
05e525c
Update package.json
d-gubert Jan 27, 2020
0ab4c70
Merge remote-tracking branch 'origin/develop' into uikit
d-gubert Jan 29, 2020
87405f1
Update Apps-Engine version
d-gubert Jan 29, 2020
ea2ec0a
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into uikit
ggazzo Jan 31, 2020
c9a156d
fuselage update
ggazzo Jan 31, 2020
242f820
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into uikit
ggazzo Feb 1, 2020
e4e956d
handle app errors
ggazzo Feb 1, 2020
3b60280
Merge branch 'develop' into uikit
sampaiodiego Feb 2, 2020
09174ab
Fix package-lock
sampaiodiego Feb 2, 2020
8d4c00d
update package-lock.json
ggazzo Feb 3, 2020
e0c6d30
fix initialvalue state
ggazzo Feb 3, 2020
5074db9
typo
ggazzo Feb 3, 2020
f6b0919
Update action trigger format
d-gubert Feb 3, 2020
42e1bd7
fix close modals
ggazzo Feb 4, 2020
9486cad
Merge branch 'uikit' of github.com:RocketChat/Rocket.Chat into uikit
ggazzo Feb 4, 2020
89e1c8a
[IMPROVE] Show more information related to the Omnichannel room closi…
renatobecker Feb 2, 2020
7e7a6f2
[NEW] Check the Omnichannel service status per Department (#16425)
renatobecker Feb 3, 2020
7f73312
Regression: Fix status bar margins (#16438)
ggazzo Feb 3, 2020
279d175
[NEW] Setting to only send plain text emails (#16065)
rodrigok Feb 3, 2020
97df5c0
[FIX] Option to make a channel default (#16433)
Feb 3, 2020
a56dc74
Regression: recent opened rooms being marked as read (#16442)
ggazzo Feb 3, 2020
801e74c
[NEW] Sort the Omnichannel Chat list according to the user preference…
renatobecker Feb 3, 2020
1bc02e8
Use GitHub Actions to store builds (#16443)
sampaiodiego Feb 3, 2020
b8d423c
[IMPROVE] Log as info level when Method Rate Limiters are reached (#1…
rodrigok Feb 3, 2020
4c747cf
Update with error messages
d-gubert Feb 4, 2020
5982e42
Merge branch 'develop' into uikit
sampaiodiego Feb 4, 2020
e394639
Remove npm
sampaiodiego Feb 4, 2020
2fc7d50
Merge remote-tracking branch 'origin/develop' into uikit
d-gubert Feb 4, 2020
fc5281c
Change endpoint
sampaiodiego Feb 4, 2020
3b5b67d
Merge branch 'uikit' of github.com:RocketChat/Rocket.Chat into uikit
d-gubert Feb 4, 2020
228913d
oncancel event
ggazzo Feb 4, 2020
f501bf1
Merge branch 'uikit' of github.com:RocketChat/Rocket.Chat into uikit
ggazzo Feb 4, 2020
6e92a4f
Merge branch 'uikit' of github.com:RocketChat/Rocket.Chat into uikit
d-gubert Feb 4, 2020
e192f80
Redirect the modal_close event to the App
d-gubert Feb 4, 2020
4894e1f
close outside modal
ggazzo Feb 4, 2020
69b72ce
Merge branch 'uikit' of github.com:RocketChat/Rocket.Chat into uikit
ggazzo Feb 4, 2020
ce82488
Merge remote-tracking branch 'origin/develop' into uikit
d-gubert Feb 4, 2020
1b32f93
Fix package-lock
d-gubert Feb 4, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions app/api/server/v1/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ API.v1.addRoute('commands.list', { authRequired: true }, {
},
});

// Expects a body of: { command: 'gimme', params: 'any string value', roomId: 'value' }
// Expects a body of: { command: 'gimme', params: 'any string value', roomId: 'value', triggerId: 'value' }
API.v1.addRoute('commands.run', { authRequired: true }, {
post() {
const body = this.bodyParams;
Expand All @@ -74,7 +74,7 @@ API.v1.addRoute('commands.run', { authRequired: true }, {
}

const cmd = body.command.toLowerCase();
if (!slashCommands.commands[body.command.toLowerCase()]) {
if (!slashCommands.commands[cmd]) {
return API.v1.failure('The command provided does not exist (or is disabled).');
}

Expand All @@ -96,7 +96,9 @@ API.v1.addRoute('commands.run', { authRequired: true }, {
message.tmid = body.tmid;
}

const result = Meteor.runAsUser(user._id, () => slashCommands.run(cmd, params, message));
const { triggerId } = body;

const result = Meteor.runAsUser(user._id, () => slashCommands.run(cmd, params, message, triggerId));

return API.v1.success({ result });
},
Expand Down Expand Up @@ -137,7 +139,7 @@ API.v1.addRoute('commands.preview', { authRequired: true }, {

return API.v1.success({ preview });
},
// Expects a body format of: { command: 'giphy', params: 'mine', roomId: 'value', previewItem: { id: 'sadf8' type: 'image', value: 'https://dev.null/gif } }
// Expects a body format of: { command: 'giphy', params: 'mine', roomId: 'value', tmid: 'value', triggerId: 'value', previewItem: { id: 'sadf8' type: 'image', value: 'https://dev.null/gif' } }
post() {
const body = this.bodyParams;
const user = this.getLoggedInUser();
Expand All @@ -162,6 +164,14 @@ API.v1.addRoute('commands.preview', { authRequired: true }, {
return API.v1.failure('The preview item being executed is in the wrong format.');
}

if (body.tmid && typeof body.tmid !== 'string') {
return API.v1.failure('The tmid parameter when provided must be a string.');
}

if (body.triggerId && typeof body.triggerId !== 'string') {
return API.v1.failure('The triggerId parameter when provided must be a string.');
}

const cmd = body.command.toLowerCase();
if (!slashCommands.commands[cmd]) {
return API.v1.failure('The command provided does not exist (or is disabled).');
Expand All @@ -171,9 +181,24 @@ API.v1.addRoute('commands.preview', { authRequired: true }, {
Meteor.call('canAccessRoom', body.roomId, user._id);

const params = body.params ? body.params : '';
const message = {
rid: body.roomId,
};

if (body.tmid) {
const thread = Messages.findOneById(body.tmid);
if (!thread || thread.rid !== body.roomId) {
return API.v1.failure('Invalid thread.');
}
message.tmid = body.tmid;
}

Meteor.runAsUser(user._id, () => {
Meteor.call('executeSlashCommandPreview', { cmd, params, msg: { rid: body.roomId } }, body.previewItem);
Meteor.call('executeSlashCommandPreview', {
cmd,
params,
msg: { rid: body.roomId, tmid: body.tmid },
}, body.previewItem, body.triggerId);
});

return API.v1.success();
Expand Down
6 changes: 6 additions & 0 deletions app/apps/server/bridges/bridges.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { AppSettingBridge } from './settings';
import { AppUserBridge } from './users';
import { AppLivechatBridge } from './livechat';
import { AppUploadBridge } from './uploads';
import { UiInteractionBridge } from './uiInteraction';

export class RealAppBridges extends AppBridges {
constructor(orch) {
Expand All @@ -35,6 +36,7 @@ export class RealAppBridges extends AppBridges {
this._userBridge = new AppUserBridge(orch);
this._livechatBridge = new AppLivechatBridge(orch);
this._uploadBridge = new AppUploadBridge(orch);
this._uiInteractionBridge = new UiInteractionBridge(orch);
}

getCommandBridge() {
Expand Down Expand Up @@ -96,4 +98,8 @@ export class RealAppBridges extends AppBridges {
getUploadBridge() {
return this._uploadBridge;
}

getUiInteractionBridge() {
return this._uiInteractionBridge;
}
}
9 changes: 7 additions & 2 deletions app/apps/server/bridges/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class AppCommandsBridge {
this._verifyCommand(command);

const item = {
appId,
command: command.command.toLowerCase(),
params: Utilities.getI18nKeyForApp(command.i18nParamsExample, appId),
description: Utilities.getI18nKeyForApp(command.i18nDescription, appId),
Expand Down Expand Up @@ -145,7 +146,7 @@ export class AppCommandsBridge {
}
}

_appCommandExecutor(command, parameters, message) {
_appCommandExecutor(command, parameters, message, triggerId) {
const user = this.orch.getConverters().get('users').convertById(Meteor.userId());
const room = this.orch.getConverters().get('rooms').convertById(message.rid);
const threadId = message.tmid;
Expand All @@ -156,7 +157,9 @@ export class AppCommandsBridge {
Object.freeze(room),
Object.freeze(params),
threadId,
triggerId,
);

Promise.await(this.orch.getManager().getCommandManager().executeCommand(command, context));
}

Expand All @@ -175,7 +178,7 @@ export class AppCommandsBridge {
return Promise.await(this.orch.getManager().getCommandManager().getPreviews(command, context));
}

_appCommandPreviewExecutor(command, parameters, message, preview) {
_appCommandPreviewExecutor(command, parameters, message, preview, triggerId) {
const user = this.orch.getConverters().get('users').convertById(Meteor.userId());
const room = this.orch.getConverters().get('rooms').convertById(message.rid);
const threadId = message.tmid;
Expand All @@ -186,7 +189,9 @@ export class AppCommandsBridge {
Object.freeze(room),
Object.freeze(params),
threadId,
triggerId,
);

Promise.await(this.orch.getManager().getCommandManager().executePreview(command, preview, context));
}
}
11 changes: 11 additions & 0 deletions app/apps/server/bridges/listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ export class AppListenerBridge {
// }
}

async uiKitInteractionEvent(inte, action) {
return this.orch.getManager().getListenerManager().executeListener(inte, action);

// try {

// } catch (e) {
// this.orch.debugLog(`${ e.name }: ${ e.message }`);
// this.orch.debugLog(e.stack);
// }
}

async livechatEvent(inte, room) {
const rm = this.orch.getConverters().get('rooms').convertRoom(room);
const result = await this.orch.getManager().getListenerManager().executeListener(inte, rm);
Expand Down
13 changes: 13 additions & 0 deletions app/apps/server/bridges/uiInteraction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Notifications } from '../../../notifications/server';

export class UiInteractionBridge {
constructor(orch) {
this.orch = orch;
}

async notifyUser(user, interaction, appId) {
this.orch.debugLog(`The App ${ appId } is sending an interaction to user.`);

Notifications.notifyUser(user.id, 'uiInteraction', interaction);
}
}
11 changes: 3 additions & 8 deletions app/apps/server/communication/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { AppMethods } from './methods';
import { AppsRestApi } from './rest';
import { AppEvents, AppServerNotifier, AppServerListener } from './websockets';
import { AppUIKitInteractionApi } from './uikit';
import { AppEvents, AppServerListener, AppServerNotifier } from './websockets';

export {
AppMethods,
AppsRestApi,
AppEvents,
AppServerNotifier,
AppServerListener,
};
export { AppUIKitInteractionApi, AppMethods, AppsRestApi, AppEvents, AppServerNotifier, AppServerListener };
159 changes: 159 additions & 0 deletions app/apps/server/communication/uikit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import express from 'express';
import { WebApp } from 'meteor/webapp';
import { UIKitIncomingInteractionType } from '@rocket.chat/apps-engine/definition/uikit';

import { Users } from '../../../models/server';

const apiServer = express();

apiServer.disable('x-powered-by');

WebApp.connectHandlers.use(apiServer);

// eslint-disable-next-line new-cap
const router = express.Router();

const unauthorized = (res) =>
res.status(401).send({
status: 'error',
message: 'You must be logged in to do this.',
});

router.use((req, res, next) => {
const {
'x-user-id': userId,
'x-auth-token': authToken,
} = req.headers;

if (!userId || !authToken) {
return unauthorized(res);
}

const user = Users.findOneByIdAndLoginToken(userId, authToken);
if (!user) {
return unauthorized(res);
}

req.user = user;
req.userId = user._id;

next();
});

apiServer.use('/api/apps/ui.interaction/', router);

export class AppUIKitInteractionApi {
constructor(orch) {
this.orch = orch;

router.post('/:appId', (req, res) => {
const {
appId,
} = req.params;

const {
type,
} = req.body;

switch (type) {
case UIKitIncomingInteractionType.BLOCK: {
const {
type,
actionId,
triggerId,
mid,
rid,
payload,
} = req.body;

const room = this.orch.getConverters().get('rooms').convertById(rid);
const user = this.orch.getConverters().get('users').convertToApp(req.user);
const message = mid && this.orch.getConverters().get('messages').convertById(mid);

const action = {
type,
appId,
actionId,
message,
triggerId,
payload,
user,
room,
};

try {
const result = Promise.await(this.orch.getBridges().getListenerBridge().uiKitInteractionEvent('IUIKitInteractionHandler', action));

res.send(result);
} catch (e) {
res.status(500).send(e.message);
}
break;
}

case UIKitIncomingInteractionType.VIEW_CLOSED: {
const {
type,
actionId,
view,
isCleared,
} = req.body;

const user = this.orch.getConverters().get('users').convertToApp(req.user);

const action = {
type,
appId,
actionId,
user,
payload: {
view,
isCleared,
},
};

try {
Promise.await(this.orch.getBridges().getListenerBridge().uiKitInteractionEvent('IUIKitInteractionHandler', action));

res.send(200);
} catch (e) {
console.log(e);
res.status(500).send(e.message);
}
break;
}

case UIKitIncomingInteractionType.VIEW_SUBMIT: {
const {
type,
actionId,
triggerId,
payload,
} = req.body;

const user = this.orch.getConverters().get('users').convertToApp(req.user);

const action = {
type,
appId,
actionId,
triggerId,
payload,
user,
};

try {
const result = Promise.await(this.orch.getBridges().getListenerBridge().uiKitInteractionEvent('IUIKitInteractionHandler', action));

res.send(result);
} catch (e) {
res.status(500).send(e.message);
}
break;
}
}

// TODO: validate payloads per type
});
}
}
2 changes: 2 additions & 0 deletions app/apps/server/converters/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class AppMessagesConverter {
customFields: 'customFields',
groupable: 'groupable',
token: 'token',
blocks: 'blocks',
room: (message) => {
const result = this.orch.getConverters().get('rooms').convertById(message.rid);
delete message.rid;
Expand Down Expand Up @@ -135,6 +136,7 @@ export class AppMessagesConverter {
attachments,
reactions: message.reactions,
parseUrls: message.parseUrls,
blocks: message.blocks,
token: message.token,
};

Expand Down
Loading