dbmeta: remove disallowed fields in ghosts
This commit is contained in:
@@ -556,7 +556,8 @@ func getTopicInfoFromResponse(resp *tg.MessagesForumTopics, channelID int64, top
|
||||
|
||||
func (t *TelegramClient) getDMPowerLevels(ghost *bridgev2.Ghost) *bridgev2.PowerLevelOverrides {
|
||||
var plo bridgev2.PowerLevelOverrides
|
||||
if ghost.Metadata.(*GhostMetadata).Blocked {
|
||||
// TODO use per-login metadata for blocked status
|
||||
if /*ghost.Metadata.(*GhostMetadata).Blocked*/ false {
|
||||
// Don't allow sending messages to blocked users
|
||||
plo.EventsDefault = superadminPowerLevel
|
||||
} else {
|
||||
|
||||
@@ -675,10 +675,9 @@ func (t *TelegramClient) onUserName(ctx context.Context, e tg.Entities, update *
|
||||
|
||||
var userInfo bridgev2.UserInfo
|
||||
|
||||
if !ghost.Metadata.(*GhostMetadata).IsContact {
|
||||
name := util.FormatFullName(update.FirstName, update.LastName, false, update.UserID)
|
||||
userInfo.Name = &name
|
||||
}
|
||||
// TODO anti-contact-name logic
|
||||
name := util.FormatFullName(update.FirstName, update.LastName, false, update.UserID)
|
||||
userInfo.Name = &name
|
||||
|
||||
if len(update.Usernames) > 0 {
|
||||
for _, ident := range ghost.Identifiers {
|
||||
@@ -1251,6 +1250,10 @@ func (t *TelegramClient) onChatDefaultBannedRights(ctx context.Context, entities
|
||||
}
|
||||
|
||||
func (t *TelegramClient) onPeerBlocked(ctx context.Context, e tg.Entities, update *tg.UpdatePeerBlocked) error {
|
||||
// TODO fix this after adding storage for block status (getDMPowerLevels also needs updating)
|
||||
if true {
|
||||
return nil
|
||||
}
|
||||
var userID networkid.UserID
|
||||
if peer, ok := update.PeerID.(*tg.PeerUser); ok {
|
||||
userID = ids.MakeUserID(peer.UserID)
|
||||
@@ -1264,13 +1267,6 @@ func (t *TelegramClient) onPeerBlocked(ctx context.Context, e tg.Entities, updat
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ghost.UpdateInfo(ctx, &bridgev2.UserInfo{
|
||||
ExtraUpdates: func(ctx context.Context, g *bridgev2.Ghost) bool {
|
||||
updated := g.Metadata.(*GhostMetadata).Blocked != update.Blocked
|
||||
g.Metadata.(*GhostMetadata).Blocked = update.Blocked
|
||||
return updated
|
||||
},
|
||||
})
|
||||
|
||||
// Find portals that are DMs with the user
|
||||
res := t.main.Bridge.QueueRemoteEvent(t.userLogin, &simplevent.ChatResync{
|
||||
|
||||
@@ -43,8 +43,6 @@ type GhostMetadata struct {
|
||||
IsPremium bool `json:"is_premium,omitempty"`
|
||||
IsBot bool `json:"is_bot,omitempty"`
|
||||
IsChannel bool `json:"is_channel,omitempty"`
|
||||
IsContact bool `json:"is_contact,omitempty"`
|
||||
Blocked bool `json:"blocked,omitempty"`
|
||||
Deleted bool `json:"deleted,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -128,10 +128,9 @@ func (t *TelegramClient) wrapUserInfo(ctx context.Context, u tg.UserClass) (*bri
|
||||
ExtraUpdates: func(ctx context.Context, ghost *bridgev2.Ghost) (changed bool) {
|
||||
meta := ghost.Metadata.(*GhostMetadata)
|
||||
if !user.Min {
|
||||
changed = changed || meta.IsPremium != user.Premium || meta.IsBot != user.Bot || meta.IsContact != user.Contact
|
||||
changed = changed || meta.IsPremium != user.Premium || meta.IsBot != user.Bot
|
||||
meta.IsPremium = user.Premium
|
||||
meta.IsBot = user.Bot
|
||||
meta.IsContact = user.Contact
|
||||
meta.Deleted = user.Deleted
|
||||
}
|
||||
return changed
|
||||
|
||||
Reference in New Issue
Block a user