chore: refresh gramsrv public release
This commit is contained in:
parent
75cebe8dbf
commit
70b6820474
1274 changed files with 378751 additions and 59919 deletions
|
|
@ -2,6 +2,7 @@ package rpc
|
|||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/gotd/td/tg"
|
||||
|
||||
|
|
@ -49,10 +50,10 @@ func (r *Router) registerHelp(d *tg.ServerDispatcher) {
|
|||
return tdesktop.TimezonesList(hash), nil
|
||||
})
|
||||
d.OnHelpGetPeerColors(func(ctx context.Context, hash int) (tg.HelpPeerColorsClass, error) {
|
||||
return tdesktop.PeerColors(), nil
|
||||
return tdesktop.PeerColors(hash), nil
|
||||
})
|
||||
d.OnHelpGetPeerProfileColors(func(ctx context.Context, hash int) (tg.HelpPeerColorsClass, error) {
|
||||
return tdesktop.PeerColors(), nil
|
||||
return tdesktop.PeerProfileColors(hash), nil
|
||||
})
|
||||
d.OnHelpGetPromoData(func(ctx context.Context) (tg.HelpPromoDataClass, error) {
|
||||
return tdesktop.PromoData(r.clock.Now()), nil
|
||||
|
|
@ -60,7 +61,42 @@ func (r *Router) registerHelp(d *tg.ServerDispatcher) {
|
|||
d.OnHelpGetTermsOfServiceUpdate(func(ctx context.Context) (tg.HelpTermsOfServiceUpdateClass, error) {
|
||||
return tdesktop.TermsOfServiceUpdate(r.clock.Now()), nil
|
||||
})
|
||||
d.OnHelpGetPremiumPromo(func(ctx context.Context) (*tg.HelpPremiumPromo, error) {
|
||||
return tdesktop.PremiumPromo(), nil
|
||||
// 客户端遇到无法识别的 tg:// 深链时会查询 help.getDeepLinkInfo。telesrv 不维护
|
||||
// “需更新 App”的特殊深链提示库,对所有 path 返回 deepLinkInfoEmpty——这是规范的
|
||||
// “无特殊信息”应答:DrKLO 仅在收到非空 deepLinkInfo 时才弹“请更新 App”弹窗
|
||||
// (LaunchActivity.java:5175),收到 Empty 则静默放行按普通链接处理。此前未注册
|
||||
// handler 会落 fallback 返回 500 NOT_IMPLEMENTED(污染日志且非正确协议行为)。
|
||||
d.OnHelpGetDeepLinkInfo(func(ctx context.Context, path string) (tg.HelpDeepLinkInfoClass, error) {
|
||||
return &tg.HelpDeepLinkInfoEmpty{}, nil
|
||||
})
|
||||
d.OnHelpGetPremiumPromo(r.onHelpGetPremiumPromo)
|
||||
}
|
||||
|
||||
// onHelpGetPremiumPromo 返回最小真实的 Premium 状态页数据:状态文案按 viewer
|
||||
// 的会员有效期生成;videos/period_options 留空——购买入口已被 appConfig
|
||||
// premium_purchase_blocked=true 关闭,订阅价格 UI 不会消费这些字段(TDesktop
|
||||
// 空 period_options 仅隐藏价格按钮,DrKLO 回退到无价文案,均不报错)。
|
||||
// 六个字段全是 TL 必填项,空值也必须给出空集合而非缺失。
|
||||
func (r *Router) onHelpGetPremiumPromo(ctx context.Context) (*tg.HelpPremiumPromo, error) {
|
||||
promo := &tg.HelpPremiumPromo{
|
||||
StatusText: "Telegram Premium is not active on this account.",
|
||||
StatusEntities: []tg.MessageEntityClass{},
|
||||
VideoSections: []string{},
|
||||
Videos: []tg.DocumentClass{},
|
||||
PeriodOptions: []tg.PremiumSubscriptionOption{},
|
||||
Users: []tg.UserClass{},
|
||||
}
|
||||
userID, _, err := r.currentUserID(ctx)
|
||||
if err != nil || r.deps.Users == nil {
|
||||
return promo, nil
|
||||
}
|
||||
u, err := r.deps.Users.Self(ctx, userID)
|
||||
if err != nil {
|
||||
return promo, nil
|
||||
}
|
||||
if u.PremiumActiveAt(r.clock.Now().Unix()) {
|
||||
until := time.Unix(int64(u.PremiumUntil), 0)
|
||||
promo.StatusText = "Telegram Premium is active until " + until.Format("2006-01-02") + "."
|
||||
}
|
||||
return promo, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue