client: Prefer contact name if exists
Don't allow TG user to override your own contact name for them after they have been made a contact.
This commit is contained in:
@@ -691,9 +691,10 @@ func (t *TelegramClient) getUserInfoFromTelegramUser(ctx context.Context, u tg.U
|
|||||||
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)
|
||||||
if !user.Min {
|
if !user.Min {
|
||||||
changed = changed || meta.IsPremium != user.Premium || meta.IsBot != user.Bot
|
changed = changed || meta.IsPremium != user.Premium || meta.IsBot != user.Bot || meta.IsContact != user.Contact
|
||||||
meta.IsPremium = user.Premium
|
meta.IsPremium = user.Premium
|
||||||
meta.IsBot = user.Bot
|
meta.IsBot = user.Bot
|
||||||
|
meta.IsContact = user.Contact
|
||||||
meta.Deleted = user.Deleted
|
meta.Deleted = user.Deleted
|
||||||
}
|
}
|
||||||
return changed
|
return changed
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ type GhostMetadata struct {
|
|||||||
IsPremium bool `json:"is_premium,omitempty"`
|
IsPremium bool `json:"is_premium,omitempty"`
|
||||||
IsBot bool `json:"is_bot,omitempty"`
|
IsBot bool `json:"is_bot,omitempty"`
|
||||||
IsChannel bool `json:"is_channel,omitempty"`
|
IsChannel bool `json:"is_channel,omitempty"`
|
||||||
|
IsContact bool `json:"is_contact,omitempty"`
|
||||||
Blocked bool `json:"blocked,omitempty"`
|
Blocked bool `json:"blocked,omitempty"`
|
||||||
Deleted bool `json:"deleted,omitempty"`
|
Deleted bool `json:"deleted,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -609,8 +609,12 @@ func (t *TelegramClient) onUserName(ctx context.Context, e tg.Entities, update *
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
name := util.FormatFullName(update.FirstName, update.LastName, false, update.UserID)
|
var userInfo bridgev2.UserInfo
|
||||||
userInfo := bridgev2.UserInfo{Name: &name}
|
|
||||||
|
if !ghost.Metadata.(*GhostMetadata).IsContact {
|
||||||
|
name := util.FormatFullName(update.FirstName, update.LastName, false, update.UserID)
|
||||||
|
userInfo.Name = &name
|
||||||
|
}
|
||||||
|
|
||||||
if len(update.Usernames) > 0 {
|
if len(update.Usernames) > 0 {
|
||||||
for _, ident := range ghost.Identifiers {
|
for _, ident := range ghost.Identifiers {
|
||||||
|
|||||||
Reference in New Issue
Block a user