feat: sync monoforum and collectible emoji status
Sync telesrv bd15657 (feat(account): implement collectible emoji status). Skipped telesrv docs changes per public sync rules.
This commit is contained in:
parent
edb7057757
commit
0c99ae0a9d
91 changed files with 4061 additions and 693 deletions
73
internal/rpc/messages_suggested_post.go
Normal file
73
internal/rpc/messages_suggested_post.go
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"github.com/iamxvbaba/td/tg"
|
||||
|
||||
"telesrv/internal/domain"
|
||||
)
|
||||
|
||||
const (
|
||||
minSuggestedPostStars int64 = 5
|
||||
maxSuggestedPostStars int64 = 100_000
|
||||
minSuggestedPostNanoTON int64 = 10_000_000
|
||||
maxSuggestedPostNanoTON int64 = 10_000_000_000_000
|
||||
)
|
||||
|
||||
func domainSuggestedPost(input tg.SuggestedPost, present bool) (*domain.SuggestedPost, error) {
|
||||
if !present {
|
||||
return nil, nil
|
||||
}
|
||||
if input.GetAccepted() || input.GetRejected() {
|
||||
return nil, tgerr400("SUGGESTED_POST_AMOUNT_INVALID")
|
||||
}
|
||||
out := &domain.SuggestedPost{}
|
||||
if date, ok := input.GetScheduleDate(); ok {
|
||||
if date <= 0 {
|
||||
return nil, scheduleDateInvalidErr()
|
||||
}
|
||||
out.ScheduleDate = date
|
||||
}
|
||||
if price, ok := input.GetPrice(); ok {
|
||||
switch value := price.(type) {
|
||||
case *tg.StarsAmount:
|
||||
if value == nil || value.Amount < minSuggestedPostStars || value.Amount > maxSuggestedPostStars ||
|
||||
value.Nanos < 0 || value.Nanos >= 1_000_000_000 || value.Amount == maxSuggestedPostStars && value.Nanos != 0 {
|
||||
return nil, tgerr400("SUGGESTED_POST_AMOUNT_INVALID")
|
||||
}
|
||||
out.Price = &domain.SuggestedPostPrice{Kind: domain.SuggestedPostPriceStars, Amount: value.Amount, Nanos: value.Nanos}
|
||||
case *tg.StarsTonAmount:
|
||||
if value == nil || value.Amount < minSuggestedPostNanoTON || value.Amount > maxSuggestedPostNanoTON {
|
||||
return nil, tgerr400("SUGGESTED_POST_AMOUNT_INVALID")
|
||||
}
|
||||
out.Price = &domain.SuggestedPostPrice{Kind: domain.SuggestedPostPriceTON, Amount: value.Amount}
|
||||
default:
|
||||
return nil, tgerr400("SUGGESTED_POST_AMOUNT_INVALID")
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func tgSuggestedPost(input *domain.SuggestedPost) (tg.SuggestedPost, bool) {
|
||||
if input == nil {
|
||||
return tg.SuggestedPost{}, false
|
||||
}
|
||||
out := tg.SuggestedPost{}
|
||||
if input.Accepted {
|
||||
out.SetAccepted(true)
|
||||
}
|
||||
if input.Rejected {
|
||||
out.SetRejected(true)
|
||||
}
|
||||
if input.ScheduleDate > 0 {
|
||||
out.SetScheduleDate(input.ScheduleDate)
|
||||
}
|
||||
if input.Price != nil {
|
||||
switch input.Price.Kind {
|
||||
case domain.SuggestedPostPriceStars:
|
||||
out.SetPrice(&tg.StarsAmount{Amount: input.Price.Amount, Nanos: input.Price.Nanos})
|
||||
case domain.SuggestedPostPriceTON:
|
||||
out.SetPrice(&tg.StarsTonAmount{Amount: input.Price.Amount})
|
||||
}
|
||||
}
|
||||
return out, true
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue