Skip to content

Commit fc01082

Browse files
Danny Smithcdupuis
Danny Smith
authored andcommitted
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]
1 parent 8e28e04 commit fc01082

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

lib/handlers/command/slack/LinkRepo.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2018 Atomist, Inc.
2+
* Copyright © 2019 Atomist, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -115,7 +115,7 @@ export class LinkRepo implements HandleCommand {
115115
return ctx.messageClient.respond(err)
116116
.then(() => Success, failure);
117117
}
118-
if (isSlack(this.channelId) && !isChannel(this.channelId)) {
118+
if (!isChannel(this.channelId)) {
119119
const err = "The Atomist Bot can only link repositories to public or private channels. " +
120120
"Please try again in a public or private channel.";
121121
return ctx.messageClient.addressChannels(err, this.channelName)

lib/util/slack.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2018 Atomist, Inc.
2+
* Copyright © 2019 Atomist, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,10 @@
2222
* @return true if the channel is a public channel
2323
*/
2424
export function isChannel(id: string): boolean {
25-
return id.indexOf("C") === 0 || id.indexOf("G") === 0;
25+
if (isSlack(id)) {
26+
return id.indexOf("C") === 0 || id.indexOf("G") === 0;
27+
}
28+
return true;
2629
}
2730

2831
/**
@@ -38,4 +41,4 @@ export function isChannel(id: string): boolean {
3841
*/
3942
export function isSlack(id: string): boolean {
4043
return !id.includes("skype");
41-
}
44+
}

test/util/slack.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ describe("slack", () => {
4848
});
4949
});
5050

51+
it("should accept any MS Team channel ID", () => {
52+
assert(isChannel("12:[email protected]"));
53+
});
54+
5155
});
5256

5357
describe("checkIsSlack", () => {

0 commit comments

Comments
 (0)