MCPcopy Create free account

hub / github.com/Prejudice-Studio/Twilight / functions

Functions2,686 in github.com/Prejudice-Studio/Twilight

↓ 922 callersMethodstore
()
internal/api/app.go:117
↓ 761 callersMethodcfg
cfg 返回当前生效的 config.Config 指针:调用方读字段后即可释放快照; 同一次 handler 内若需要前后一致,先 `cfg := a.cfg()` 一次再多次读字段。 返回指针而非值避免在 hot path 上每次拷贝 ~50 字段的 Config struct。
internal/api/app.go:108
↓ 664 callersFunctiontoast
({ ...props }: Toast)
webui/src/hooks/use-toast.ts:163
↓ 647 callersFunctionfailWithCode
failWithCode 是 fail 的重载,附带业务级错误码(见 errcode.go)。 推荐所有领域错误(容量满 / 绑定冲突 / 弱密码等)使用本函数, 仅协议层错误(参数缺失 / 鉴权失败等通用类)才使用 fail。
internal/api/response.go:106
↓ 355 callersMethodadd
(method, pattern string, auth AuthLevel, handler HandlerFunc)
internal/api/app.go:667
↓ 290 callersFunctionok
(w http.ResponseWriter, message string, data any)
internal/api/response.go:85
↓ 228 callersFunctionasString
(value any)
internal/api/business.go:1460
↓ 224 callersFunctionstringValue
(payload map[string]any, key string)
internal/api/app.go:1295
↓ 220 callersMethodrequest
( endpoint: string, options: RequestInit = {}, extra: ApiRequestExtraOptions = {}, )
webui/src/lib/api.ts:198
↓ 175 callersFunctionnewTestApp
(t *testing.T)
internal/api/app_test.go:29
↓ 152 callersFunctionnumeric
(value any)
internal/api/business.go:986
↓ 146 callersFunctionfirstNonEmpty
(values ...string)
internal/api/handlers.go:2936
↓ 134 callersFunctiondoJSON
(app *App, method, path, body string, cookies []*http.Cookie)
internal/api/app_test.go:5399
↓ 132 callersMethodClose
()
internal/store/store.go:849
↓ 129 callersFunctiondoJSONWithHeaders
(app *App, method, path, body string, cookies []*http.Cookie, headers map[string]string)
internal/api/app_test.go:5423
↓ 128 callersMethodCreateUser
(u User)
internal/store/store.go:1642
↓ 119 callersFunctioncurrent
(r *http.Request)
internal/api/app.go:816
↓ 117 callersMethodtelegramSendMessage
(ctx context.Context, chatID any, text string)
internal/api/telegram.go:159
↓ 115 callersMethodGet
(ctx context.Context, token string)
internal/api/session.go:156
↓ 111 callersFunctiondecodeMap
(r *http.Request)
internal/api/app.go:1253
↓ 108 callersMethodUser
(uid int64)
internal/store/store.go:1877
↓ 102 callersFunctionstatusFromError
(w http.ResponseWriter, err error)
internal/api/app.go:1513
↓ 94 callersMethodUpdateUser
(uid int64, fn func(*User) error)
internal/store/store.go:1884
↓ 94 callersFunctionjsDocParam
(name, typ, description string, required bool)
internal/api/developer_handlers.go:290
↓ 87 callersFunctioncn
(...inputs: ClassValue[])
webui/src/lib/utils.ts:4
↓ 85 callersMethodWrite
(data []byte)
internal/api/app.go:177
↓ 83 callersMethodstringValue
(fallback string, keys ...string)
internal/config/config.go:1155
↓ 81 callersFunctionjsDocParamDefault
(name, typ, description, fallback string)
internal/api/developer_handlers.go:294
↓ 80 callersFunctionboolValue
(payload map[string]any, key string, fallback bool)
internal/api/app.go:1331
↓ 77 callersFunctionuseI18n
()
webui/src/lib/i18n.tsx:170
↓ 76 callersMethodmutateAndSaveLocked
mutateAndSaveLocked 把"读最新状态 → 变更 → 持久化 → 失败回滚"模板化。 调用方必须已经持有 s.mu 写锁;helper 内部不再额外加锁。 旧的写者模板"refreshLocked → 改 s.state → saveLocked"在 saveLocked 失败 后
internal/store/store.go:1098
↓ 57 callersFunctionintValue
(payload map[string]any, key string, fallback int)
internal/api/app.go:1313
↓ 56 callersMethodListUsers
()
internal/store/store.go:2430
↓ 56 callersMethodaudit
audit 是写入操作审计日志的便捷方法。category 为 "admin" / "user" / "system"。 AuditLog.enabled=false 时静默跳过记录。从 current(r) 提取操作者身份。
internal/api/audit_handlers.go:16
↓ 56 callersMethodintValue
(fallback int, keys ...string)
internal/config/config.go:1180
↓ 53 callersFunctionboolish
(value any)
internal/api/admin_extra.go:1060
↓ 49 callersFunctionregisterAndLogin
registerAndLogin 注册并登录指定账户,返回 session cookie 切片。
internal/api/app_test.go:86
↓ 48 callersFunctionclamp
(value, minValue, maxValue int)
internal/api/business.go:26
↓ 47 callersFunctionuseToast
()
webui/src/hooks/use-toast.ts:206
↓ 46 callersFunctionredactSensitiveText
(value string)
internal/api/runtime_logs.go:475
↓ 45 callersMethodboolValue
(fallback bool, keys ...string)
internal/config/config.go:1256
↓ 44 callersMethodRegCode
(code string)
internal/store/store.go:3611
↓ 44 callersFunctionpublicUser
(u store.User)
internal/api/app.go:1380
↓ 42 callersMethodFindUserByUsername
(username string)
internal/store/store.go:1841
↓ 42 callersFunctionint64Param
(params Params, key string)
internal/api/app.go:1343
↓ 42 callersFunctionqueryInt
(r *http.Request, key string, fallback int)
internal/api/business.go:17
↓ 38 callersFunctionrateKey
(parts ...any)
internal/api/ratelimit.go:77
↓ 37 callersMethodallowRate
(ctx context.Context, key string, limit int, window time.Duration)
internal/api/app.go:661
↓ 36 callersFunctiontruncateString
(value string, limit int)
internal/api/business.go:372
↓ 35 callersFunctionOpen
(path string)
internal/store/store.go:480
↓ 34 callersMethodUpsertRegCode
(code RegCode)
internal/store/store.go:3618
↓ 34 callersFunctionfindCookie
(cookies []*http.Cookie, name string)
internal/api/app_test.go:5442
↓ 34 callersFunctionintValue
(value string, fallback int)
internal/config/config.go:1407
↓ 31 callersMethodsessions
()
internal/api/app.go:124
↓ 31 callersMethodtelegramEditPanelWithNotice
(ctx context.Context, panel telegramPanelContext, target store.User, notice string)
internal/api/telegram_inline.go:491
↓ 29 callersFunctioninvalidateUsersCache
()
webui/src/app/(main)/admin/users/page.tsx:302
↓ 29 callersFunctionzeroNil
(v int64)
internal/api/handlers.go:2945
↓ 28 callersMethodembyGet
(ctx context.Context, apiPath string, dst any)
internal/api/emby_client.go:89
↓ 25 callersMethodclientIP
(r *http.Request)
internal/api/app.go:1128
↓ 25 callersMethodembyConfigured
embyConfigured 返回 Emby URL 和 Token 是否都已配置。 仅 URL 配置而 Token 为空时视为未鉴权配置,不应发起请求。
internal/api/emby_client.go:85
↓ 24 callersFunctionboolValue
(value string, fallback bool)
internal/config/config.go:1435
↓ 24 callersMethodsaveLocked
()
internal/store/store.go:1118
↓ 23 callersFunctionfriendlyError
(code: string | undefined, fallback?: string)
webui/src/lib/validators.ts:341
↓ 23 callersFunctionrandomCode
randomCode 生成 hex 编码的随机字符串,用于 API key、绑定码、上传文件名、 临时密码等所有"必须不可预测"的场景。 安全性约束:crypto/rand 故障时**绝不**回退到 time.Now().UnixNano() — 那会让攻击者用本机时钟近似猜出 token,等同于
internal/api/handlers.go:2906
↓ 22 callersMethodDeleteUser
(ctx context.Context, uid int64)
internal/api/session.go:232
↓ 22 callersFunctionLoad
(path string)
internal/config/config.go:328
↓ 22 callersFunctionexpiryIsPermanent
(expiredAt int64)
internal/api/business.go:185
↓ 21 callersFunctionurlPathEscape
(value string)
internal/api/app.go:1220
↓ 19 callersMethodFindUserByTelegramID
(telegramID int64)
internal/store/store.go:2467
↓ 19 callersMethodrefreshLocked
()
internal/store/store.go:1199
↓ 19 callersMethodtelegramRunJSCustomCommand
(code string, c telegramCommandCtx, privateChat bool)
internal/api/telegram_js_commands.go:112
↓ 19 callersFunctionuseAsyncResource
( loader: (signal?: AbortSignal) => Promise<T>, options: UseAsyncResourceOptions<T> = {} )
webui/src/hooks/use-async-resource.ts:18
↓ 18 callersFunctionResolveWithinRoot
ResolveWithinRoot 把 candidate 拼接到 root 下并返回绝对路径,若越界返回 ErrUnsafePath。 candidate 为相对路径或单文件名;绝对路径会先转换为相对 root 再校验。 不做 Lstat / 扩展名 / 符号链接判断,调用方可基于返回值再做。
internal/api/safepath.go:20
↓ 18 callersMethodauditEntryIP
auditEntryIP 是不依赖 *http.Request 的审计写入入口,供没有 HTTP 上下文的路径 (如 Telegram Bot 命令)使用,IP 由调用方显式传入(如 "telegram")。
internal/api/audit_handlers.go:33
↓ 18 callersFunctiondeveloperJSLimitText
(value string, limit int)
internal/api/telegram_js_commands.go:339
↓ 18 callersMethodtelegramAvailable
()
internal/api/telegram.go:39
↓ 18 callersMethoduserIsProtected
(u store.User)
internal/api/business.go:171
↓ 17 callersFunctionaddBatchOutcomeWithCode
(result map[string]any, uid int64, code ErrCode, err error)
internal/api/business.go:1405
↓ 17 callersFunctionformatDate
(date: string | Date | number | null | undefined)
webui/src/lib/utils.ts:48
↓ 17 callersFunctionnewJSONStoreForTest
(t *testing.T)
internal/store/store_test.go:12
↓ 17 callersMethodtelegramBindCodeState
telegramBindCodeState checks the status of a bind code. If uid is non-zero (user scene), it also verifies the bind code belongs to that user and check
internal/api/telegram_bind_status.go:30
↓ 16 callersMethodUpsertInviteCode
(code InviteCode)
internal/store/store.go:3327
↓ 15 callersMethodDeveloperModeEnabled
()
internal/store/store.go:3312
↓ 15 callersFunctionexpireStatus
(expiredAt int64)
internal/api/app.go:1444
↓ 15 callersFunctionjobParamBool
(params map[string]any, key string, fallback bool)
internal/api/scheduler_runner.go:780
↓ 15 callersFunctionnullableInt
(v int64)
internal/api/app.go:1424
↓ 15 callersFunctionuseConfirm
()
webui/src/components/ui/confirm-dialog.tsx:173
↓ 14 callersMethodServeHTTP
(w http.ResponseWriter, r *http.Request)
internal/api/app.go:574
↓ 14 callersFunctiondeveloperJSBoolOption
(input any, key string)
internal/api/telegram_js_commands.go:1507
↓ 14 callersMethoddisableRemoteEmbyForWebState
(ctx context.Context, u store.User)
internal/api/emby.go:381
↓ 13 callersMethodAddSchedulerRunReturning
(run SchedulerRun)
internal/store/scheduler.go:22
↓ 13 callersMethodBackend
()
internal/store/store.go:884
↓ 13 callersFunctionHashPassword
(password string)
internal/security/password.go:39
↓ 13 callersMethodListRegCodes
()
internal/store/store.go:3773
↓ 13 callersMethodParentOf
(uid int64)
internal/store/store.go:3530
↓ 13 callersMethodZapLevel
()
internal/config/config.go:1470
↓ 13 callersMethodbindCode
(code string)
internal/api/telegram_bind_status.go:122
↓ 13 callersFunctionconfigValues
(cfg config.Config)
internal/api/config_admin.go:1152
↓ 13 callersFunctiondeveloperJSAdminUser
(user *store.User, logs *[]string, action string)
internal/api/telegram_js_commands.go:1024
↓ 13 callersFunctionlistValue
(value string)
internal/config/config.go:1518
next →1–100 of 2,686, ranked by callers