Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Prejudice-Studio/Twilight
/ functions
Functions
2,686 in github.com/Prejudice-Studio/Twilight
⨍
Functions
2,686
◇
Types & classes
267
↓ 13 callers
Method
telegramPost
(ctx context.Context, method string, body map[string]any, dst any)
internal/api/telegram.go:96
↓ 13 callers
Method
telegramProtectedTarget
(u store.User)
internal/api/telegram_inline.go:796
↓ 12 callers
Method
InviteCode
(code string)
internal/store/store.go:3351
↓ 12 callers
Method
ListAnnouncements
(includeHidden bool)
internal/store/store.go:2891
↓ 12 callers
Method
PlaybackRecords
(uid int64, since int64, limit int)
internal/store/playback.go:52
↓ 12 callers
Method
Read
()
internal/config/reader.go:20
↓ 12 callers
Method
SchedulerRuns
(jobID string, limit int)
internal/store/scheduler.go:70
↓ 12 callers
Function
describePostgresConnectionError
(info postgresInfo, err error)
internal/store/store.go:695
↓ 12 callers
Function
developerJSOptionString
developerJSOptionString reads the first matching key as a trimmed-free string (no trim, callers trim where needed), returning "" when none are present
internal/api/telegram_js_generators.go:466
↓ 12 callers
Function
developerJSUserSnapshot
(user store.User)
internal/api/telegram_js_commands.go:346
↓ 12 callers
Function
emailConfigured
emailConfigured 判定邮箱子系统是否可用:总开关开启 + 有 SMTP 主机 + 有可用的 发件地址(from_address 或回退 smtp_username)。前端入口展示、后端发码守卫都以 此为准,避免 force_bind=true 却没配 SMTP 把用户锁死在仪表盘外。
internal/api/email_client.go:21
↓ 12 callers
Method
embyDelete
(ctx context.Context, apiPath string)
internal/api/emby_client.go:112
↓ 12 callers
Function
emptyNil
(value string)
internal/api/business.go:1366
↓ 12 callers
Method
ensure
()
internal/store/store.go:905
↓ 12 callers
Function
normalizeEmailKey
(email string)
internal/store/email_verification.go:48
↓ 12 callers
Function
normalizeRegCodeDays
normalizeRegCodeDays 规范化卡码天数的历史哨兵语义,必须与 addDaysToExpiry / expiryFromDays 的口径一致: - days == 0(或字段未设):历史默认值,按 30 天处理; - days < 0:永久(-1 是唯一的"永久"哨兵); - day
internal/api/business.go:219
↓ 12 callers
Function
sanitizeImageUrl
(url?: string | null)
webui/src/lib/safe-url.ts:7
↓ 12 callers
Method
stringListValue
(fallback []string, keys ...string)
internal/config/config.go:1278
↓ 11 callers
Method
PostgresDSN
()
internal/config/config.go:1678
↓ 11 callers
Function
addBatchOutcome
addBatchOutcome 累加单条 outcome 到批量响应里。code 可空字符串,表示"未携 带结构化码"——这种调用点应当尽快迁移到具名 ErrCode(参见 R64-8)。前端约 定按 errors[].code 做 switch,errors[].error 仅作运维日志用文案。
internal/api/business.go:1401
↓ 11 callers
Function
dailySpec
(value string, fallbackHour, fallbackMinute int)
internal/api/scheduler_daemon.go:437
↓ 11 callers
Function
max
(a, b int)
internal/api/business.go:36
↓ 11 callers
Method
rawValue
(keys ...string)
internal/config/config.go:1112
↓ 11 callers
Method
recordRegisterBindFailure
(bind store.BindCode, code string, status string, errorCode ErrCode, httpStatus int, message string)
internal/api/telegram_bind_status.go:108
↓ 11 callers
Method
rejectRegcodeWriteIfStorageMismatch
(w http.ResponseWriter)
internal/api/storage_guard.go:51
↓ 11 callers
Method
runSchedulerJob
(r *http.Request, jobID string)
internal/api/scheduler_runner.go:98
↓ 11 callers
Method
telegramAnswerCallbackQuery
(ctx context.Context, callbackID, text string, showAlert bool)
internal/api/telegram.go:219
↓ 11 callers
Method
upsertBindCode
(bind store.BindCode)
internal/api/telegram_bind_status.go:129
↓ 10 callers
Method
Do
(ctx context.Context, args ...string)
internal/redis/redis.go:145
↓ 10 callers
Method
PutEmailVerification
PutEmailVerification 原子地清掉同一 (purpose,email) 下的旧记录再写入新记录, 保证每个用途+邮箱最多只有一份在用验证码(重复发码不累积,最新码生效)。
internal/store/email_verification.go:54
↓ 10 callers
Method
configFilePath
()
internal/api/config_admin.go:604
↓ 10 callers
Function
created
(w http.ResponseWriter, message string, data any)
internal/api/response.go:89
↓ 10 callers
Method
embyApplyEnabledState
embyApplyEnabledState 启停 Emby 后把状态镜像回本地 EmbyDisabled,让用户列表无需逐行 查 Emby 即可展示真实的 Emby 启停。uid 已知时走 O(1) 的 UpdateUser,刻意不用按 EmbyID 的线性扫描,避免在批量/调度场景退化成 O(n^
internal/api/emby.go:359
↓ 10 callers
Method
embyPost
(ctx context.Context, apiPath string, body any, dst any)
internal/api/emby_client.go:100
↓ 10 callers
Method
handleRenew
(w http.ResponseWriter, r *http.Request, _ Params)
internal/api/handlers.go:457
↓ 10 callers
Method
handleUseCode
(w http.ResponseWriter, r *http.Request, _ Params)
internal/api/code_use_handlers.go:13
↓ 10 callers
Function
inventoryResult
(exists bool, message string, item map[string]any, seasons []int, season int)
internal/api/emby_inventory.go:195
↓ 10 callers
Method
protectedUserReason
(u store.User)
internal/api/business.go:158
↓ 10 callers
Function
randomFromAlphabet
(alphabet string, length int)
internal/api/business.go:783
↓ 10 callers
Function
renderConfigTOML
(values map[string]map[string]any)
internal/api/config_admin.go:1277
↓ 10 callers
Function
telegramChatIDs
(values []string)
internal/api/telegram.go:450
↓ 10 callers
Method
telegramRenderText
(text string)
internal/api/telegram_bot.go:1097
↓ 9 callers
Method
ConsumeInviteCode
(code string, childUID int64)
internal/store/store.go:3406
↓ 9 callers
Method
ListDevices
(uid int64)
internal/store/device.go:24
↓ 9 callers
Method
ListMediaRequests
(uid int64, all bool)
internal/store/store.go:2695
↓ 9 callers
Function
New
(cfg config.Config, st *store.Store)
internal/api/app.go:221
↓ 9 callers
Method
SetUserActiveAtomic
SetUserActiveAtomic 与 SetUserRoleAtomic 同理,处理"禁用最后一个 active admin"。 解决 handleAdminToggleUser 把"是否最后 admin"放在闭包外快照读取的问题。
internal/store/store.go:2166
↓ 9 callers
Method
Ticket
(id int64)
internal/store/store.go:3074
↓ 9 callers
Method
TicketTypes
TicketTypes 返回当前工单类型列表。
internal/store/store.go:3220
↓ 9 callers
Function
ValidateEmailFormat
(email string)
internal/validate/validate.go:99
↓ 9 callers
Method
clear
(code string)
internal/api/bind_status_hub.go:184
↓ 9 callers
Function
createTicket
(t *testing.T, app *App, title, content string, cookies []*http.Cookie)
internal/api/ticket_handlers_test.go:70
↓ 9 callers
Function
formatSeconds
(seconds int64)
internal/api/business.go:1420
↓ 9 callers
Function
formatTimestamp
(seconds: number | null | undefined)
webui/src/app/(main)/admin/scheduler/page.tsx:56
↓ 9 callers
Method
handleTelegramUpdate
(ctx context.Context, update map[string]any)
internal/api/telegram_bot.go:184
↓ 9 callers
Function
markRegistrationGrant
(u *store.User, source, code string)
internal/api/business.go:229
↓ 9 callers
Method
maxCodeDays
(user store.User)
internal/api/business.go:1120
↓ 9 callers
Function
normalizeBindStatusCode
(code string)
internal/api/bind_status_hub.go:229
↓ 9 callers
Method
notifyLocked
(code string)
internal/api/bind_status_hub.go:220
↓ 9 callers
Function
renewExpiryAndReactivate
renewExpiryAndReactivate 把"续期"语义统一成一个动作:bump ExpiredAt 同时 在新到期时刻仍然有效(> now)的前提下复位 Active=true。 历史背景:check_expired 调度对**非邀请**用户会直接 `Active=false`(参见 s
internal/api/business.go:322
↓ 9 callers
Function
roleName
(role int)
internal/api/app.go:1431
↓ 9 callers
Method
saveConfigContent
(content string)
internal/api/config_admin.go:388
↓ 9 callers
Method
telegramAdminID
(telegramID int64)
internal/api/telegram_bot.go:974
↓ 9 callers
Method
telegramTouchPanel
(panel telegramPanelContext)
internal/api/telegram_inline.go:216
↓ 9 callers
Method
toAbsoluteAssetUrl
(url?: string | null)
webui/src/lib/api.ts:131
↓ 9 callers
Function
uploadTicketImage
uploadTicketImage 通过 multipart 上传一张图片,返回响应记录。
internal/api/ticket_handlers_test.go:47
↓ 9 callers
Function
validatePasswordStrength
( password: string, label = "新密码" )
webui/src/lib/password.ts:11
↓ 8 callers
Method
ConsumeEmailVerificationAtomic
ConsumeEmailVerificationAtomic 校验候选哈希并按结果原子更新状态: - 过期:删除记录,返回 Expired; - 命中:删除记录(消费),返回 OK; - 不命中且尝试未达上限:Attempts+1 落盘,返回 Mismatch; - 不命中且达上限:删除记录,返回
internal/store/email_verification.go:101
↓ 8 callers
Function
InstallRuntimeLogger
(w io.Writer, level zapcore.Level)
internal/api/runtime_logs.go:295
↓ 8 callers
Method
ListAllInviteCodes
()
internal/store/store.go:3358
↓ 8 callers
Method
WriteHeader
(status int)
internal/api/app.go:169
↓ 8 callers
Method
append
(entry RuntimeLogEntry)
internal/api/runtime_logs.go:100
↓ 8 callers
Function
bangumiEndpoint
(base, path string, values url.Values)
internal/api/bangumi_client.go:62
↓ 8 callers
Function
cleanupSchedulerRuntimeConfig
(t: TFunc, jobID: string)
webui/src/app/(main)/admin/scheduler/page.tsx:169
↓ 8 callers
Function
configSectionDefs
()
internal/api/config_admin.go:917
↓ 8 callers
Function
developerJSOptionInt
developerJSOptionInt reads the first matching key from an exported JS options object as an int, falling back to the supplied default when absent.
internal/api/telegram_js_generators.go:455
↓ 8 callers
Method
embyShouldEnableUser
(u store.User)
internal/api/emby.go:421
↓ 8 callers
Function
enableTicketSystem
enableTicketSystem 在运行时打开工单系统并按需覆盖并发上限 / 图片限制。 直接走 runtime.Store 替换 cfg,原因同 TestSessionCookieRespectsConfiguredDomain: New() 之后 cfg 副本存在 runtimeState
internal/api/ticket_handlers_test.go:19
↓ 8 callers
Function
getJSON
(ctx context.Context, endpoint string, headers map[string]string, dst any)
internal/api/http_json_client.go:74
↓ 8 callers
Method
hashEmailCode
hashEmailCode 用服务端密钥对 (id|code) 做 HMAC-SHA256,返回 hex。store 只存这个 哈希并做定长常量时间比较;即使 state 泄露也读不出明文码,配合短码 + 尝试上限 + 短 TTL,离线爆破窗口受限。
internal/api/email_verify_service.go:71
↓ 8 callers
Function
mustDevice
(t *testing.T, st *Store, d Device)
internal/store/device_limit_test.go:82
↓ 8 callers
Function
normalizeMediaStatus
(status string)
internal/api/business.go:391
↓ 8 callers
Function
passwordStrengthLabel
(score: number)
webui/src/lib/password.ts:55
↓ 8 callers
Function
pngBytes
pngBytes 返回一段最小可被 http.DetectContentType 识别为 image/png 的字节。
internal/api/ticket_handlers_test.go:42
↓ 8 callers
Function
publicExpiryUnix
(expiredAt int64)
internal/api/business.go:189
↓ 8 callers
Function
requireAdmin
requireAdmin 是 admin-only handler 的入口断言。AuthAdmin 路由已在 dispatcher(app.go:611)处把非 admin 阻挡在外,但 handler 自身再确认一次 caller 角色,避免: 1. 路由表手抖把 admin handler 挂
internal/api/app.go:1484
↓ 8 callers
Method
requireEmbyConfigured
requireEmbyConfigured 把"Emby URL 或 Token 未配置 → 写一致的 400 响应"的样板收敛 到一处。同时校验 URL 和 Token:仅配置 URL 而 Token 为空时,所有 Emby API 调用 都会以未鉴权身份发出,可能导致数据泄露或被 Emby 拒绝
internal/api/business.go:334
↓ 8 callers
Method
requireNonEmbyAdmin
(w http.ResponseWriter, r *http.Request, user store.User)
internal/api/emby.go:178
↓ 8 callers
Method
schedulerJobRunning
(jobID string)
internal/api/scheduler_daemon.go:485
↓ 8 callers
Method
snapshot
(limit int, after int64)
internal/api/runtime_logs.go:136
↓ 8 callers
Function
stop
()
webui/src/hooks/use-bind-code-status.ts:86
↓ 8 callers
Function
telegramCommand
(raw string)
internal/api/telegram_bot.go:994
↓ 8 callers
Function
telegramYesNoLabel
(ok bool)
internal/api/telegram_bot.go:1183
↓ 8 callers
Function
writeWebSocketClose
(conn net.Conn)
internal/api/websocket.go:66
↓ 7 callers
Function
ConfigureRuntimeLogging
(level zapcore.Level, limit int)
internal/api/runtime_logs.go:313
↓ 7 callers
Method
Create
(ctx context.Context, uid int64)
internal/api/session.go:111
↓ 7 callers
Method
SetUserEmailVerifiedAtomic
SetUserEmailVerifiedAtomic 绑定邮箱并设置验证状态。约定: - email 非空则更新 User.Email;为空则保留现有邮箱(用于仅切换验证态)。 - verified=true 且 force=false 时做占用冲突校验(其它已验证账号占用 → ErrConflic
internal/store/email_verification.go:291
↓ 7 callers
Method
UserCount
()
internal/store/store.go:1636
↓ 7 callers
Method
UserLatestRebindRequest
UserLatestRebindRequest returns the most recent rebind request for a user, regardless of status. Returns (request, true) if found, or (zero, false) if
internal/store/store.go:3898
↓ 7 callers
Function
ValidateUsername
ValidateUsername 校验用户名。
internal/validate/validate.go:42
← previous
next →
101–200 of 2,686, ranked by callers