handlematrix: Implement DeleteChatHandlingNetworkAPI (#122)

This commit is contained in:
Conan
2025-10-07 21:26:10 +08:00
committed by GitHub
parent 4410415776
commit b1f3c4c1db
3 changed files with 36 additions and 2 deletions
+27
View File
@@ -741,3 +741,30 @@ func (t *TelegramClient) senderForUserID(userID int64) bridgev2.EventSender {
Sender: ids.MakeUserID(userID),
}
}
func (t *TelegramClient) HandleMatrixDeleteChat(ctx context.Context, chat *bridgev2.MatrixDeleteChat) error {
peerType, id, err := ids.ParsePortalID(chat.Portal.ID)
if err != nil {
return err
}
switch peerType {
case ids.PeerTypeUser:
if chat.Content.DeleteForEveryone {
_, err := t.client.API().MessagesDeleteHistory(ctx, &tg.MessagesDeleteHistoryRequest{
Peer: &tg.InputPeerUser{UserID: id},
Revoke: true,
MaxID: 0,
})
if err != nil {
return err
}
}
_, err = t.client.API().MessagesDeleteChat(ctx, id)
if err != nil {
return err
}
default:
return fmt.Errorf("deleting chat not supported for peer type %s", peerType)
}
return nil
}