-
Notifications
You must be signed in to change notification settings - Fork 73
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
User correct Matrix accounts when redacting events #780
Changes from 2 commits
d3a719d
2443e46
dd11c2a
b4f2911
e2df892
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,8 +291,29 @@ export class SlackEventHandler extends BaseSlackHandler { | |
} else if (msg.subtype === "message_deleted" && msg.deleted_ts) { | ||
const originalEvent = await this.main.datastore.getEventBySlackId(msg.channel, msg.deleted_ts); | ||
if (originalEvent) { | ||
const botClient = this.main.botIntent.matrixClient; | ||
await botClient.redactEvent(originalEvent.roomId, originalEvent.eventId); | ||
const previousMessage = msg.previous_message; | ||
if (!previousMessage) { | ||
log.error("Cannot delete message with no previous_message:", msg); | ||
return; | ||
} | ||
if (previousMessage.subtype === 'bot_message') { | ||
// Sent from Matrix, try to remove it with our bot account | ||
tadzik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try { | ||
const botClient = this.main.botIntent.matrixClient; | ||
await botClient.redactEvent(originalEvent.roomId, originalEvent.eventId, "Deleted on Slack"); | ||
} catch (err) { | ||
log.error("Failed to remove message", previousMessage, "with our Matrix bot: insufficient power level? Error:", err); | ||
return; | ||
} | ||
} | ||
else if (!previousMessage.user) { | ||
log.error("Cannot redact Slack message if we don't know the original sender:", previousMessage); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we just use the botClient? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in b4f2911; this has a side effect of us trying to delete messages sent by originally-Matrix users with the slack bot – which probably makes sense. |
||
return; | ||
} | ||
else { | ||
const ghost = await this.main.ghostStore.get(previousMessage.user, previousMessage.team_domain, previousMessage.team); | ||
await ghost.redactEvent(originalEvent.roomId, originalEvent.eventId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we try with the botClient if this fails, as a fallback? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in b4f2911 |
||
} | ||
return; | ||
} | ||
// If we don't have the event | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not actually seen
team_id
in incoming Slack messages, and the only place I see it used is when it's artificially assigned to in SlackRTMHandler – perhaps it's an error in our typing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really remember when this was introduced, it's possible it's invalid and team_id is the right one.