handlematrix: add more checks to member handling

This commit is contained in:
Tulir Asokan
2026-05-02 00:14:19 +03:00
parent 5a363d3778
commit df7dee6edc
3 changed files with 13 additions and 6 deletions

View File

@@ -1392,6 +1392,8 @@ func (tc *TelegramClient) HandleMatrixMembership(ctx context.Context, msg *bridg
case bridgev2.Invite, bridgev2.AcceptKnock:
if targetInputUser == nil {
return nil, wrapUnsupportedError(fmt.Errorf("can't invite non-user peer type %s", targetPeerType))
} else if tc.metadata.IsBot {
return nil, wrapUnsupportedError(fmt.Errorf("can't invite users as a bot"))
}
_, err = tc.client.API().ChannelsInviteToChannel(ctx, &tg.ChannelsInviteToChannelRequest{
Channel: inputChannel,
@@ -1419,6 +1421,8 @@ func (tc *TelegramClient) HandleMatrixMembership(ctx context.Context, msg *bridg
case bridgev2.Invite, bridgev2.AcceptKnock:
if targetInputUser == nil {
return nil, wrapUnsupportedError(fmt.Errorf("can't invite non-user peer type %s", targetPeerType))
} else if tc.metadata.IsBot {
return nil, wrapUnsupportedError(fmt.Errorf("can't invite users as a bot"))
}
_, err = tc.client.API().MessagesAddChatUser(ctx, &tg.MessagesAddChatUserRequest{
ChatID: chatID,