fix: sync stars topup and paid reaction settings
This commit is contained in:
parent
4e18d31e16
commit
1f11b0fd1b
12 changed files with 506 additions and 24 deletions
|
|
@ -107,12 +107,16 @@ func domainChannelReactionPolicy(req *tg.MessagesSetChatAvailableReactionsReques
|
|||
policy.Type = domain.ChannelReactionPolicyAll
|
||||
policy.AllowCustom = reactions.AllowCustom
|
||||
case *tg.ChatReactionsSome:
|
||||
if len(reactions.Reactions) > domain.MaxChannelReactionTypes {
|
||||
return domain.ChannelReactionPolicy{}, limitInvalidErr()
|
||||
}
|
||||
policy.Type = domain.ChannelReactionPolicySome
|
||||
seen := make(map[string]struct{}, len(reactions.Reactions))
|
||||
for _, reaction := range reactions.Reactions {
|
||||
// TDesktop models the paid toggle as a pseudo reaction in the
|
||||
// selector and may submit reactionPaid in chatReactionsSome. The
|
||||
// durable paid state is carried by paid_enabled, not the normal
|
||||
// reaction whitelist.
|
||||
if paidReactionSentinel(reaction) {
|
||||
continue
|
||||
}
|
||||
parsed, err := domainMessageReactionFromTL(reaction)
|
||||
if err != nil {
|
||||
return domain.ChannelReactionPolicy{}, tgerr400("REACTION_INVALID")
|
||||
|
|
@ -122,6 +126,9 @@ func domainChannelReactionPolicy(req *tg.MessagesSetChatAvailableReactionsReques
|
|||
if _, ok := seen[key]; ok {
|
||||
continue
|
||||
}
|
||||
if len(seen) >= domain.MaxChannelReactionTypes {
|
||||
return domain.ChannelReactionPolicy{}, limitInvalidErr()
|
||||
}
|
||||
seen[key] = struct{}{}
|
||||
switch parsed.Type {
|
||||
case domain.MessageReactionEmoji:
|
||||
|
|
@ -135,3 +142,8 @@ func domainChannelReactionPolicy(req *tg.MessagesSetChatAvailableReactionsReques
|
|||
}
|
||||
return policy, nil
|
||||
}
|
||||
|
||||
func paidReactionSentinel(reaction tg.ReactionClass) bool {
|
||||
paid, ok := reaction.(*tg.ReactionPaid)
|
||||
return ok && paid != nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue