Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into adm/…
Browse files Browse the repository at this point in the history
…users_and_rooms

* 'develop' of github.com:RocketChat/Rocket.Chat:
  Bump https-proxy-agent from 2.2.1 to 2.2.4 (#17323)
  [NEW] Adds ability for Rocket.Chat Apps to create discussions (#16683)
  Add possibility to sort the Omnichannel current chats list by column (#17347)
  [IMPROVE] Redesign Administration > Import (#17289)
  • Loading branch information
gabriellsh committed Apr 18, 2020
2 parents 60beb92 + a9e95fe commit 3855ca5
Show file tree
Hide file tree
Showing 39 changed files with 1,331 additions and 1,166 deletions.
3 changes: 2 additions & 1 deletion .storybook/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@babel/preset-flow"
],
"plugins": [
"@babel/plugin-proposal-class-properties"
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-optional-chaining"
]
}
8 changes: 2 additions & 6 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { withKnobs } from '@storybook/addon-knobs';
import { MINIMAL_VIEWPORTS, INITIAL_VIEWPORTS } from '@storybook/addon-viewport/dist/defaults';
import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport/dist/defaults';
import { addDecorator, addParameters, configure } from '@storybook/react';

import { rocketChatDecorator } from './mocks/decorators';

addParameters({
viewport: {
viewports: {
...MINIMAL_VIEWPORTS,
...INITIAL_VIEWPORTS,
},
defaultViewport: 'responsive',
viewports: MINIMAL_VIEWPORTS,
},
});

Expand Down
35 changes: 33 additions & 2 deletions app/apps/server/bridges/rooms.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
import { Meteor } from 'meteor/meteor';

import { Rooms, Subscriptions, Users } from '../../../models/server';
import { addUserToRoom } from '../../../lib/server/functions/addUserToRoom';
import { Rooms, Subscriptions, Users } from '../../../models/server';

export class AppRoomBridge {
constructor(orch) {
Expand Down Expand Up @@ -120,4 +120,35 @@ export class AppRoomBridge {
addUserToRoom(rm._id, member);
}
}

async createDiscussion(room, parentMessage = null, reply = '', members = [], appId) {
this.orch.debugLog(`The App ${ appId } is creating a new discussion.`, room);

const rcRoom = this.orch.getConverters().get('rooms').convertAppRoom(room);

let rcMessage;
if (parentMessage) {
rcMessage = this.orch.getConverters().get('messages').convertAppMessage(parentMessage);
}

if (!rcRoom.prid || !Rooms.findOneById(rcRoom.prid)) {
throw new Error('There must be a parent room to create a discussion.');
}

const discussion = {
prid: rcRoom.prid,
t_name: rcRoom.fname,
pmid: rcMessage ? rcMessage._id : undefined,
reply: reply && reply.trim() !== '' ? reply : undefined,
users: members.length > 0 ? members : [],
};

let rid;
Meteor.runAsUser(room.creator.id, () => {
const info = Meteor.call('createDiscussion', discussion);
rid = info.rid;
});

return rid;
}
}
11 changes: 11 additions & 0 deletions app/apps/server/converters/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class AppRoomsConverter {
closedAt: room.closedAt,
lm: room.lastModifiedAt,
customFields: room.customFields,
prid: typeof room.parentRoom === 'undefined' ? undefined : room.parentRoom.id,
};

return Object.assign(newRoom, room._unmappedProperties_);
Expand Down Expand Up @@ -195,7 +196,17 @@ export class AppRoomsConverter {

return this.orch.getConverters().get('users').convertById(responseBy._id);
},
parentRoom: (room) => {
const { prid } = room;

if (!prid) {
return undefined;
}

delete room.prid;

return this.orch.getConverters().get('rooms').convertById(prid);
},
};

return transformMappedData(room, map);
Expand Down
55 changes: 0 additions & 55 deletions app/importer/client/admin/adminImport.html

This file was deleted.

136 changes: 0 additions & 136 deletions app/importer/client/admin/adminImport.js

This file was deleted.

83 changes: 0 additions & 83 deletions app/importer/client/admin/adminImportNew.html

This file was deleted.

Loading

0 comments on commit 3855ca5

Please sign in to comment.