fix(cosmetics): область стиля в ответе и ожидание данных в проверке
- GET /users/@me/styles отдаёт запись для каждой области, даже если стиль ещё не задан: иначе клиент не мог выбрать пер-серверную область - живая проверка ждёт загрузки галереи и вариантов рамок - уточнён приоритет: эффект роли важнее личного стиля (AGENT.md 7.2)
This commit is contained in:
@@ -345,7 +345,7 @@ func (s *Server) registerStyleRoutes(api huma.API) {
|
||||
}
|
||||
output := &styleListOutput{}
|
||||
output.Body.Styles = append(output.Body.Styles,
|
||||
styleFromStore(byScope[scopeGlobal],
|
||||
styleFromStore(byScope[scopeGlobal], scopeGlobal, "",
|
||||
grantedIDs(cosmetics, grants[user.ID].Frames, store.CosmeticFrame),
|
||||
grantedIDs(cosmetics, grants[user.ID].Badges, store.CosmeticBadge),
|
||||
colors))
|
||||
@@ -362,12 +362,11 @@ func (s *Server) registerStyleRoutes(api huma.API) {
|
||||
return nil, humaError(err)
|
||||
}
|
||||
entry := scoped[user.ID]
|
||||
payload := styleFromStore(byScope[scope],
|
||||
output.Body.Styles = append(output.Body.Styles,
|
||||
styleFromStore(byScope[scope], scope, guilds[i].Name,
|
||||
grantedIDs(cosmetics, entry.GuildFrames, store.CosmeticFrame),
|
||||
grantedIDs(cosmetics, entry.GuildBadges, store.CosmeticBadge),
|
||||
colors)
|
||||
payload.GuildName = guilds[i].Name
|
||||
output.Body.Styles = append(output.Body.Styles, payload)
|
||||
colors))
|
||||
}
|
||||
return output, nil
|
||||
})
|
||||
@@ -444,8 +443,13 @@ func (s *Server) registerStyleRoutes(api huma.API) {
|
||||
}
|
||||
frames := grantedIDs(cosmetics, grants[user.ID].Frames, store.CosmeticFrame)
|
||||
badges := grantedIDs(cosmetics, grants[user.ID].Badges, store.CosmeticBadge)
|
||||
scope := scopeGlobal
|
||||
guildName := ""
|
||||
if guildID != nil {
|
||||
scope = formatSnowflake(*guildID)
|
||||
}
|
||||
output := &styleOutput{}
|
||||
output.Body.Style = styleFromStore(style, frames, badges, store.NickColorPalette())
|
||||
output.Body.Style = styleFromStore(style, scope, guildName, frames, badges, store.NickColorPalette())
|
||||
s.dispatchStyleUpdate(user.ID, guildID)
|
||||
return output, nil
|
||||
})
|
||||
@@ -618,15 +622,20 @@ func cosmeticsFromEffective(effective store.EffectiveCosmetics) *cosmeticsPayloa
|
||||
return payload
|
||||
}
|
||||
|
||||
// styleFromStore собирает ответ по личному стилю.
|
||||
func styleFromStore(style *store.UserStyle, frames, badges []string, colors []int64) stylePayload {
|
||||
// styleFromStore собирает ответ по области стиля: даже без записанного стиля
|
||||
// запись отдаётся клиенту — в ней список доступных элементов (AGENT.md 7.2).
|
||||
func styleFromStore(style *store.UserStyle, scope, guildName string, frames, badges []string, colors []int64) stylePayload {
|
||||
payload := stylePayload{
|
||||
Scope: scopeGlobal,
|
||||
Scope: scope,
|
||||
GuildName: guildName,
|
||||
FrameIDs: frames,
|
||||
BadgeIDs: badges,
|
||||
NickColors: colors,
|
||||
Effects: effectNames(),
|
||||
}
|
||||
if scope != scopeGlobal {
|
||||
payload.GuildID = scope
|
||||
}
|
||||
if payload.FrameIDs == nil {
|
||||
payload.FrameIDs = []string{}
|
||||
}
|
||||
@@ -639,10 +648,6 @@ func styleFromStore(style *store.UserStyle, frames, badges []string, colors []in
|
||||
if style == nil {
|
||||
return payload
|
||||
}
|
||||
if style.GuildID != nil {
|
||||
payload.Scope = formatSnowflake(*style.GuildID)
|
||||
payload.GuildID = formatSnowflake(*style.GuildID)
|
||||
}
|
||||
if style.FrameID != nil {
|
||||
payload.Style.FrameID = formatSnowflake(*style.FrameID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user