connector: only save access hash if not a min entity

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-10-26 22:48:54 -06:00
parent e266d1ac80
commit 7cb70d9753
2 changed files with 8 additions and 6 deletions
+6 -5
View File
@@ -524,12 +524,13 @@ func (t *TelegramClient) getUserInfoFromTelegramUser(ctx context.Context, u tg.U
return nil, fmt.Errorf("user is %T not *tg.User", user)
}
var identifiers []string
if accessHash, ok := user.GetAccessHash(); ok {
if err := t.ScopedStore.SetAccessHash(ctx, ids.PeerTypeUser, user.ID, accessHash); err != nil {
return nil, err
}
}
if !user.Min {
if accessHash, ok := user.GetAccessHash(); ok {
if err := t.ScopedStore.SetAccessHash(ctx, ids.PeerTypeUser, user.ID, accessHash); err != nil {
return nil, err
}
}
if err := t.ScopedStore.SetUsername(ctx, ids.PeerTypeUser, user.ID, user.Username); err != nil {
return nil, err
}
+2 -1
View File
@@ -474,7 +474,8 @@ func (t *TelegramClient) updateGhost(ctx context.Context, userID int64, user *tg
}
func (t *TelegramClient) updateChannel(ctx context.Context, channel *tg.Channel) (*bridgev2.UserInfo, error) {
if accessHash, ok := channel.GetAccessHash(); ok {
if accessHash, ok := channel.GetAccessHash(); ok && !channel.Min {
fmt.Printf("UPDATE CHANNEL HAS ACCESS HASH %d %d\n", channel.ID, accessHash)
if err := t.ScopedStore.SetAccessHash(ctx, ids.PeerTypeChannel, channel.ID, accessHash); err != nil {
return nil, err
}