Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team sync changes #23

Merged
merged 30 commits into from
Nov 17, 2023
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
caeb355
notify us admins in admin room about a deleted slack channel
ashfame Sep 29, 2023
7b831ab
notify us admins in admin room when bridge boots up
ashfame Sep 29, 2023
224fdb8
add bridged room id to notification message upon slack channel deletion
ashfame Oct 9, 2023
556b146
ensure rooms are created by super admin user, creator is only a mod a…
ashfame Oct 9, 2023
bdff14a
remove super_admin_user field in config and add rooms field under tea…
ashfame Oct 10, 2023
9f3f6c0
change hint message when new slack channel is created
ashfame Oct 10, 2023
c274bee
fix bug with membership sync logic
ashfame Oct 10, 2023
17505ea
handle channel_archive event
ashfame Oct 10, 2023
fe1627b
dedupe code from archive/deletion channel handlers
ashfame Oct 10, 2023
f77f12a
account for inconsistent event handling for channel_archive event
ashfame Oct 11, 2023
6570485
subscribe to member_left_channel event
ashfame Oct 11, 2023
e184ded
subscribe to channel_archive event as well
ashfame Oct 11, 2023
d902cdd
Revert "account for inconsistent event handling for channel_archive e…
ashfame Oct 11, 2023
d2fb55d
fix event name
ashfame Oct 11, 2023
e520141
notify us when a new bridged room is created upon a new slack channel…
ashfame Oct 12, 2023
e8035fb
disable updating ghost users upon each slack message when team sync i…
ashfame Oct 13, 2023
053c816
better var name
ashfame Oct 17, 2023
afb7a9d
move notifyAdmins func to Main
ashfame Oct 17, 2023
c087416
Update src/TeamSyncer.ts
ashfame Oct 17, 2023
bf0c565
Update src/TeamSyncer.ts
ashfame Oct 17, 2023
7bee73b
Update src/TeamSyncer.ts
ashfame Oct 17, 2023
c4f22ac
Update src/TeamSyncer.ts
ashfame Oct 17, 2023
0dfbb4f
improve performance of membership sync at boot
ashfame Oct 17, 2023
fb909d7
move power levels code a bit above
ashfame Oct 17, 2023
fcbe71b
improve code organisation in createRoomForChannel
ashfame Oct 17, 2023
12c63a0
notify us if unlinking fails, so that we can manually act
ashfame Oct 17, 2023
1db0e5a
define new method on fakeDatastore for tests to pass
ashfame Oct 17, 2023
e002c3b
log if fails to notify admins, makes integration test pass
ashfame Oct 17, 2023
88963fe
document team sync modifications in readme
ashfame Oct 18, 2023
28f6b85
move readme section
ashfame Oct 18, 2023
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
53 changes: 16 additions & 37 deletions src/TeamSyncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,35 +375,8 @@ export class TeamSyncer {
return;
}

// notify admins
if (this.adminRoom) {
await this.main.botIntent.sendMessage(this.adminRoom, {
msgtype: "m.notice",
body: `${teamId} removed channel ${channelId}, bridged room: ${room.MatrixRoomId}`,
});
}

try {
await this.main.botIntent.sendMessage(room.MatrixRoomId, {
msgtype: "m.notice",
body: "The Slack channel bridged to this room has been deleted.",
});
} catch (ex) {
log.warn("Failed to send deletion notice into the room:", ex);
}

// Hide deleted channels in the room directory.
try {
await this.main.botIntent.setRoomDirectoryVisibility(room.MatrixRoomId, "private");
} catch (ex) {
log.warn("Failed to hide room from the room directory:", ex);
}

try {
await this.main.actionUnlink({ matrix_room_id: room.MatrixRoomId });
} catch (ex) {
log.warn("Tried to unlink room but failed:", ex);
}
await this.notifyAdmins(`${teamId} removed channel ${channelId}, bridged room: ${room.MatrixRoomId}`);
await this.shutDownBridgedRoom("deleted", room.MatrixRoomId);
ashfame marked this conversation as resolved.
Show resolved Hide resolved
}

public async onChannelArchived(teamId: string, channelId: string): Promise<void> {
Expand All @@ -417,32 +390,38 @@ export class TeamSyncer {
return;
}

// notify admins
await this.notifyAdmins(`${teamId} archived channel ${channelId}, bridged room: ${room.MatrixRoomId}`);
await this.shutDownBridgedRoom("archived", room.MatrixRoomId);
ashfame marked this conversation as resolved.
Show resolved Hide resolved
}

public async notifyAdmins(message: string) {
if (this.adminRoom) {
await this.main.botIntent.sendMessage(this.adminRoom, {
msgtype: "m.notice",
body: `${teamId} archived channel ${channelId}, bridged room: ${room.MatrixRoomId}`,
body: message,
});
}
}

public async shutDownBridgedRoom(reason: string, roomId: string) {
try {
await this.main.botIntent.sendMessage(room.MatrixRoomId, {
await this.main.botIntent.sendMessage(roomId, {
msgtype: "m.notice",
body: "The Slack channel bridged to this room has been archived.",
body: `The Slack channel bridged to this room has been \`${reason}\`.`,
ashfame marked this conversation as resolved.
Show resolved Hide resolved
});
} catch (ex) {
log.warn("Failed to send archived notice into the room:", ex);
log.warn(`Failed to send \`${reason}\` notice into the room:`, ex);
ashfame marked this conversation as resolved.
Show resolved Hide resolved
}

// Hide deleted channels in the room directory.
// Hide from room directory.
try {
await this.main.botIntent.setRoomDirectoryVisibility(room.MatrixRoomId, "private");
await this.main.botIntent.setRoomDirectoryVisibility(roomId, "private");
} catch (ex) {
log.warn("Failed to hide room from the room directory:", ex);
}

try {
await this.main.actionUnlink({ matrix_room_id: room.MatrixRoomId });
await this.main.actionUnlink({ matrix_room_id: roomId });
} catch (ex) {
log.warn("Tried to unlink room but failed:", ex);
}
Expand Down
Loading