Skip to content

Commit

Permalink
Merge pull request #33 from mrsimpson/hotfix-bundle/0.56.0-0.2.2
Browse files Browse the repository at this point in the history
Hotfix bundle/0.56.0 0.2.2
  • Loading branch information
ruKurz committed Jun 29, 2017
2 parents 10d95fa + 5dcf967 commit 9cb699a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<template name="AssistifyCreateChannel">
<div class="wrapper assistify-create-section">
<h4>{{_ "Requests" }}</h4>
{{> AssistifyCreateRequest}}
</div>
<div class="wrapper assistify-create-section">
<h4>{{_ "Expertises" }}</h4>
{{> AssistifyCreateExpertise}}
</div>
</template>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template name="AssistifyCreateExpertise">
{{#if canCreateExpertise}}
<h4>{{_ "Expertises" }}</h4>
<div class="input-line no-icon">
<span>{{_ "Expertise_title"}}</span>
<input type="text" id="expertise" dir="auto" placeholder="{{_ 'Enter_name_here'}}">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<template name="AssistifyCreateRequest">
<h4>{{_ "Requests" }}</h4>
<label class="color-tertiary-font-color" for="expertise-search">{{_ "New_request_for_expertise"}}</label>
<div class="input-line no-icon">
{{> inputAutocomplete settings=autocompleteExpertiseSettings id="expertise-search" class="search" autocomplete=off value=expertise}}
Expand Down
19 changes: 14 additions & 5 deletions packages/assistify-help-request/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class HelpRequestApi {

return new helpRequest.HelpDiscussionCreatedResponse(
HelpRequestApi.getUrlForRoom(creationResult.room),
creationResult.providers
creationResult.members
);
}

Expand Down Expand Up @@ -68,7 +68,10 @@ class HelpRequestApi {

if (potentialEmails.length > 0) {
potentialEmails.forEach((emailAddress) => {
users.push(RocketChat.models.Users.findOneByEmailAddress(emailAddress));
const matchedUser = RocketChat.models.Users.findOneByEmailAddress(emailAddress);
if (matchedUser) {
users.push(matchedUser);
}
});
// users = users.concat(
// RocketChat.models.Users.findByEmailAddresses(potentialEmails).fetch()
Expand All @@ -77,7 +80,10 @@ class HelpRequestApi {

if (potentialIds.length > 0) {
potentialIds.forEach((_id) => {
users.push(RocketChat.models.Users.findById(_id).fetch());
const matchedUser = RocketChat.models.Users.findById(_id).fetch();
if (matchedUser) {
users.push();
}
});
}

Expand Down Expand Up @@ -142,9 +148,12 @@ class HelpRequestApi {
throw new Meteor.Error(err);
}

const roomCreated = RocketChat.models.Rooms.findOne({_id: channel.rid});
return {
room: RocketChat.models.Rooms.findOne({_id: channel.rid}),
providers
room: roomCreated,
members: roomCreated.usernames.map((user) => {
return {username: user};
})
};
}
}
Expand Down
44 changes: 10 additions & 34 deletions packages/assistify-help-request/server/routes.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
/* globals Restivus */

/**
* Restful API endpoints for interaction with external systems
*/

import {helpRequest} from '../help-request';

const API = new Restivus({
apiPath: 'assistify/',
useDefaultAuth: true,
prettyJson: true
});


function keysToUpperCase(obj) {
for (const prop in obj) {
if (typeof obj[prop] === 'object') {
obj[prop] = keysToUpperCase(obj[prop]);
}
if (prop !== prop.toUpperCase()) {
obj[prop.toUpperCase()] = obj[prop];
delete obj[prop];
}
}
return obj;
}

function keysToLowerCase(obj) {
for (const prop in obj) {
if (typeof obj[prop] === 'object') {
obj[prop] = keysToLowerCase(obj[prop]);
}
if (prop !== prop.toLowerCase()) {
obj[prop.toLowerCase()] = obj[prop];
delete obj[prop];
if (obj.hasOwnProperty(prop)) {
if (typeof obj[prop] === 'object') {
obj[prop] = keysToLowerCase(obj[prop]);
}
if (prop !== prop.toLowerCase()) {
obj[prop.toLowerCase()] = obj[prop];
delete obj[prop];
}
}
}
return obj;
Expand Down Expand Up @@ -65,7 +45,7 @@ function preProcessBody(body) {
delete body['%heap'];
}

API.addRoute('helpDiscussion', {
RocketChat.API.v1.addRoute('assistify.helpDiscussion', {authRequired: true}, {
/**
* Creates a room with an initial question and adds users who could possibly help
* @see packages\rocketchat-api\server\routes.coffee
Expand All @@ -90,10 +70,6 @@ API.addRoute('helpDiscussion', {

const creationResult = api.processHelpDiscussionPostRequest(this.bodyParams);

return {
status_code: 200,
result: creationResult,
RESULT: keysToUpperCase(creationResult)
};
return creationResult;
}
});
5 changes: 3 additions & 2 deletions packages/assistify-help-request/server/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import {helpRequest} from '../help-request';

// Definition of value objects. No clue why export interface is not supported
class HelpDiscussionCreatedResponse {
constructor(url, providersJoined) {
constructor(url, members) {
this.success = true;
this.url = url;
this.providers_joined = providersJoined;
this.members = members;
}
}

Expand Down

0 comments on commit 9cb699a

Please sign in to comment.