Skip to content

Commit

Permalink
Auto merge pull request #4 from atomist/sdm-pack-lifecycle
Browse files Browse the repository at this point in the history
* 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]
  • Loading branch information
dansmithy authored and cdupuis committed May 21, 2019
1 parent 8e28e04 commit fc01082
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/handlers/command/slack/LinkRepo.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions lib/util/slack.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
}

/**
Expand All @@ -38,4 +41,4 @@ export function isChannel(id: string): boolean {
*/
export function isSlack(id: string): boolean {
return !id.includes("skype");
}
}
4 changes: 4 additions & 0 deletions test/util/slack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ describe("slack", () => {
});
});

it("should accept any MS Team channel ID", () => {
assert(isChannel("12:a347e001ebcd4f02ab3a086c1ddb0a03@thread.skype"));
});

});

describe("checkIsSlack", () => {
Expand Down

0 comments on commit fc01082

Please sign in to comment.