From fc01082886b3bf434555328ee42490e1713ff36c Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Tue, 21 May 2019 07:45:35 +0100 Subject: [PATCH] Auto merge pull request #4 from atomist/sdm-pack-lifecycle * Modify isChannel to always return true for any MSTeams channel id Retains current behavior for Slack channel ids. * Autofix: TypeScript header [atomist:generated] [atomist:autofix=typescript_header] --- lib/handlers/command/slack/LinkRepo.ts | 4 ++-- lib/util/slack.ts | 9 ++++++--- test/util/slack.test.ts | 4 ++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/handlers/command/slack/LinkRepo.ts b/lib/handlers/command/slack/LinkRepo.ts index 0e17283..7d4ccdc 100644 --- a/lib/handlers/command/slack/LinkRepo.ts +++ b/lib/handlers/command/slack/LinkRepo.ts @@ -1,5 +1,5 @@ /* - * Copyright © 2018 Atomist, Inc. + * Copyright © 2019 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -115,7 +115,7 @@ export class LinkRepo implements HandleCommand { return ctx.messageClient.respond(err) .then(() => Success, failure); } - if (isSlack(this.channelId) && !isChannel(this.channelId)) { + if (!isChannel(this.channelId)) { const err = "The Atomist Bot can only link repositories to public or private channels. " + "Please try again in a public or private channel."; return ctx.messageClient.addressChannels(err, this.channelName) diff --git a/lib/util/slack.ts b/lib/util/slack.ts index 41c4de5..80055a3 100644 --- a/lib/util/slack.ts +++ b/lib/util/slack.ts @@ -1,5 +1,5 @@ /* - * Copyright © 2018 Atomist, Inc. + * Copyright © 2019 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,10 @@ * @return true if the channel is a public channel */ export function isChannel(id: string): boolean { - return id.indexOf("C") === 0 || id.indexOf("G") === 0; + if (isSlack(id)) { + return id.indexOf("C") === 0 || id.indexOf("G") === 0; + } + return true; } /** @@ -38,4 +41,4 @@ export function isChannel(id: string): boolean { */ export function isSlack(id: string): boolean { return !id.includes("skype"); -} +} \ No newline at end of file diff --git a/test/util/slack.test.ts b/test/util/slack.test.ts index e5f805d..0ad6f19 100644 --- a/test/util/slack.test.ts +++ b/test/util/slack.test.ts @@ -48,6 +48,10 @@ describe("slack", () => { }); }); + it("should accept any MS Team channel ID", () => { + assert(isChannel("12:a347e001ebcd4f02ab3a086c1ddb0a03@thread.skype")); + }); + }); describe("checkIsSlack", () => {