mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
some change
This commit is contained in:
1 parent
715f2afb61
commit
a5d24dfc93
3 files changed
+11
-5
No files matched your search
@@ -136,6 +136,9 @@ export class TrackOptionsManager {
|
||||
const identifier = TrackOptionsManager.makeTrackIdentifier(track);
|
||||
if (!identifier) return null;
|
||||
|
||||
const safeStartMs = Number.isFinite(startMs) ? Math.max(0, Math.trunc(startMs)) : 0;
|
||||
const safeEndMs = Number.isFinite(endMs) ? Math.max(0, Math.trunc(endMs)) : 0;
|
||||
|
||||
const safeAlias = TrackOptionsManager.sanitizeAlias(alias);
|
||||
const title = (track.title || "").slice(0, 512);
|
||||
const bi = this._botIdInsert();
|
||||
@@ -143,11 +146,11 @@ export class TrackOptionsManager {
|
||||
try {
|
||||
await this._query(
|
||||
`INSERT INTO track_options (user_id, track_identifier, track_title, alias, start_ms, end_ms${bi.col})
|
||||
VALUES (${mysql.escape(userId)}, ${mysql.escape(identifier)}, ${mysql.escape(title)}, ${mysql.escape(safeAlias)}, ${startMs}, ${endMs}${bi.val})
|
||||
ON DUPLICATE KEY UPDATE start_ms = ${startMs}, end_ms = ${endMs}, track_title = ${mysql.escape(title)}`
|
||||
VALUES (${mysql.escape(userId)}, ${mysql.escape(identifier)}, ${mysql.escape(title)}, ${mysql.escape(safeAlias)}, ${safeStartMs}, ${safeEndMs}${bi.val})
|
||||
ON DUPLICATE KEY UPDATE start_ms = ${safeStartMs}, end_ms = ${safeEndMs}, track_title = ${mysql.escape(title)}`
|
||||
);
|
||||
this._cache.delete(`${userId}:${identifier}:${safeAlias}`);
|
||||
return { identifier, startMs, endMs, alias: safeAlias };
|
||||
return { identifier, startMs: safeStartMs, endMs: safeEndMs, alias: safeAlias };
|
||||
} catch (err) {
|
||||
logger.error("[TrackOptions] set error:", err.message);
|
||||
return null;
|
||||
|
||||
+3
-1
@@ -184,7 +184,9 @@ export class Utils {
|
||||
if (str === null || str === undefined || str === "") return false;
|
||||
if (typeof str === "number") return !isNaN(str) && isFinite(str);
|
||||
if (typeof str !== "string") return false;
|
||||
return !isNaN(str) && isFinite(str);
|
||||
const trimmed = str.trim();
|
||||
if (trimmed === "") return false;
|
||||
return !isNaN(trimmed) && isFinite(trimmed);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -193,9 +193,10 @@ export class Locale {
|
||||
|
||||
for (const [placeholder, val] of Object.entries(replacements)) {
|
||||
const escaped = placeholder.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
const replacement = String(val ?? "");
|
||||
value = value.replace(
|
||||
new RegExp(`\\{\\{${escaped}\\}\\}`, "g"),
|
||||
String(val ?? "")
|
||||
() => replacement
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user