chore: refresh gramsrv public release

This commit is contained in:
A 2026-06-30 14:37:43 +08:00
parent 75cebe8dbf
commit 70b6820474
1274 changed files with 378751 additions and 59919 deletions

View file

@ -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
}