mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00
Fix service bots not rejecting invites on incoming DMs (#659)
* Manually send a reason on a leave for now * changelog
This commit is contained in:
parent
55529d7128
commit
b8bb51fd1f
1
changelog.d/659.bugfix
Normal file
1
changelog.d/659.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix service bots not being able to reject invites with a reason.
|
@ -791,18 +791,24 @@ export class Bridge {
|
|||||||
// We got an invite but it's not a configured bot user, must be for a ghost user
|
// We got an invite but it's not a configured bot user, must be for a ghost user
|
||||||
log.debug(`Rejecting invite to room ${roomId} for ghost user ${invitedUserId}`);
|
log.debug(`Rejecting invite to room ${roomId} for ghost user ${invitedUserId}`);
|
||||||
const client = this.as.getIntentForUserId(invitedUserId).underlyingClient;
|
const client = this.as.getIntentForUserId(invitedUserId).underlyingClient;
|
||||||
return client.kickUser(invitedUserId, roomId, "Bridge does not support DMing ghosts");
|
return client.doRequest("POST", "/_matrix/client/v3/rooms/" + encodeURIComponent(roomId) + "/leave", null, {
|
||||||
|
reason: "Bridge does not support DMing ghosts"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't accept invites from people who can't do anything
|
// Don't accept invites from people who can't do anything
|
||||||
if (!this.config.checkPermissionAny(event.sender, BridgePermissionLevel.login)) {
|
if (!this.config.checkPermissionAny(event.sender, BridgePermissionLevel.login)) {
|
||||||
return botUser.intent.underlyingClient.kickUser(botUser.userId, roomId, "You do not have permission to invite this bot.");
|
return botUser.intent.underlyingClient.doRequest("POST", "/_matrix/client/v3/rooms/" + encodeURIComponent(roomId) + "/leave", null, {
|
||||||
|
reason: "You do not have permission to invite this bot."
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.content.is_direct && botUser.userId !== this.as.botUserId) {
|
if (event.content.is_direct && botUser.userId !== this.as.botUserId) {
|
||||||
// Service bots do not support direct messages (admin rooms)
|
// Service bots do not support direct messages (admin rooms)
|
||||||
log.debug(`Rejecting direct message (admin room) invite to room ${roomId} for service bot ${botUser.userId}`);
|
log.debug(`Rejecting direct message (admin room) invite to room ${roomId} for service bot ${botUser.userId}`);
|
||||||
return botUser.intent.underlyingClient.kickUser(botUser.userId, roomId, "This bot does not support admin rooms.");
|
return botUser.intent.underlyingClient.doRequest("POST", "/_matrix/client/v3/rooms/" + encodeURIComponent(roomId) + "/leave", null, {
|
||||||
|
reason: "This bot does not support admin rooms."
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accept the invite
|
// Accept the invite
|
||||||
|
Loading…
x
Reference in New Issue
Block a user