client: save channel usernames in database

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-09-26 14:01:09 -06:00
parent 332bbb8de1
commit 31397681f5
4 changed files with 16 additions and 7 deletions
+9
View File
@@ -77,6 +77,8 @@ func (t *TelegramClient) onUpdateChannel(ctx context.Context, update *tg.UpdateC
} else if channel.Left {
log.Error().Msg("Update was for a left channel. Leaving the channel.")
leave()
} else {
// TODO update the channel info
}
return nil
}
@@ -408,6 +410,13 @@ func (t *TelegramClient) updateChannel(ctx context.Context, channel *tg.Channel)
}
}
if username, set := channel.GetUsername(); set {
err := t.ScopedStore.SetUsername(ctx, ids.PeerTypeChannel, channel.ID, username)
if err != nil {
return err
}
}
ghost.UpdateInfo(ctx, &bridgev2.UserInfo{
Name: &channel.Title,
Avatar: avatar,