chat delete: bridge properly

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-10-09 11:17:51 -06:00
parent 03c7028460
commit 4205047aab
4 changed files with 19 additions and 3 deletions
+1 -1
View File
@@ -59,4 +59,4 @@ require (
rsc.io/qr v0.2.0 // indirect
)
replace github.com/gotd/td => github.com/beeper/td v0.107.1-0.20240925194934-90b1db6ce8fe
replace github.com/gotd/td => github.com/beeper/td v0.107.1-0.20241009171837-4aced54beeac
+2 -2
View File
@@ -2,8 +2,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
github.com/beeper/td v0.107.1-0.20240925194934-90b1db6ce8fe h1:Cmdu2TlAbJYA8JCRlalxMyAXnLjq6XNUppqgMdBummA=
github.com/beeper/td v0.107.1-0.20240925194934-90b1db6ce8fe/go.mod h1:mwQQQrrAn3wizT37UjBAUB4lTy1j2RHnkRJ4z9ivqGs=
github.com/beeper/td v0.107.1-0.20241009171837-4aced54beeac h1:mzdAAwOOC662v42tjFWtwdRdnVsZvPjEx8+PWlrZm3E=
github.com/beeper/td v0.107.1-0.20241009171837-4aced54beeac/go.mod h1:mwQQQrrAn3wizT37UjBAUB4lTy1j2RHnkRJ4z9ivqGs=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
+1
View File
@@ -192,6 +192,7 @@ func NewTelegramClient(ctx context.Context, tc *TelegramConnector, login *bridge
dispatcher.OnPeerBlocked(func(ctx context.Context, e tg.Entities, update *tg.UpdatePeerBlocked) error {
return client.onPeerBlocked(ctx, update)
})
dispatcher.OnChat(client.onChat)
client.ScopedStore = tc.Store.GetScopedStore(telegramUserID)
+15
View File
@@ -887,3 +887,18 @@ func (t *TelegramClient) onPeerBlocked(ctx context.Context, update *tg.UpdatePee
})
return nil
}
func (t *TelegramClient) onChat(ctx context.Context, e tg.Entities, update *tg.UpdateChat) error {
if _, ok := e.ChatsForbidden[update.ChatID]; ok {
// The chat is now forbidden, we should leave it.
t.main.Bridge.QueueRemoteEvent(t.userLogin, &simplevent.ChatDelete{
OnlyForMe: true,
EventMeta: simplevent.EventMeta{
Type: bridgev2.RemoteEventChatDelete,
PortalKey: t.makePortalKeyFromID(ids.PeerTypeChat, update.ChatID),
Sender: t.mySender(),
},
})
}
return nil
}