Skip to content

Commit

Permalink
Fixed #991 - multiple add user calls being made
Browse files Browse the repository at this point in the history
  • Loading branch information
justinwilaby committed Oct 26, 2018
1 parent e71a384 commit 24bb069
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions packages/app/main/src/services/conversationService.spec.ts
Expand Up @@ -40,8 +40,9 @@ describe('The ConversationService should call "fetch" with the expected paramete
expect(headers instanceof nodeFetch.Headers).toBeTruthy();
expect(headers === headers).toBeTruthy();
expect(method).toBe('POST');
expect(body[0].name).toBeFalsy();
expect(body[0].id).toBeFalsy();
const members = JSON.parse(body);
expect(members[0].name).toBeFalsy();
expect(members[0].id).toBeFalsy();
expect(headersInstance).toEqual(headers);
});

Expand All @@ -54,7 +55,8 @@ describe('The ConversationService should call "fetch" with the expected paramete
expect(headers instanceof nodeFetch.Headers).toBeTruthy();
expect(headers === headers).toBeTruthy();
expect(method).toBe('DELETE');
expect(body[0].id).toBe('1234');
const users = JSON.parse(body);
expect(users[0].id).toBe('1234');
expect(headersInstance).toEqual(headers);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/app/main/src/services/conversationService.ts
Expand Up @@ -11,7 +11,7 @@ export class ConversationService {
return fetch(url, {
headers,
method: 'POST',
body: [{ name, id }]
body: JSON.stringify([{ name, id }])
});
}

Expand All @@ -20,7 +20,7 @@ export class ConversationService {
return fetch(url, {
headers,
method: 'DELETE',
body: [{ id }]
body: JSON.stringify([{ id }])
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/emulator/core/package.json
Expand Up @@ -8,7 +8,7 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "babel ./src --out-dir lib --extensions \".ts,.tsx\" --ignore \"**/*.spec.ts\" && tsc --emitDeclarationOnly --declaration",
"build": "babel ./src --out-dir lib --extensions \".ts,.tsx\" --ignore \"**/*.spec.ts\" --source-maps inline && tsc --emitDeclarationOnly --declaration",
"build:watch": "npm run build:prod --outdir lib --watch",
"clean": "rimraf lib",
"lint": "tslint --project tslint.json",
Expand Down
2 changes: 1 addition & 1 deletion packages/emulator/core/src/emulator/middleware/addUsers.ts
Expand Up @@ -42,7 +42,7 @@ import { ConversationAware } from './fetchConversation';
export default function addUsers(_botEmulator: BotEmulator) {
return async (req: ConversationAware, res: Restify.Response, next: Restify.Next): Promise<any> => {
try {
const members: ChannelAccount[] = req.body;
const members: ChannelAccount[] = JSON.parse(req.body || '[]');
const it = members[Symbol.iterator](); // Node does not support array.values() :(
let member;
while (member = it.next().value) {
Expand Down

0 comments on commit 24bb069

Please sign in to comment.