sticker

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package sticker implements per-user custom sticker management.

Two-step registration contract (API)

  1. Upload the image: POST /v1/file/upload?type=sticker (multipart). The response carries `path` and — when the server has signing capability (OCTO_MASTER_KEY configured) — `sticker_handle`.
  2. Register: POST /v1/sticker/user with body {path, format, placeholder, handle}, passing the upload's `sticker_handle` value as `handle`.

Stickers do NOT support presigned uploads: the upload handle can only be minted where modules/file holds both the authenticated uploader and the content-validated bytes, so the image must transit the multipart endpoint.

Handle enforcement (capability vs policy)

Whether `handle` is REQUIRED is governed by the system_setting `sticker.handle_required` (SystemSettings.StickerHandleRequired) — a DB-backed, admin-toggleable policy independent of the signing capability (OCTO_MASTER_KEY / stickersig.Enabled). It lives in system_setting rather than an env var so the rollout can be toggled and rolled back from the admin console without a restart (converging across replicas within the snapshot TTL). Clients read the effective policy from GET /v1/common/appconfig → `sticker_handle_required`. See the stickersig package doc for the rollout rationale and behavior matrix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sticker

type Sticker struct {
	log.Log
	// contains filtered or unexported fields
}

Sticker 用户自定义贴纸 API。

func New

func New(ctx *config.Context) *Sticker

New 创建 Sticker 实例。settings 走进程内共享单例,配额变更(管理端写 system_setting)经其 60s 快照在多实例间收敛。

func (*Sticker) Route

func (s *Sticker) Route(r *wkhttp.WKHttp)

Route 路由配置。所有路由经 AuthMiddleware(个人维度,按 login uid 隔离), 并在其后挂 SharedUIDRateLimiter(每用户配额)。

type StickerModel

type StickerModel struct {
	StickerID   string
	UID         string
	Path        string
	Placeholder string
	Format      string
	Sort        int
	Shortcode   string
	Keywords    string
	SourcePath  string
	// SourcePathHash is set only for "collect from message" records. Direct
	// upload registrations keep it empty so the collect-only unique key does not
	// affect existing custom-sticker creation.
	SourcePathHash string
	Status         int
	db.BaseModel
}

StickerModel 用户自定义贴纸(个人维度,扁平、不分包)。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL