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 {
|
func (t *TelegramClient) getDMPowerLevels(ghost *bridgev2.Ghost) *bridgev2.PowerLevelOverrides {
|
||||||
var plo 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
|
// Don't allow sending messages to blocked users
|
||||||
plo.EventsDefault = superadminPowerLevel
|
plo.EventsDefault = superadminPowerLevel
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -675,10 +675,9 @@ func (t *TelegramClient) onUserName(ctx context.Context, e tg.Entities, update *
|
|||||||
|
|
||||||
var userInfo bridgev2.UserInfo
|
var userInfo bridgev2.UserInfo
|
||||||
|
|
||||||
if !ghost.Metadata.(*GhostMetadata).IsContact {
|
// TODO anti-contact-name logic
|
||||||
name := util.FormatFullName(update.FirstName, update.LastName, false, update.UserID)
|
name := util.FormatFullName(update.FirstName, update.LastName, false, update.UserID)
|
||||||
userInfo.Name = &name
|
userInfo.Name = &name
|
||||||
}
|
|
||||||
|
|
||||||
if len(update.Usernames) > 0 {
|
if len(update.Usernames) > 0 {
|
||||||
for _, ident := range ghost.Identifiers {
|
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 {
|
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
|
var userID networkid.UserID
|
||||||
if peer, ok := update.PeerID.(*tg.PeerUser); ok {
|
if peer, ok := update.PeerID.(*tg.PeerUser); ok {
|
||||||
userID = ids.MakeUserID(peer.UserID)
|
userID = ids.MakeUserID(peer.UserID)
|
||||||
@@ -1264,13 +1267,6 @@ func (t *TelegramClient) onPeerBlocked(ctx context.Context, e tg.Entities, updat
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
// Find portals that are DMs with the user
|
||||||
res := t.main.Bridge.QueueRemoteEvent(t.userLogin, &simplevent.ChatResync{
|
res := t.main.Bridge.QueueRemoteEvent(t.userLogin, &simplevent.ChatResync{
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ 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"`
|
|
||||||
Deleted bool `json:"deleted,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) {
|
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 || meta.IsContact != user.Contact
|
changed = changed || meta.IsPremium != user.Premium || meta.IsBot != user.Bot
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user