Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/756.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue that caused channel name to not be displayed in the list command output.
2 changes: 1 addition & 1 deletion src/AdminCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class AdminCommands {
}

const slack = r.SlackChannelId ?
`${channelName} (${r.SlackChannelId})` :
`#${channelName} (${r.SlackChannelId})` :
channelName;

let status = r.getStatus();
Expand Down
2 changes: 1 addition & 1 deletion src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ export class Main {
}

let channelInfo: ConversationsInfoResponse|undefined;
if (slackClient && opts.slack_channel_id && opts.team_id) {
if (slackClient && opts.slack_channel_id) {
// PSA: Bots cannot join channels, they have a limited set of APIs https://api.slack.com/methods/bots.info

channelInfo = (await slackClient.conversations.info({ channel: opts.slack_channel_id})) as ConversationsInfoResponse;
Expand Down
21 changes: 12 additions & 9 deletions src/SlackEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ const log = new Logger("SlackEventHandler");
/**
* https://api.slack.com/events/channel_rename
*/
interface ISlackEventChannelRename extends ISlackEvent {
id: string;
name: string;
created: number;
interface ISlackEventChannelRename extends Omit<ISlackEvent, "channel"> {
channel: {
id: string;
name: string;
created: number;
}
}

/**
Expand Down Expand Up @@ -190,7 +192,10 @@ export class SlackEventHandler extends BaseSlackHandler {
await this.handleReaction(event as ISlackEventReaction, teamId);
break;
case "channel_rename":
await this.handleChannelRenameEvent(event as ISlackEventChannelRename);
// The rename event is not compatible with ISlackEvent because the channel property is an object,
// not a string. So we resort to casting to unknown first.
// TODO: Move channel property out of ISlackEvent, into each event type, where relevant.
await this.handleChannelRenameEvent((event as unknown) as ISlackEventChannelRename);
break;
case "team_domain_change":
await this.handleDomainChangeEvent(event as ISlackEventTeamDomainChange, teamId);
Expand Down Expand Up @@ -349,12 +354,10 @@ export class SlackEventHandler extends BaseSlackHandler {
}

private async handleChannelRenameEvent(event: ISlackEventChannelRename) {
// TODO test me. and do we even need this? doesn't appear to be used anymore
const room = this.main.rooms.getBySlackChannelId(event.id);
const room = this.main.rooms.getBySlackChannelId(event.channel.id);
if (!room) { throw new Error("unknown_channel"); }

const channelName = `#${event.name}`;
room.SlackChannelName = channelName;
room.SlackChannelName = event.channel.name;
if (room.isDirty) {
await this.main.datastore.upsertRoom(room);
}
Expand Down