fix(appearance): sync close Android theme wallpaper fallback

Public projection of telesrv 2c8b7cb4c20692d00017bd84f68dd11d7915ec33 with neutral appearance seed naming. Covers gramsrv#29.
This commit is contained in:
iamxvbaba 2026-08-01 15:22:31 +08:00
parent af616e8c12
commit 94f3843d23
5 changed files with 170 additions and 13 deletions

View file

@ -6,6 +6,7 @@ import (
"strings"
"github.com/iamxvbaba/td/tg"
"go.uber.org/zap"
"github.com/iamxvbaba/td/tlprofile"
"telesrv/internal/branding"
@ -289,6 +290,7 @@ func (r *Router) registerAccount(d *tlprofile.Dispatcher) {
return false, tgerr400("WALLPAPER_INVALID")
}
if _, ok := tdesktop.LookupWallPaper(req.Wallpaper); !ok {
r.log.Info("wallpaper reference rejected", wallpaperReferenceLogFields("account.installWallPaper", req.Wallpaper)...)
return false, tgerr400("WALLPAPER_INVALID")
}
return true, nil
@ -463,6 +465,20 @@ func (r *Router) registerAccount(d *tlprofile.Dispatcher) {
}
func wallpaperReferenceLogFields(method string, input tg.InputWallPaperClass) []zap.Field {
fields := []zap.Field{zap.String("method", method)}
switch wallpaper := input.(type) {
case *tg.InputWallPaperSlug:
return append(fields, zap.String("input_type", "inputWallPaperSlug"), zap.String("slug", wallpaper.Slug))
case *tg.InputWallPaper:
return append(fields, zap.String("input_type", "inputWallPaper"), zap.Int64("wallpaper_id", wallpaper.ID))
case *tg.InputWallPaperNoFile:
return append(fields, zap.String("input_type", "inputWallPaperNoFile"), zap.Int64("wallpaper_id", wallpaper.ID))
default:
return append(fields, zap.String("input_type", "unknown"))
}
}
func (r *Router) onAccountGetPassword(ctx context.Context) (*tg.AccountPassword, error) {
if r.deps.Account == nil {
return tgPassword(domain.PasswordSettings{SecureRandom: []byte("telesrv-tdesktop-dev-secure-rand")}), nil