ghost: improve metadata handling
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
+13
-7
@@ -301,11 +301,13 @@ func (t *TelegramClient) getUserInfoFromTelegramUser(u tg.UserClass) (*bridgev2.
|
|||||||
return nil, fmt.Errorf("user is %T not *tg.User", user)
|
return nil, fmt.Errorf("user is %T not *tg.User", user)
|
||||||
}
|
}
|
||||||
var identifiers []string
|
var identifiers []string
|
||||||
for _, username := range user.Usernames {
|
if !user.Min {
|
||||||
identifiers = append(identifiers, fmt.Sprintf("telegram:%s", username.Username))
|
for _, username := range user.Usernames {
|
||||||
}
|
identifiers = append(identifiers, fmt.Sprintf("telegram:%s", username.Username))
|
||||||
if phone, ok := user.GetPhone(); ok {
|
}
|
||||||
identifiers = append(identifiers, fmt.Sprintf("tel:+%s", strings.TrimPrefix(phone, "+")))
|
if phone, ok := user.GetPhone(); ok {
|
||||||
|
identifiers = append(identifiers, fmt.Sprintf("tel:+%s", strings.TrimPrefix(phone, "+")))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var avatar *bridgev2.Avatar
|
var avatar *bridgev2.Avatar
|
||||||
@@ -328,8 +330,12 @@ func (t *TelegramClient) getUserInfoFromTelegramUser(u tg.UserClass) (*bridgev2.
|
|||||||
Identifiers: identifiers,
|
Identifiers: identifiers,
|
||||||
ExtraUpdates: func(ctx context.Context, ghost *bridgev2.Ghost) (changed bool) {
|
ExtraUpdates: func(ctx context.Context, ghost *bridgev2.Ghost) (changed bool) {
|
||||||
meta := ghost.Metadata.(*GhostMetadata)
|
meta := ghost.Metadata.(*GhostMetadata)
|
||||||
changed = meta.IsPremium != user.Premium || meta.AccessHash != user.AccessHash
|
if !user.Min {
|
||||||
meta.IsPremium = user.Premium
|
changed = changed || meta.IsPremium != user.Premium || meta.IsBot != user.Bot
|
||||||
|
meta.IsPremium = user.Premium
|
||||||
|
meta.IsBot = user.Bot
|
||||||
|
}
|
||||||
|
changed = changed || meta.AccessHash != user.AccessHash
|
||||||
meta.AccessHash = user.AccessHash
|
meta.AccessHash = user.AccessHash
|
||||||
return changed
|
return changed
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ func (tg *TelegramConnector) GetDBMetaTypes() database.MetaTypes {
|
|||||||
|
|
||||||
type GhostMetadata struct {
|
type GhostMetadata struct {
|
||||||
IsPremium bool `json:"is_premium"`
|
IsPremium bool `json:"is_premium"`
|
||||||
|
IsBot bool `json:"is_bot"`
|
||||||
AccessHash int64 `json:"access_hash"`
|
AccessHash int64 `json:"access_hash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user