fix: sync WebK compatibility paths
This commit is contained in:
parent
766c5db992
commit
76bfc5100f
12 changed files with 387 additions and 8 deletions
|
|
@ -2,6 +2,7 @@ package rpc
|
|||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/iamxvbaba/td/tg"
|
||||
"go.uber.org/zap"
|
||||
|
|
@ -18,6 +19,9 @@ func (r *Router) onMessagesSetDefaultReaction(ctx context.Context, reaction tg.R
|
|||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if err := r.validateDefaultReaction(ctx, parsed); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if svc, ok := r.deps.Account.(accountDefaultReactionService); ok {
|
||||
if _, err := svc.SetDefaultReaction(ctx, userID, parsed); err != nil {
|
||||
return false, internalErr()
|
||||
|
|
@ -26,6 +30,37 @@ func (r *Router) onMessagesSetDefaultReaction(ctx context.Context, reaction tg.R
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func (r *Router) validateDefaultReaction(ctx context.Context, reaction domain.MessageReaction) error {
|
||||
if reaction.Type == domain.MessageReactionCustomEmoji {
|
||||
return nil
|
||||
}
|
||||
if reaction.Type != domain.MessageReactionEmoji {
|
||||
return reactionInvalidErr()
|
||||
}
|
||||
|
||||
if r.deps.Files != nil {
|
||||
catalog, err := r.deps.Files.ListAvailableReactions(ctx)
|
||||
if err != nil {
|
||||
return internalErr()
|
||||
}
|
||||
if len(catalog) > 0 {
|
||||
for _, item := range catalog {
|
||||
if !item.Inactive && strings.TrimSpace(item.Reaction) == reaction.Emoticon {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return reactionInvalidErr()
|
||||
}
|
||||
}
|
||||
|
||||
for _, item := range staticReactionCatalog() {
|
||||
if item.Key() == reaction.Key() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return reactionInvalidErr()
|
||||
}
|
||||
|
||||
func (r *Router) onMessagesGetPaidReactionPrivacy(ctx context.Context) (tg.UpdatesClass, error) {
|
||||
userID, _, err := r.currentUserID(ctx)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue