Skip to content

Commit

Permalink
add type for discussion in api params
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhsherl committed Jul 15, 2019
1 parent 4c9c89e commit 1bf9287
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/api/server/v1/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ API.v1.addRoute('rooms.leave', { authRequired: true }, {

API.v1.addRoute('rooms.createDiscussion', { authRequired: true }, {
post() {
const { prid, pmid, reply, t_name, users } = this.bodyParams;
const { prid, pmid, reply, t_name, users, t } = this.bodyParams;
if (!prid) {
return API.v1.failure('Body parameter "prid" is required.');
}
Expand All @@ -238,6 +238,7 @@ API.v1.addRoute('rooms.createDiscussion', { authRequired: true }, {
pmid,
t_name,
reply,
t,
users: users || [],
}));

Expand Down
12 changes: 7 additions & 5 deletions app/discussion/server/methods/createDiscussion.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const mentionMessage = (rid, { _id, username, name }, message_embedded) => {
return Messages.insert(welcomeMessage);
};

const create = ({ prid, pmid, t_name, reply, users }) => {
const create = ({ prid, pmid, t_name, reply, t, users }) => {
// if you set both, prid and pmid, and the rooms doesnt match... should throw an error)
let message = false;
if (pmid) {
Expand Down Expand Up @@ -86,8 +86,10 @@ const create = ({ prid, pmid, t_name, reply, users }) => {
// auto invite the replied message owner
const invitedUsers = message ? [message.u.username, ...users] : users;

// discussions are always created as private groups
const discussion = createRoom('p', name, user.username, [...new Set(invitedUsers)], false, {
// discussions are created as private groups, if t is not given as 'c'
const type = t === 'c' ? 'c' : 'p';

const discussion = createRoom(type, name, user.username, [...new Set(invitedUsers)], false, {
fname: t_name,
description: message.msg, // TODO discussions remove
topic: p_room.name, // TODO discussions remove
Expand Down Expand Up @@ -121,7 +123,7 @@ Meteor.methods({
* @param {string} t_name - discussion name
* @param {string[]} users - users to be added
*/
createDiscussion({ prid, pmid, t_name, reply, users }) {
createDiscussion({ prid, pmid, t_name, reply, t, users }) {
if (!settings.get('Discussion_enabled')) {
throw new Meteor.Error('error-action-not-allowed', 'You are not allowed to create a discussion', { method: 'createDiscussion' });
}
Expand All @@ -135,6 +137,6 @@ Meteor.methods({
throw new Meteor.Error('error-action-not-allowed', 'You are not allowed to create a discussion', { method: 'createDiscussion' });
}

return create({ uid, prid, pmid, t_name, reply, users });
return create({ uid, prid, pmid, t_name, reply, t, users });
},
});

0 comments on commit 1bf9287

Please sign in to comment.