takeout: use takeout to list dialogs once permission granted

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-09-10 00:06:02 -06:00
parent 4692d46305
commit fab98cfdea
4 changed files with 101 additions and 12 deletions
+7 -3
View File
@@ -16,8 +16,6 @@ import (
)
func (t *TelegramClient) SyncChats(ctx context.Context) error {
log := zerolog.Ctx(ctx)
limit := t.main.Config.Sync.UpdateLimit
if limit <= 0 {
limit = math.MaxInt32
@@ -40,6 +38,12 @@ func (t *TelegramClient) SyncChats(ctx context.Context) error {
return err
}
return t.handleDialogs(ctx, dialogs, t.main.Config.Sync.CreateLimit)
}
func (t *TelegramClient) handleDialogs(ctx context.Context, dialogs tg.ModifiedMessagesDialogs, createLimit int) error {
log := zerolog.Ctx(ctx)
users := map[networkid.UserID]tg.UserClass{}
for _, user := range dialogs.GetUsers() {
users[ids.MakeUserID(user.GetID())] = user
@@ -89,7 +93,7 @@ func (t *TelegramClient) SyncChats(ctx context.Context) error {
}
created++ // The portal will have to be created
if created > t.main.Config.Sync.CreateLimit {
if createLimit >= 0 && created > createLimit {
break
}
}