MCPcopy Create free account

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

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

↓ 5 callersFunctionmediaResultFromFields
(source, id, title, mediaType, poster string)
internal/api/media_service.go:108
↓ 5 callersFunctionnewEmailTestApp
newEmailTestApp 构造一个开启邮箱子系统 + 强制绑定的 App,用于测试 gate 与验证码 HMAC/消费流程。SMTP 主机虽配但测试里不真正发信(只调 hash / verify / gate)。
internal/api/email_verify_service_test.go:14
↓ 5 callersFunctionnewRuntimeLogSink
(limit int)
internal/api/runtime_logs.go:63
↓ 5 callersFunctionnewSetupTestApp
(t *testing.T)
internal/api/setup_handlers_test.go:16
↓ 5 callersFunctionnormalizeCORSOrigin
(raw string)
internal/api/app.go:1065
↓ 5 callersFunctionnormalizeProbeURL
(raw string)
internal/api/emby_url_probe.go:62
↓ 5 callersFunctionnormalizeSource
(source string)
internal/api/business.go:380
↓ 5 callersFunctionreadLine
(r *bufio.Reader)
internal/redis/redis.go:325
↓ 5 callersFunctionregcodeTargetLabel
(code: Regcode)
webui/src/app/(main)/admin/regcodes/page.tsx:709
↓ 5 callersFunctionregcodeUsedByLabel
(code: Regcode)
webui/src/app/(main)/admin/regcodes/page.tsx:716
↓ 5 callersFunctionrememberCache
(cache: Map<K, V>, key: K, value: V, limit: number)
webui/src/app/(main)/media/page.tsx:51
↓ 5 callersMethodrequireEmailVerified
requireEmailVerified 是价值型接口的强制门:强制策略下未验证邮箱的普通/白名单 用户被 403 拦截(前端守卫只做体验,这里是不可绕过的服务端防线)。返回 true 表示已写出失败响应,调用方应直接 return。
internal/api/email_handlers.go:34
↓ 5 callersFunctionsafeDevices
(u: EmbyAuditUser)
webui/src/components/admin/emby-device-audit-panel.tsx:87
↓ 5 callersFunctionschedulerSideEffectContext
(parent context.Context)
internal/api/scheduler_runner.go:769
↓ 5 callersFunctionstringSlice
(v any)
internal/api/handlers.go:2914
↓ 5 callersMethodtelegramApplyPanelAction
(ctx context.Context, panel telegramPanelContext, action string)
internal/api/telegram_inline.go:313
↓ 5 callersMethodtelegramFindUsers
(query string, limit int)
internal/api/telegram_bot.go:1104
↓ 5 callersMethodtelegramGetChatMember
(ctx context.Context, chatID string, userID int64)
internal/api/telegram.go:230
↓ 5 callersMethodtelegramGroupUserPanelMarkup
(token string, u store.User, confirmAction string)
internal/api/telegram_inline.go:716
↓ 5 callersMethodtelegramHandleCustomCommand
(ctx context.Context, command string, c telegramCommandCtx, privateChat bool)
internal/api/telegram_js_commands.go:43
↓ 5 callersFunctiontelegramRateLimitPause
telegramRateLimitPause 在批处理(kick / 提醒)路径上充当一行式背压: 看到 telegram 限速错误就 sleep。 两条来源: 1. telegramPost 在 OK=false + parameters.retry_after>0 时把秒数编进错误 字符串(t
internal/api/telegram.go:499
↓ 5 callersMethodtelegramRuntimeStatus
()
internal/api/telegram.go:85
↓ 5 callersMethodtelegramSendMessageWithMarkup
(ctx context.Context, chatID any, text string, replyMarkup any)
internal/api/telegram.go:164
↓ 5 callersFunctiontelegramUserList
(users []store.User)
internal/api/telegram_bot.go:1154
↓ 5 callersFunctionupdateRow
(id: string, patch: Partial<CommandRow>)
webui/src/app/(main)/admin/telegram/commands/page.tsx:160
↓ 5 callersFunctionuserEntitlementOK
userEntitlementOK 是"消费 entitlement"接口(生成邀请码 / 续期码 / API Key / 媒体库自助修改)共用的 gate:账号 Active 且未过期。当前 maxCodeDays 已经隐 式地把第二个条件做了(ExpiredAt <= now 返回 0),但散落
internal/api/business.go:1110
↓ 5 callersFunctionuserExpiredOnly
userExpiredOnly 判定"Active=false 是否纯由 ExpiredAt 触发"。check_expired 调度对非邀请用户的处理是"同时 Active=false + 落 ExpiredAt 在过去",与 admin 手动禁用(Active=false 但 ExpiredAt
internal/api/business.go:296
↓ 5 callersFunctionvalidateDeveloperJSCommand
(code string)
internal/api/developer_handlers.go:226
↓ 5 callersMethodverifyEmailCodeByID
verifyEmailCodeByID 用 verification_id + code 校验(登录态绑定 / 改密路径)。
internal/api/email_verify_service.go:230
↓ 4 callersMethodAddBangumiSyncLog
(entry BangumiSyncLog)
internal/store/store.go:4325
↓ 4 callersMethodAddIPBlacklist
(ip, reason string, expireAt int64)
internal/store/ip_blacklist.go:8
↓ 4 callersMethodAddSignin
(uid int64, points int)
internal/store/signin.go:14
↓ 4 callersMethodAddSigninWithOptions
(uid int64, dailyPoints int, bonusForStreak func(int) int, resetAfterMiss bool)
internal/store/signin.go:18
↓ 4 callersFunctionBackupMetaPath
(path string)
internal/store/store.go:1486
↓ 4 callersMethodBindCode
(code string)
internal/store/store.go:2763
↓ 4 callersFunctionCheckEmailBlacklist
(email string, blacklist []string)
internal/validate/validate.go:112
↓ 4 callersFunctionCheckEmailWhitelist
(email string, whitelist []string)
internal/validate/validate.go:137
↓ 4 callersMethodChildrenOf
(uid int64)
internal/store/store.go:3537
↓ 4 callersMethodClosedTicketsWithAttachmentsBefore
ClosedTicketsWithAttachmentsBefore 返回所有已关闭且 ClosedAt 早于 cutoff 的工单, 用于定时清理过期的工单交流图片。
internal/store/store.go:3188
↓ 4 callersMethodConfigurePostgres
(maxOpen, maxIdle int)
internal/store/store.go:872
↓ 4 callersMethodDelete
(ctx context.Context, token string)
internal/api/session.go:216
↓ 4 callersMethodEnforceDeviceLimit
EnforceDeviceLimit 仅保留某用户最近活跃的 max 台设备(按 LastSeen 倒序),淘汰 更旧的「未受信任」设备。约定(防误踢/防锁死): - max<=0 视为不限制,直接返回; - 受信任设备(Trusted)永不淘汰,即使超出名额; - 刚登录的设备 LastSeen
internal/store/device.go:72
↓ 4 callersMethodEnsureForMigration
()
internal/store/store.go:1060
↓ 4 callersMethodFallbackCount
FallbackCount 报告自启动以来 redis session 失败回退到内存 / postgres 的累计 次数。值持续增长意味着 redis 不可用:sessions 仍能通过 postgres 维持登录, 但跨副本 ttl 同步不再走 redis;运维应优先恢复 redis。
internal/api/session.go:325
↓ 4 callersMethodFindMediaRequestByKey
(key string)
internal/store/store.go:2708
↓ 4 callersMethodFindUserByEmailVerified
FindUserByEmailVerified 按"已验证邮箱"精确命中账号(登出态找回用)。 只认 EmailVerified=true 的账号:未验证邮箱不足以证明归属,否则把别人邮箱 写成自己的未验证邮箱即可劫持对方账号的找回入口。
internal/store/email_verification.go:272
↓ 4 callersMethodListDeveloperJSPresets
()
internal/store/store.go:2959
↓ 4 callersMethodListInviteCodes
(uid int64)
internal/store/store.go:3369
↓ 4 callersMethodListRebindRequests
(status string)
internal/store/store.go:3859
↓ 4 callersMethodListViolationLogs
ListViolationLogs returns all violation logs, newest first.
internal/store/store.go:4181
↓ 4 callersMethodMediaRequest
(id int64)
internal/store/store.go:2688
↓ 4 callersMethodRelease
()
internal/store/flock_unix.go:49
↓ 4 callersMethodSchedulerRunSnapshot
(jobID string, limit int)
internal/store/scheduler.go:88
↓ 4 callersMethodSetUserRoleAtomic
SetUserRoleAtomic 在同一把写锁内做 last-admin 计数 + 写入。 解决了原 handleAdminUpdateUser / handleAdminSetRole 把"读 ListUsers 计数" 与"UpdateUser 闭包"分两段执行导致的 TOCTOU:两个 ad
internal/store/store.go:2133
↓ 4 callersMethodUpsertDeveloperJSPreset
(p DeveloperJSPreset)
internal/store/store.go:2923
↓ 4 callersMethodUpsertDevice
(d Device)
internal/store/device.go:8
↓ 4 callersFunctionWriteFileAtomicSync
WriteFileAtomicSync 是 writeFileAtomicSync 的导出别名,供 api 层数据库迁移 等需要落地"用户可恢复备份"的路径复用同一份原子写盘语义。
internal/store/store.go:1523
↓ 4 callersMethodauditDeveloperJSInteraction
(telegramID int64, action string, detail map[string]any)
internal/api/telegram_js_interactions.go:238
↓ 4 callersFunctionbase32Code
(length int)
internal/api/business.go:779
↓ 4 callersFunctionbindCodeCreateTestHeaders
()
internal/api/app_test.go:5416
↓ 4 callersFunctionbindStateExpiryWait
(state telegramBindCodeState)
internal/api/handlers.go:811
↓ 4 callersFunctioncanAccessMediaRequest
(user store.User, req store.MediaRequest)
internal/api/business.go:436
↓ 4 callersMethodcanInvite
(user store.User)
internal/api/business.go:1253
↓ 4 callersFunctioncanonicalConfigSection
canonicalConfigSection 把 TOML 里出现的 section 名归一到 configSectionDefs 使用 的规范 Key(大小写不敏感匹配)。无法匹配时原样返回,交给 isSecretField 自然 落空(非 secret)。
internal/api/config_admin.go:157
↓ 4 callersFunctioncategoryLabel
(locale: TextLocale, category: string)
webui/src/components/developer-js-docs-panel.tsx:852
↓ 4 callersFunctionclamp
(value: number, min: number, max: number)
webui/src/lib/theme-custom.ts:31
↓ 4 callersMethodcloneResponse
(response: ApiResponse<T>)
webui/src/lib/api.ts:120
↓ 4 callersMethodconfiguredAdminMatch
(uid int64, username string)
internal/api/configured_admins.go:34
↓ 4 callersMethodconsumableRegCodeLocked
(code string, now int64)
internal/store/store.go:3743
↓ 4 callersMethodconsumeRegCodeLocked
(r RegCode, uid, telegramID int64)
internal/store/store.go:3757
↓ 4 callersFunctioncontainsInt64
(xs []int64, v int64)
internal/store/store_test.go:151
↓ 4 callersMethoddatabaseMigrationSummary
(driver string, state store.State, dryRun bool, snapshotBytes int, targetReady map[string]any)
internal/api/database_admin.go:354
↓ 4 callersFunctiondatabaseStateCounts
(state store.State)
internal/api/database_admin.go:395
↓ 4 callersFunctiondelAccountPendingKey
(chatID, fromID int64)
internal/api/telegram_bot.go:31
↓ 4 callersMethoddeleteBindCode
(code string)
internal/api/telegram_bind_status.go:136
↓ 4 callersMethoddeveloperJSGetUserByUID
(vm *goja.Runtime, current *store.User, uidValue goja.Value, logs *[]string)
internal/api/telegram_js_commands.go:458
↓ 4 callersFunctiondeveloperJSLimit
(limit int, fallback int, max int)
internal/api/telegram_js_commands.go:1060
↓ 4 callersFunctiondeveloperJSSafeError
(err error)
internal/api/telegram_js_commands.go:332
↓ 4 callersMethoddeveloperJSSearchUsers
(user *store.User, query string, limit int, logs *[]string)
internal/api/telegram_js_commands.go:1070
↓ 4 callersMethoddeveloperJSSetUserActive
(vm *goja.Runtime, actor *store.User, opts developerJSRunOptions, logs *[]string, uidValue goja.Value, activeV
internal/api/telegram_js_commands.go:1146
↓ 4 callersMethoddisableRemoteEmbyForUnbind
(w http.ResponseWriter, r *http.Request, embyID string)
internal/api/business.go:266
↓ 4 callersFunctiondoJSONRequestWithTimeout
doJSONRequestWithTimeout 把 timeout 包成 context deadline 后用共享 client 发送, 既能复用连接池又能保留每端点不同的超时语义。 边界:req 已经携带 ctx(NewRequestWithContext),如果调用方 ctx 已带 dead
internal/api/http_json_client.go:133
↓ 4 callersMethodembyCapacityReachedExcluding
(excludeUID int64, excludeRegCode, excludeInviteCode string)
internal/api/business.go:103
↓ 4 callersMethodembyHealth
embyHealth 统一封装 emby 健康探活:先 /System/Info/Public(无需鉴权), 失败再 /System/Info(带 token 鉴权),把"双段 fallback"集中一处。 之前同样的 if/else 分散在 admin_extra.go / handlers.go
internal/api/emby.go:156
↓ 4 callersFunctionembyItemQuery
(params map[string]string)
internal/api/emby_inventory.go:291
↓ 4 callersFunctionembyRemoteID
(user map[string]any)
internal/api/scheduler_runner.go:720
↓ 4 callersFunctionembyRetryOn5xx
embyRetryOn5xx 把幂等的 emby 操作(GET/PUT policy/state 同步)包一层 "5xx + 网络抖动重试 2 次"。 为什么需要:emby_sync 调度会对需要收回权限的本地用户调用 embySetUserEnabled, 里面走 /Users/<id>/Pol
internal/api/emby.go:42
↓ 4 callersFunctionemitRegionRefresh
(region: string, payload?: RefreshPayload)
webui/src/lib/region-refresh.ts:6
↓ 4 callersFunctionemptyState
()
internal/store/store.go:899
↓ 4 callersMethodenforceTelegramMembership
(ctx context.Context, autoEnableRejoined bool)
internal/api/admin_jobs.go:28
↓ 4 callersFunctionensureTicketDefaults
(values map[string]map[string]any)
internal/api/config_admin.go:541
↓ 4 callersFunctionfillDeviceIPsFromHistory
fillDeviceIPsFromHistory 用历史登录 IP 回填没有实时会话 IP 的(通常是离线)设备。 Emby /Devices 不带 IP,离线设备拿不到实时会话 IP,但管理员审查时仍想知道这台设备 大致来自哪个 IP。两种回填都标记 ip_approx=true(推断值,非实时会
internal/api/emby_device_audit.go:111
↓ 4 callersFunctionfilterNavItems
( items: SidebarNavItem[], features?: Record<string, boolean> | null, )
webui/src/components/layout/sidebar.tsx:101
↓ 4 callersFunctionfirstNonEmpty
(values ...string)
internal/config/config.go:1446
↓ 4 callersFunctionformatBytes
(value?: number)
webui/src/app/(main)/admin/logs/page.tsx:45
↓ 4 callersFunctionformatBytes
(value?: number)
webui/src/app/(main)/admin/database/page.tsx:44
↓ 4 callersFunctionformatBytes
(bytes: number | undefined, unknown: string)
webui/src/app/(main)/admin/stats/page.tsx:34
↓ 4 callersFunctionformatConfigPreviewValue
(field: ConfigField, value: unknown, t: Translate)
webui/src/app/(main)/admin/config/page.tsx:203
↓ 4 callersFunctionformatRegcodeDays
(days: number)
webui/src/app/(main)/admin/regcodes/page.tsx:121
↓ 4 callersMethodgetBangumiUserCollections
(ctx context.Context, username string, token string, collectType int, limit int, offset int)
internal/api/bangumi_client.go:169
← previousnext →301–400 of 2,686, ranked by callers