levix-bot 4.9.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -3
- package/SETUP.md +63 -7
- package/app.cjs +159 -46
- package/deploy/install.sh +10 -5
- package/package.json +9 -6
- package/public/dashboard/assets/40af6d88b63079a0-BZ8ojJNu.woff2 +0 -0
- package/public/dashboard/assets/481acf6760031cee-BypgxfGb.woff2 +0 -0
- package/public/dashboard/assets/6d3351fc535f8ef3-D2-eand5.woff2 +0 -0
- package/public/dashboard/assets/8ab0af53a3bda9d3-CyCXRvzh.woff2 +0 -0
- package/public/dashboard/assets/8f262393e9249e61-TQp-UTiE.woff2 +0 -0
- package/public/dashboard/assets/94d65887a83f1282-DmpS2jIq.woff2 +0 -0
- package/public/dashboard/assets/99e400330f36ae77-D3oMJlXt.woff2 +0 -0
- package/public/dashboard/assets/9d1f41b13e519d90-BVNSOH3d.woff2 +0 -0
- package/public/dashboard/assets/a005256cb957ecc7-CoYeBiSI.woff2 +0 -0
- package/public/dashboard/assets/b19c2080652a3c2b-DIC32ArD.woff2 +0 -0
- package/public/dashboard/assets/c4064400db3750ce-BehTv68k.woff2 +0 -0
- package/public/dashboard/assets/c69d345fa1068c2d-CmI34b-g.woff2 +0 -0
- package/public/dashboard/assets/cc27b30471250057-6fWv1k7M.woff2 +0 -0
- package/public/dashboard/assets/d8c30647abfeffe6-eXO_dkmS.woff2 +0 -0
- package/public/dashboard/assets/eb83d8d40af4411f-Buze_B52.woff2 +0 -0
- package/public/dashboard/assets/effc6711249e7349-qRpaaN48.woff2 +0 -0
- package/public/dashboard/assets/gateway-BDYet0pI.css +1 -0
- package/public/dashboard/assets/gateway-BYt6-s1O.js +1 -0
- package/public/dashboard/assets/index-B9wFpD_z.css +2 -0
- package/public/dashboard/assets/index-DWcQmu0_.js +124 -0
- package/public/dashboard/assets/index-Da-j89O-.js +458 -0
- package/public/dashboard/font-licenses/jetbrainsmono-OFL.txt +93 -0
- package/public/dashboard/font-licenses/plusjakartasans-OFL.txt +93 -0
- package/public/dashboard/font-licenses/tajawal-OFL.txt +93 -0
- package/public/dashboard/gateway.html +17 -0
- package/public/dashboard/index.html +3 -5
- package/public/ui-boot.js +33 -14
- package/scheduler.cjs +76 -23
- package/src/auth/auth-storage.cjs +54 -7
- package/src/auth/use-database-auth-state.js +70 -39
- package/src/automation/engine.js +412 -0
- package/src/automation/limits.cjs +6 -0
- package/src/automation/manage.js +290 -0
- package/src/automation/reactions.js +471 -0
- package/src/automation/rules.cjs +114 -0
- package/src/automation/status.cjs +76 -0
- package/src/backup/account.cjs +29 -0
- package/src/backup/activation.cjs +247 -0
- package/src/backup/content.cjs +36 -0
- package/src/backup/create.cjs +280 -0
- package/src/backup/extensions.cjs +101 -0
- package/src/backup/format.cjs +565 -0
- package/src/backup/jobs.cjs +111 -0
- package/src/backup/journal.cjs +41 -0
- package/src/backup/plan.cjs +223 -0
- package/src/backup/recovery.cjs +110 -0
- package/src/backup/restore.cjs +460 -0
- package/src/backup/uploads.cjs +146 -0
- package/src/bootstrap/core.js +50 -12
- package/src/bootstrap/panel.js +53 -2
- package/src/bootstrap/session-startup-policy.js +8 -1
- package/src/cli.js +163 -22
- package/src/commands/autodelete.cjs +41 -57
- package/src/commands/autoschedule.cjs +7 -33
- package/src/commands/blacklist.cjs +17 -35
- package/src/commands/block.cjs +4 -18
- package/src/commands/calc.cjs +22 -74
- package/src/commands/debt.cjs +28 -59
- package/src/commands/deleteschedule.cjs +7 -23
- package/src/commands/digit.cjs +5 -39
- package/src/commands/gemini.cjs +135 -218
- package/src/commands/group/add.cjs +28 -76
- package/src/commands/group/all.cjs +4 -15
- package/src/commands/group/antilink.cjs +28 -41
- package/src/commands/group/antispam.cjs +25 -35
- package/src/commands/group/approveall.cjs +7 -21
- package/src/commands/group/clearwarns.cjs +4 -18
- package/src/commands/group/deletenote.cjs +4 -18
- package/src/commands/group/demote.cjs +6 -23
- package/src/commands/group/flagged.cjs +10 -19
- package/src/commands/group/kick.cjs +26 -36
- package/src/commands/group/media.cjs +21 -36
- package/src/commands/group/members.cjs +16 -28
- package/src/commands/group/note.cjs +3 -14
- package/src/commands/group/policy.cjs +16 -37
- package/src/commands/group/promote.cjs +5 -22
- package/src/commands/group/removeall.cjs +6 -38
- package/src/commands/group/rules.cjs +4 -19
- package/src/commands/group/save.cjs +4 -18
- package/src/commands/group/setname.cjs +5 -19
- package/src/commands/group/setpp.cjs +8 -26
- package/src/commands/group/setrules.cjs +4 -15
- package/src/commands/group/setwarn.cjs +6 -23
- package/src/commands/group/tagadmins.cjs +5 -16
- package/src/commands/group/warn.cjs +5 -16
- package/src/commands/group/warns.cjs +12 -33
- package/src/commands/group/welcome.cjs +17 -34
- package/src/commands/group.cjs +91 -68
- package/src/commands/help.cjs +48 -89
- package/src/commands/lang.cjs +38 -97
- package/src/commands/listschedules.cjs +19 -30
- package/src/commands/loop.cjs +9 -55
- package/src/commands/md.cjs +2 -13
- package/src/commands/memory.cjs +53 -87
- package/src/commands/mod.cjs +40 -79
- package/src/commands/notes.cjs +4 -15
- package/src/commands/pack.cjs +26 -49
- package/src/commands/packs.cjs +8 -18
- package/src/commands/perm.cjs +48 -51
- package/src/commands/ping.cjs +2 -10
- package/src/commands/poll.cjs +5 -38
- package/src/commands/prayer.cjs +55 -36
- package/src/commands/qr.cjs +4 -18
- package/src/commands/rand.cjs +9 -58
- package/src/commands/restart.cjs +15 -33
- package/src/commands/schedule.cjs +5 -25
- package/src/commands/score.cjs +6 -27
- package/src/commands/send.cjs +4 -18
- package/src/commands/setprefix.cjs +11 -23
- package/src/commands/shortlink.cjs +13 -39
- package/src/commands/status.cjs +188 -76
- package/src/commands/sticker.cjs +5 -16
- package/src/commands/stickers.cjs +16 -20
- package/src/commands/stopbot.cjs +9 -25
- package/src/commands/stt.cjs +75 -107
- package/src/commands/todo.cjs +11 -31
- package/src/commands/toimage.cjs +11 -27
- package/src/commands/translate.cjs +53 -36
- package/src/commands/tts.cjs +46 -40
- package/src/commands/unblock.cjs +3 -17
- package/src/commands/update.cjs +23 -0
- package/src/commands/weather.cjs +40 -47
- package/src/config/ai-identity.cjs +14 -1
- package/src/config/baileys.config.js +16 -3
- package/src/config/data-dir.cjs +37 -0
- package/src/config/defaults.cjs +1 -0
- package/src/config/exit-codes.cjs +11 -0
- package/src/config/lock.cjs +55 -81
- package/src/config/official-links.cjs +61 -0
- package/src/config/paths.cjs +4 -33
- package/src/config/release.cjs +87 -0
- package/src/config/settings.cjs +199 -10
- package/src/core/connection.js +77 -9
- package/src/core/events.js +119 -33
- package/src/core/session.js +536 -84
- package/src/core/socket.js +81 -10
- package/src/db/copy.cjs +136 -0
- package/src/db/db.cjs +241 -36
- package/src/db/startup-guard.js +5 -0
- package/src/db/store.cjs +561 -54
- package/src/diagnostics/baileysLog.cjs +87 -0
- package/src/diagnostics/debugLog.cjs +16 -4
- package/src/diagnostics/device.cjs +4 -2
- package/src/diagnostics/nodeRuntime.cjs +131 -0
- package/src/diagnostics/signalSessionInspect.cjs +38 -0
- package/src/domain/command.js +24 -22
- package/src/extensions/autoReply.cjs +521 -0
- package/src/extensions/context.cjs +73 -0
- package/src/extensions/contract.cjs +69 -0
- package/src/extensions/entitlement/client.cjs +381 -0
- package/src/extensions/entitlement/index.cjs +629 -0
- package/src/extensions/entitlement/installation.cjs +117 -0
- package/src/extensions/entitlement/keys.cjs +72 -0
- package/src/extensions/entitlement/state.cjs +201 -0
- package/src/extensions/entitlement/target.cjs +7 -0
- package/src/extensions/entitlement/token.cjs +225 -0
- package/src/extensions/host.cjs +519 -0
- package/src/extensions/templateKeys.cjs +81 -0
- package/src/handlers/command.handler.js +191 -64
- package/src/handlers/group.handler.js +78 -18
- package/src/handlers/message.handler.js +56 -25
- package/src/i18n/catalog.generated.cjs +3537 -0
- package/src/index.js +51 -12
- package/src/legal/bundled/ar.json +102 -0
- package/src/legal/bundled/en.json +102 -0
- package/src/legal/bundled/es-419.json +102 -0
- package/src/legal/bundled/pt-BR.json +102 -0
- package/src/legal/cli.cjs +200 -0
- package/src/legal/consent.cjs +187 -0
- package/src/legal/document.cjs +156 -0
- package/src/legal/keys.cjs +100 -0
- package/src/legal/release.cjs +226 -0
- package/src/legal/remote.cjs +419 -0
- package/src/legal/terms.cjs +142 -0
- package/src/messaging/escape.cjs +31 -0
- package/src/messaging/health.cjs +65 -0
- package/src/messaging/identity.cjs +42 -0
- package/src/messaging/message.cjs +136 -0
- package/src/messaging/parser.cjs +88 -0
- package/src/messaging/router.cjs +217 -0
- package/src/middleware/permissions.middleware.js +34 -2
- package/src/panel/account-profile.cjs +489 -0
- package/src/panel/fallback-page.cjs +177 -0
- package/src/panel/password-reset.cjs +13 -14
- package/src/panel/recovery-email.cjs +3 -1
- package/src/routes/backup.api.esm.js +175 -0
- package/src/routes/dashboard.api.esm.js +183 -7
- package/src/routes/plus.api.esm.js +172 -0
- package/src/routes/reactions.api.esm.js +60 -0
- package/src/services/aiAgent.cjs +56 -43
- package/src/services/aiDocs.cjs +187 -0
- package/src/services/aiImage.cjs +183 -0
- package/src/services/aiMedia.cjs +146 -0
- package/src/services/aiProviders.cjs +76 -80
- package/src/services/aiRouter.cjs +2 -2
- package/src/services/aiToolAuth.cjs +76 -4
- package/src/services/aiTools.cjs +431 -105
- package/src/services/autoDelete.cjs +9 -1
- package/src/services/levix-docs.generated.json +2623 -0
- package/src/services/memoryPolicy.cjs +56 -0
- package/src/services/updateCheck.cjs +362 -0
- package/src/stickers/errors.cjs +53 -97
- package/src/stickers/library.cjs +13 -6
- package/src/stickers/owner.cjs +1 -1
- package/src/utils/commandContext.cjs +13 -0
- package/src/utils/commandDocs.cjs +42 -20
- package/src/utils/geminiHttpOptions.cjs +56 -0
- package/src/utils/geminiMedia.cjs +28 -3
- package/src/utils/groupMetadataCache.cjs +386 -21
- package/src/utils/httpsFetch.cjs +113 -0
- package/src/utils/i18n.cjs +117 -7
- package/src/utils/linkPreview.cjs +90 -0
- package/src/utils/logger.cjs +6 -0
- package/src/utils/markdownParser.cjs +3 -3
- package/src/utils/memory.cjs +375 -28
- package/src/utils/messageContent.cjs +7 -1
- package/src/utils/moderationAction.cjs +116 -73
- package/src/utils/moderationSummary.cjs +32 -56
- package/src/utils/permissionLevel.cjs +7 -28
- package/src/utils/permissions.cjs +23 -14
- package/src/utils/permissions.esm.js +99 -166
- package/src/utils/recentMessageCache.esm.js +241 -37
- package/src/utils/recurrence.cjs +78 -66
- package/src/utils/sendBotMessage.cjs +14 -29
- package/src/utils/sendBotMessage.esm.js +28 -13
- package/src/utils/statusMessage.cjs +94 -33
- package/src/utils/stickerBot.cjs +18 -16
- package/src/utils/storage.cjs +2 -0
- package/src/utils/storage.esm.js +2 -0
- package/src/utils/thumbnail.cjs +5 -21
- package/public/dashboard/assets/index-B1sOW2VX.js +0 -561
- package/public/dashboard/assets/index-CK8osB4o.css +0 -2
- package/public/dashboard.css +0 -3127
- package/public/dashboard.js +0 -1981
- package/public/gateway-i18n.js +0 -321
- package/public/gateway.js +0 -70
- package/views/dashboard.ejs +0 -775
- package/views/login.ejs +0 -408
- package/views/qr.ejs +0 -155
- package/views/setup.ejs +0 -118
|
@@ -33,8 +33,9 @@ const logger = require("../utils/logger.cjs");
|
|
|
33
33
|
const secrets = require("../config/secrets.cjs");
|
|
34
34
|
const brand = require("../config/brand.cjs");
|
|
35
35
|
const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
|
|
36
|
-
const { withLang, detectLang,
|
|
36
|
+
const { withLang, detectLang, t } = require("../utils/i18n.cjs");
|
|
37
37
|
const normalizeJid = require("../utils/normalizeJid.esm.js").default;
|
|
38
|
+
const { assertSelfDelivery } = require("../messaging/router.cjs");
|
|
38
39
|
const recoveryEmail = require("./recovery-email.cjs");
|
|
39
40
|
const {
|
|
40
41
|
CODE_TTL_MS,
|
|
@@ -102,14 +103,7 @@ function noteRecoveryAddress(address) {
|
|
|
102
103
|
|
|
103
104
|
function codeMessage(code) {
|
|
104
105
|
return withLang(detectLang(""), () =>
|
|
105
|
-
|
|
106
|
-
`🔐 *${brand.name} — password reset code: ${code}*\n\n` +
|
|
107
|
-
`Enter it in the control panel within 10 minutes. ` +
|
|
108
|
-
`If you didn't request this, ignore this message — nobody else can use it.`,
|
|
109
|
-
`🔐 *${brand.name} — كود إعادة تعيين كلمة السر: ${code}*\n\n` +
|
|
110
|
-
`ادخل الكود في لوحة التحكم خلال ١٠ دقائق. ` +
|
|
111
|
-
`إذا لم تطلب هذا الرمز، فتجاهل الرسالة — لا يمكن لأحد سواك استخدامه.`,
|
|
112
|
-
),
|
|
106
|
+
t("bot.core.passwordReset.codeMessage", { brandName: brand.name, code }),
|
|
113
107
|
);
|
|
114
108
|
}
|
|
115
109
|
|
|
@@ -123,8 +117,9 @@ function resolveChannel(channel) {
|
|
|
123
117
|
* Generate a reset code and deliver it.
|
|
124
118
|
*
|
|
125
119
|
* `options.channel` is `"whatsapp"` (the default, including a missing value)
|
|
126
|
-
* or `"email"`. `options.lang` is `"en"` or `"
|
|
127
|
-
* anything else is English. The WhatsApp text keeps
|
|
120
|
+
* or `"email"`. `options.lang` is `"en"`, `"ar"`, `"pt-BR"` or `"es-419"` and
|
|
121
|
+
* is sent to the relay; anything else is English. The WhatsApp text keeps
|
|
122
|
+
* the bot's reply language.
|
|
128
123
|
*
|
|
129
124
|
* @param {string} peer TCP peer, from clientAddress() — never req.ip
|
|
130
125
|
* @param {{ channel?: string, lang?: string }} [options]
|
|
@@ -135,7 +130,7 @@ async function requestResetCode(peer, options = {}) {
|
|
|
135
130
|
const channel = resolveChannel(opts.channel);
|
|
136
131
|
if (!channel) return { ok: false, reason: "invalid" };
|
|
137
132
|
|
|
138
|
-
const lang = opts.lang
|
|
133
|
+
const lang = recoveryEmail.normalizeLang(opts.lang);
|
|
139
134
|
|
|
140
135
|
const now = Date.now();
|
|
141
136
|
const locked = lockedFor(now);
|
|
@@ -186,9 +181,10 @@ async function requestResetCode(peer, options = {}) {
|
|
|
186
181
|
logger.info({ channel }, "[reset] Reset code sent by email");
|
|
187
182
|
} else {
|
|
188
183
|
try {
|
|
184
|
+
const self = assertSelfDelivery(normalizeJid(sock.user.id), normalizeJid(sock.user.id));
|
|
189
185
|
await sendBotMessage(
|
|
190
186
|
sock,
|
|
191
|
-
|
|
187
|
+
self,
|
|
192
188
|
{ text: codeMessage(generated.code) },
|
|
193
189
|
{ typing: false, delayMs: 0 },
|
|
194
190
|
);
|
|
@@ -204,7 +200,10 @@ async function requestResetCode(peer, options = {}) {
|
|
|
204
200
|
// any previous code in place. A newer request, or an address change while
|
|
205
201
|
// this send was in flight, owns the slot instead.
|
|
206
202
|
if (generation !== resetGeneration) return { ok: false, reason: "throttled" };
|
|
207
|
-
if (
|
|
203
|
+
if (
|
|
204
|
+
channel === "email" &&
|
|
205
|
+
(emailGen !== emailGeneration || recoveryEmail.getAddress() !== address)
|
|
206
|
+
) {
|
|
208
207
|
return { ok: false, reason: "no_email" };
|
|
209
208
|
}
|
|
210
209
|
pending = {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// confirm { kind, verification, code } the operator's guess; a match
|
|
15
15
|
// answers a token for the address
|
|
16
16
|
// reset { kind, to, code, token, lang } refused without that token
|
|
17
|
+
// lang is exactly en, ar, pt-BR or es-419; other values become en
|
|
17
18
|
//
|
|
18
19
|
// This process never sees a verify code, so the relay checks it: five
|
|
19
20
|
// guesses per code, single use. The token is sealed with the address and is
|
|
@@ -57,7 +58,7 @@ const RELAY_REASONS = new Set([
|
|
|
57
58
|
const VERIFY_DEAD = new Set(["expired", "too_many_attempts", "no_pending"]);
|
|
58
59
|
|
|
59
60
|
function normalizeLang(lang) {
|
|
60
|
-
return lang === "ar"
|
|
61
|
+
return lang === "ar" || lang === "en" || lang === "pt-BR" || lang === "es-419" ? lang : "en";
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
/**
|
|
@@ -319,6 +320,7 @@ function _expireForTests() {
|
|
|
319
320
|
module.exports = {
|
|
320
321
|
DEFAULT_ENDPOINT,
|
|
321
322
|
RELAY_TIMEOUT_MS,
|
|
323
|
+
normalizeLang,
|
|
322
324
|
normalizeEmail,
|
|
323
325
|
maskEmail,
|
|
324
326
|
getRecord,
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { createReadStream } from "node:fs";
|
|
2
|
+
import { Router } from "express";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const { CODES, validatePassword, openBackup } = require("../backup/format.cjs");
|
|
7
|
+
const { describeBackupContents } = require("../backup/create.cjs");
|
|
8
|
+
const jobs = require("../backup/jobs.cjs");
|
|
9
|
+
const uploads = require("../backup/uploads.cjs");
|
|
10
|
+
const restore = require("../backup/restore.cjs");
|
|
11
|
+
const { readLastActivation } = require("../backup/activation.cjs");
|
|
12
|
+
const { readPairedAccount, maskAccount, accountsMatch } = require("../backup/account.cjs");
|
|
13
|
+
const { buildPlan, publicPlan } = require("../backup/plan.cjs");
|
|
14
|
+
const secrets = require("../config/secrets.cjs");
|
|
15
|
+
const { blockedFor, recordFailure, clearAttempts } = require("../panel/login-throttle.cjs");
|
|
16
|
+
const { clientAddress } = require("../utils/requestOrigin.cjs");
|
|
17
|
+
|
|
18
|
+
const router = Router();
|
|
19
|
+
const tokenRe = /^[0-9a-f]{64}$/;
|
|
20
|
+
const jobRe = /^[0-9a-f]{32}$/;
|
|
21
|
+
const errorCodes = new Set([...CODES, "NO_SPACE", "UNCLASSIFIED_TABLE", "SECRET_FOUND", "SCHEMA_NEWER", "SCHEMA_MISMATCH", "NOT_FOUND", "BAD_LENGTH", "LENGTH_REQUIRED", "too_many_attempts", "RESTORE_INCOMPLETE", "CONFIRM_REQUIRED"]);
|
|
22
|
+
|
|
23
|
+
export function jsonUnlessBackupUpload(jsonParser) {
|
|
24
|
+
return (req, res, next) => {
|
|
25
|
+
const urlPath = (req.originalUrl || "").split("?")[0];
|
|
26
|
+
if (req.method === "POST" && urlPath.endsWith("/backup/restore/uploads")) return next();
|
|
27
|
+
return jsonParser(req, res, next);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function respondError(res, error) {
|
|
32
|
+
const code = errorCodes.has(error?.code) ? error.code : "IO";
|
|
33
|
+
const status = code === "BUSY" || code === "CONFIRM_REQUIRED" || code === "UNCLASSIFIED_TABLE" || code === "SCHEMA_NEWER" || code === "SCHEMA_MISMATCH" ? 409 :
|
|
34
|
+
code === "LENGTH_REQUIRED" ? 411 : code === "LIMIT" ? 413 :
|
|
35
|
+
code === "NO_SPACE" ? 507 : code === "NOT_FOUND" ? 404 :
|
|
36
|
+
["BAD_PASSWORD", "BAD_LENGTH", "WRONG_PASSWORD", "DAMAGED", "too_many_attempts"].includes(code) ? 400 : 500;
|
|
37
|
+
return res.status(status).json({ success: false, code });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function requireCurrent(req, res) {
|
|
41
|
+
const peer = clientAddress(req);
|
|
42
|
+
const retryAfter = blockedFor(peer);
|
|
43
|
+
if (retryAfter) {
|
|
44
|
+
res.set("Retry-After", String(retryAfter));
|
|
45
|
+
res.status(429).json({ success: false, code: "throttled", retryAfter });
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (!secrets.verifyDashboardPassword(req.body?.current)) {
|
|
49
|
+
recordFailure(peer);
|
|
50
|
+
res.status(403).json({ success: false, code: "wrong_password" });
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
clearAttempts(peer);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
router.post("/backup/restore/uploads", async (req, res) => {
|
|
58
|
+
try {
|
|
59
|
+
if (req.headers["content-type"]?.split(";")[0] !== "application/octet-stream")
|
|
60
|
+
return res.status(415).json({ success: false, code: "UNSUPPORTED_MEDIA_TYPE" });
|
|
61
|
+
return res.json(await uploads.receiveUpload(req));
|
|
62
|
+
} catch (error) { return respondError(res, error); }
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
router.post("/backup/restore/uploads/:id/preview", async (req, res) => {
|
|
66
|
+
const id = req.params.id;
|
|
67
|
+
if (!uploads.idRe.test(id)) return res.status(404).json({ success: false, code: "NOT_FOUND" });
|
|
68
|
+
if (uploads.lockedOut(id)) return respondError(res, { code: "too_many_attempts" });
|
|
69
|
+
const pin = uploads.pinUpload(id);
|
|
70
|
+
if (!pin) return res.status(404).json({ success: false, code: "NOT_FOUND" });
|
|
71
|
+
try {
|
|
72
|
+
const opened = await openBackup({ path: pin.path, password: req.body?.password });
|
|
73
|
+
restore.schemaCheck(opened.manifest);
|
|
74
|
+
const m = opened.manifest;
|
|
75
|
+
const paired = readPairedAccount();
|
|
76
|
+
const status = !m.account ? "none" : !paired ? "target-unpaired" :
|
|
77
|
+
accountsMatch(m.account, paired) ? "match" : "different";
|
|
78
|
+
const plan = buildPlan({ digests: m.digests ?? null, apiKeyNames: m.apiKeys, account: m.account,
|
|
79
|
+
personaSha: m.entries.find((entry) => entry.kind === "persona")?.sha256 ?? null });
|
|
80
|
+
const publicView = publicPlan(plan);
|
|
81
|
+
return res.json({ created: m.created, app: m.app, schema: m.schema, platform: m.platform,
|
|
82
|
+
counts: m.counts, apiKeys: m.apiKeys, account: { masked: maskAccount(m.account), status },
|
|
83
|
+
accountData: m.account ? "waits" : "none", plan: publicView, plus: publicView.plus });
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (error.code === "WRONG_PASSWORD" && uploads.wrongPassword(id))
|
|
86
|
+
return respondError(res, { code: "too_many_attempts" });
|
|
87
|
+
return respondError(res, error);
|
|
88
|
+
} finally { pin.release(); }
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
router.post("/backup/restore/uploads/:id/restore", (req, res) => {
|
|
92
|
+
const id = req.params.id;
|
|
93
|
+
if (uploads.idRe.test(id) && uploads.lockedOut(id)) return respondError(res, { code: "too_many_attempts" });
|
|
94
|
+
if (!uploads.idRe.test(id) || !uploads.getUpload(id))
|
|
95
|
+
return res.status(404).json({ success: false, code: "NOT_FOUND" });
|
|
96
|
+
if (!requireCurrent(req, res)) return;
|
|
97
|
+
try {
|
|
98
|
+
return res.json({ jobId: jobs.startRestore(id, req.body?.password,
|
|
99
|
+
{ confirmDestructive: req.body?.confirmDestructive === true }) });
|
|
100
|
+
}
|
|
101
|
+
catch (error) { return respondError(res, error); }
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
router.get("/backup/pending", (_req, res) => {
|
|
105
|
+
try { return res.json({ ...restore.pendingStatus(), lastActivation: readLastActivation() }); }
|
|
106
|
+
catch (error) { return respondError(res, error); }
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
router.delete("/backup/pending", (req, res) => {
|
|
110
|
+
if (!requireCurrent(req, res)) return;
|
|
111
|
+
try { restore.discardPending(); return res.json({ success: true }); }
|
|
112
|
+
catch (error) { return respondError(res, error); }
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
router.get("/backup/contents", (_req, res) => {
|
|
116
|
+
try { res.json(describeBackupContents()); }
|
|
117
|
+
catch (error) { respondError(res, error); }
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
router.post("/backup/exports", (req, res) => {
|
|
121
|
+
const { password, confirm, current } = req.body || {};
|
|
122
|
+
if (password !== confirm) return res.status(400).json({ success: false, code: "BAD_PASSWORD" });
|
|
123
|
+
try { validatePassword(password); }
|
|
124
|
+
catch (error) { return respondError(res, error); }
|
|
125
|
+
const peer = clientAddress(req);
|
|
126
|
+
const retryAfter = blockedFor(peer);
|
|
127
|
+
if (retryAfter) {
|
|
128
|
+
res.set("Retry-After", String(retryAfter));
|
|
129
|
+
return res.status(429).json({ success: false, code: "throttled", retryAfter });
|
|
130
|
+
}
|
|
131
|
+
if (!secrets.verifyDashboardPassword(current)) {
|
|
132
|
+
recordFailure(peer);
|
|
133
|
+
return res.status(403).json({ success: false, code: "wrong_password" });
|
|
134
|
+
}
|
|
135
|
+
clearAttempts(peer);
|
|
136
|
+
try { return res.json({ jobId: jobs.startExport(password) }); }
|
|
137
|
+
catch (error) { return respondError(res, error); }
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
router.get("/backup/jobs/:id", (req, res) => {
|
|
141
|
+
const job = jobRe.test(req.params.id) && jobs.getJob(req.params.id);
|
|
142
|
+
if (!job) return res.status(404).json({ success: false, code: "NOT_FOUND" });
|
|
143
|
+
return res.json(job);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
router.get("/backup/exports/:token", (req, res) => {
|
|
147
|
+
if (!tokenRe.test(req.params.token)) return res.status(404).json({ success: false, code: "NOT_FOUND" });
|
|
148
|
+
const file = jobs.getExport(req.params.token);
|
|
149
|
+
if (!file) return res.status(404).json({ success: false, code: "NOT_FOUND" });
|
|
150
|
+
const stream = createReadStream(file.path);
|
|
151
|
+
stream.once("open", () => {
|
|
152
|
+
res.set({ "Content-Type": "application/octet-stream",
|
|
153
|
+
"Content-Disposition": `attachment; filename="${file.fileName}"`,
|
|
154
|
+
"Content-Length": String(file.size), "Cache-Control": "no-store" });
|
|
155
|
+
stream.pipe(res);
|
|
156
|
+
});
|
|
157
|
+
stream.on("error", () => {
|
|
158
|
+
if (!res.headersSent) {
|
|
159
|
+
res.removeHeader("Content-Disposition");
|
|
160
|
+
res.removeHeader("Content-Length");
|
|
161
|
+
res.removeHeader("Content-Type");
|
|
162
|
+
res.status(404).json({ success: false, code: "NOT_FOUND" });
|
|
163
|
+
}
|
|
164
|
+
else res.destroy();
|
|
165
|
+
});
|
|
166
|
+
res.on("close", () => stream.destroy());
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
router.delete("/backup/exports/:token", (req, res) => {
|
|
170
|
+
if (!tokenRe.test(req.params.token) || !jobs.removeExport(req.params.token))
|
|
171
|
+
return res.status(404).json({ success: false, code: "NOT_FOUND" });
|
|
172
|
+
return res.json({ success: true });
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
export default router;
|
|
@@ -22,6 +22,7 @@ import { fileToBuffer, MultipartError, readMultipartForm } from "../utils/multip
|
|
|
22
22
|
import normalizeJid, { isLidJid } from "../utils/normalizeJid.esm.js";
|
|
23
23
|
import { grantRole, listRoles, revokeRole } from "../utils/permissions.esm.js";
|
|
24
24
|
import {
|
|
25
|
+
accountEpoch,
|
|
25
26
|
countDebts,
|
|
26
27
|
countNotes,
|
|
27
28
|
countSchedules,
|
|
@@ -46,6 +47,8 @@ import {
|
|
|
46
47
|
|
|
47
48
|
const require = createRequire(import.meta.url);
|
|
48
49
|
const logger = require("../utils/logger.cjs");
|
|
50
|
+
const updateChecker = require("../services/updateCheck.cjs");
|
|
51
|
+
const { LINKS } = require("../config/official-links.cjs");
|
|
49
52
|
const {
|
|
50
53
|
buildModerationSummaryBoth,
|
|
51
54
|
featureActionOf,
|
|
@@ -106,7 +109,11 @@ const {
|
|
|
106
109
|
const { discoverProviderModels, DiscoveryError } = require("../services/llmDiscovery.cjs");
|
|
107
110
|
const settingsTransfer = require("../services/settingsTransfer.cjs");
|
|
108
111
|
const autoDelete = require("../services/autoDelete.cjs");
|
|
112
|
+
const legalTerms = require("../legal/terms.cjs");
|
|
113
|
+
const legalConsent = require("../legal/consent.cjs");
|
|
109
114
|
const cron = require("node-cron");
|
|
115
|
+
const { createAccountProfile } = require("../panel/account-profile.cjs");
|
|
116
|
+
const { linkedIdentity } = require("../messaging/identity.cjs");
|
|
110
117
|
|
|
111
118
|
const router = Router();
|
|
112
119
|
|
|
@@ -114,6 +121,9 @@ const router = Router();
|
|
|
114
121
|
// it questions and give it orders; they never create or destroy a socket
|
|
115
122
|
// themselves, and nothing a browser does to its websocket reaches it.
|
|
116
123
|
let session = null;
|
|
124
|
+
// Built below, after the helpers it depends on exist. setSession may only call
|
|
125
|
+
// into it once it is initialized.
|
|
126
|
+
let accountProfile = null;
|
|
117
127
|
const DASHBOARD_START_COALESCE_MS = 500;
|
|
118
128
|
let dashboardStartPromise = null;
|
|
119
129
|
let dashboardStartSettledAt = 0;
|
|
@@ -124,6 +134,9 @@ export function setSession(manager) {
|
|
|
124
134
|
dashboardStartPromise = null;
|
|
125
135
|
dashboardStartSettledAt = 0;
|
|
126
136
|
dashboardStartKey = null;
|
|
137
|
+
// A new session manager means a new socket generation. Never let a profile
|
|
138
|
+
// or a cached photo revision survive it.
|
|
139
|
+
accountProfile?.reset?.();
|
|
127
140
|
}
|
|
128
141
|
|
|
129
142
|
/** The live socket, or null. Re-read every time — a reconnect replaces it. */
|
|
@@ -157,6 +170,24 @@ function sessionState() {
|
|
|
157
170
|
);
|
|
158
171
|
}
|
|
159
172
|
|
|
173
|
+
// The connected account card's cache. Constructing it only stores the
|
|
174
|
+
// callbacks: no profile is read and no socket is touched until a route asks.
|
|
175
|
+
accountProfile = createAccountProfile({
|
|
176
|
+
getContext() {
|
|
177
|
+
return {
|
|
178
|
+
socket: currentSocket(),
|
|
179
|
+
state: sessionState(),
|
|
180
|
+
epoch: accountEpoch(),
|
|
181
|
+
identity: linkedIdentity(),
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
// Existing WhatsApp image transport: HTTPS WhatsApp origins, DNS and
|
|
185
|
+
// private-network validation, and the live session's proxy.
|
|
186
|
+
fetchImage(sock, url, init) {
|
|
187
|
+
return fetchWhatsAppImage(sock, url, init);
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
|
|
160
191
|
// --- helpers --------------------------------------------------------------
|
|
161
192
|
|
|
162
193
|
function fail(res, error, label, status = 500) {
|
|
@@ -203,6 +234,29 @@ function parseDiagnosticsInput(raw) {
|
|
|
203
234
|
// Overview
|
|
204
235
|
// ===========================================================================
|
|
205
236
|
|
|
237
|
+
// Reading About never triggers a network check. Only the explicit POST does.
|
|
238
|
+
router.get("/updates", (_req, res) => {
|
|
239
|
+
const channel = updateChecker.getInstallChannel();
|
|
240
|
+
res.json({
|
|
241
|
+
success: true,
|
|
242
|
+
links: LINKS,
|
|
243
|
+
update: {
|
|
244
|
+
channel,
|
|
245
|
+
status: "idle",
|
|
246
|
+
currentVersion: require("../../package.json").version,
|
|
247
|
+
latestVersion: null,
|
|
248
|
+
url: channel === "play" ? LINKS.play : LINKS.releases,
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
router.post(
|
|
254
|
+
"/updates/check",
|
|
255
|
+
asyncRoute(async (_req, res) => {
|
|
256
|
+
res.json({ success: true, links: LINKS, update: await updateChecker.checkForUpdates() });
|
|
257
|
+
}),
|
|
258
|
+
);
|
|
259
|
+
|
|
206
260
|
router.get("/stats", (req, res) => {
|
|
207
261
|
try {
|
|
208
262
|
const connection = sessionState();
|
|
@@ -1215,9 +1269,11 @@ router.post("/roles", (req, res) => {
|
|
|
1215
1269
|
const jid = `${phone}@s.whatsapp.net`;
|
|
1216
1270
|
if (action === "grant") grantRole(jid, role);
|
|
1217
1271
|
else revokeRole(jid, role);
|
|
1218
|
-
logger.info(`[Dashboard] ${action} ${role}
|
|
1272
|
+
logger.info(`[Dashboard] ${action} ${role}`);
|
|
1273
|
+
logger.debugOnly.info({ phone }, `[Dashboard] ${action} ${role}`);
|
|
1219
1274
|
res.json({ success: true, roles: listRoles() });
|
|
1220
1275
|
} catch (error) {
|
|
1276
|
+
if (error?.code === "LINKED_ACCOUNT_OWNER") return badRequest(res, error.message);
|
|
1221
1277
|
fail(res, error, "Error changing a role");
|
|
1222
1278
|
}
|
|
1223
1279
|
});
|
|
@@ -1226,17 +1282,25 @@ router.post("/roles", (req, res) => {
|
|
|
1226
1282
|
// Scheduled messages
|
|
1227
1283
|
// ===========================================================================
|
|
1228
1284
|
|
|
1285
|
+
const SCHEDULE_LOCALES = ["en", "ar", "pt-BR", "es-419"];
|
|
1286
|
+
|
|
1229
1287
|
function scheduleView(job) {
|
|
1230
1288
|
if (!job) return null;
|
|
1231
1289
|
const timezone = settings.get("bot_timezone");
|
|
1232
1290
|
const peer = describePeer(job.targetJid);
|
|
1291
|
+
const whenByLocale = {};
|
|
1292
|
+
for (const lang of SCHEDULE_LOCALES) {
|
|
1293
|
+
whenByLocale[lang] = describeScheduledJob(job, timezone, lang);
|
|
1294
|
+
}
|
|
1233
1295
|
return {
|
|
1234
1296
|
...job,
|
|
1235
|
-
when:
|
|
1236
|
-
whenAr:
|
|
1297
|
+
when: whenByLocale.en,
|
|
1298
|
+
whenAr: whenByLocale.ar,
|
|
1299
|
+
whenByLocale,
|
|
1237
1300
|
targetLabel: peer.label,
|
|
1238
1301
|
targetKind: peer.kind,
|
|
1239
1302
|
targetPhone: peer.phone,
|
|
1303
|
+
targetNameSource: peer.nameSource,
|
|
1240
1304
|
savedName: peer.savedName ?? null,
|
|
1241
1305
|
pushName: peer.pushName ?? null,
|
|
1242
1306
|
phone: peer.phone,
|
|
@@ -1257,14 +1321,18 @@ router.get("/recipients", (req, res) => {
|
|
|
1257
1321
|
seen.add(gid);
|
|
1258
1322
|
const live = groupMetadataCache.get(gid);
|
|
1259
1323
|
const peer = describePeer(gid);
|
|
1324
|
+
const liveSubject = typeof live?.subject === "string" ? live.subject.trim() : "";
|
|
1325
|
+
const liveNamed = Boolean(liveSubject) && !liveSubject.includes("@");
|
|
1326
|
+
const named = liveNamed || peer.nameSource === "subject";
|
|
1260
1327
|
recipients.push({
|
|
1261
1328
|
id: gid,
|
|
1262
|
-
name:
|
|
1329
|
+
name: liveNamed ? liveSubject.slice(0, 128) : peer.label,
|
|
1263
1330
|
type: "group",
|
|
1264
1331
|
memberCount: live?.participants?.length ?? peer.memberCount,
|
|
1265
1332
|
savedName: null,
|
|
1266
1333
|
pushName: null,
|
|
1267
1334
|
phone: null,
|
|
1335
|
+
nameSource: named ? "subject" : "none",
|
|
1268
1336
|
});
|
|
1269
1337
|
};
|
|
1270
1338
|
|
|
@@ -1296,6 +1364,7 @@ router.get("/recipients", (req, res) => {
|
|
|
1296
1364
|
savedName: peer.savedName ?? null,
|
|
1297
1365
|
pushName: peer.pushName ?? null,
|
|
1298
1366
|
type: "contact",
|
|
1367
|
+
nameSource: peer.nameSource,
|
|
1299
1368
|
});
|
|
1300
1369
|
}
|
|
1301
1370
|
|
|
@@ -1407,7 +1476,7 @@ router.post(
|
|
|
1407
1476
|
// sends a structured `recurrence` object and never a cron string.
|
|
1408
1477
|
job.cronString = cronString;
|
|
1409
1478
|
} else {
|
|
1410
|
-
return badRequest(res, "
|
|
1479
|
+
return badRequest(res, recurrenceErrorMessage("recurrence"));
|
|
1411
1480
|
}
|
|
1412
1481
|
} else {
|
|
1413
1482
|
const timeMs = Number(scheduledTime);
|
|
@@ -1715,12 +1784,78 @@ router.post(
|
|
|
1715
1784
|
}),
|
|
1716
1785
|
);
|
|
1717
1786
|
|
|
1787
|
+
// ===========================================================================
|
|
1788
|
+
// Legal consent
|
|
1789
|
+
// ===========================================================================
|
|
1790
|
+
|
|
1791
|
+
function legalTermsResponse(requestedLocale) {
|
|
1792
|
+
const locale = legalTerms.resolveLocale(requestedLocale);
|
|
1793
|
+
const { document, sha256, version } = legalTerms.documentFor(locale);
|
|
1794
|
+
const { ok, reason, accepted } = legalConsent.consentStatus();
|
|
1795
|
+
return {
|
|
1796
|
+
version,
|
|
1797
|
+
locale,
|
|
1798
|
+
requestedLocale,
|
|
1799
|
+
sha256,
|
|
1800
|
+
effective: document.effective,
|
|
1801
|
+
terms: document.terms,
|
|
1802
|
+
privacy: document.privacy,
|
|
1803
|
+
links: legalTerms.LINKS,
|
|
1804
|
+
locales: legalTerms.availableLocales(),
|
|
1805
|
+
consent: {
|
|
1806
|
+
ok,
|
|
1807
|
+
reason,
|
|
1808
|
+
accepted: accepted
|
|
1809
|
+
? {
|
|
1810
|
+
termsVersion: accepted.termsVersion,
|
|
1811
|
+
locale: accepted.locale,
|
|
1812
|
+
acceptedAt: accepted.acceptedAt,
|
|
1813
|
+
appVersion: accepted.appVersion,
|
|
1814
|
+
}
|
|
1815
|
+
: null,
|
|
1816
|
+
},
|
|
1817
|
+
};
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
router.get(
|
|
1821
|
+
"/legal/terms",
|
|
1822
|
+
asyncRoute(async (req, res) => {
|
|
1823
|
+
const requestedLocale = typeof req.query.locale === "string" ? req.query.locale : null;
|
|
1824
|
+
res.json({ success: true, ...legalTermsResponse(requestedLocale) });
|
|
1825
|
+
}),
|
|
1826
|
+
);
|
|
1827
|
+
|
|
1828
|
+
router.post(
|
|
1829
|
+
"/legal/accept",
|
|
1830
|
+
asyncRoute(async (req, res) => {
|
|
1831
|
+
const { version, sha256, locale } = req.body || {};
|
|
1832
|
+
if ([version, sha256, locale].some((value) => typeof value !== "string" || !value)) {
|
|
1833
|
+
return badRequest(res, "version, sha256 and locale are required strings");
|
|
1834
|
+
}
|
|
1835
|
+
try {
|
|
1836
|
+
legalConsent.recordAcceptance({ version, sha256, locale, via: "panel" });
|
|
1837
|
+
} catch (error) {
|
|
1838
|
+
if (error.code === "CONSENT_BAD_LOCALE") return badRequest(res, "Unknown Terms locale");
|
|
1839
|
+
if (error.code === "TERMS_MISMATCH") {
|
|
1840
|
+
return res.status(409).json({
|
|
1841
|
+
success: false,
|
|
1842
|
+
code: "TERMS_CHANGED",
|
|
1843
|
+
...legalTermsResponse(locale),
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
throw error;
|
|
1847
|
+
}
|
|
1848
|
+
await session?.recheckConsent();
|
|
1849
|
+
res.json({ success: true, session: sessionState() });
|
|
1850
|
+
}),
|
|
1851
|
+
);
|
|
1852
|
+
|
|
1718
1853
|
// ===========================================================================
|
|
1719
1854
|
// Bot control
|
|
1720
1855
|
// ===========================================================================
|
|
1721
1856
|
|
|
1722
1857
|
// The WhatsApp session. These four routes are the only way a browser can
|
|
1723
|
-
//
|
|
1858
|
+
// directly control it, and each is a request to the backend's state machine rather
|
|
1724
1859
|
// than an instruction to make or break a socket. Everything under
|
|
1725
1860
|
// /dashboard/api is already behind the panel session and the cross-origin
|
|
1726
1861
|
// check in app.cjs, so no new surface is exposed here.
|
|
@@ -1840,7 +1975,17 @@ router.post(
|
|
|
1840
1975
|
return res.status(409).json({ success: false, error: "There is nothing linked to unlink" });
|
|
1841
1976
|
}
|
|
1842
1977
|
|
|
1843
|
-
|
|
1978
|
+
let state;
|
|
1979
|
+
try {
|
|
1980
|
+
state = await session.logout();
|
|
1981
|
+
} catch (error) {
|
|
1982
|
+
if (error.code !== "UNLINK_NOT_STARTED") throw error;
|
|
1983
|
+
return res.status(503).json({
|
|
1984
|
+
success: false,
|
|
1985
|
+
error: error.message,
|
|
1986
|
+
code: error.code,
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1844
1989
|
logger.warn("[Dashboard] WhatsApp account unlinked from the dashboard");
|
|
1845
1990
|
res.json({ success: true, session: state });
|
|
1846
1991
|
}),
|
|
@@ -1898,6 +2043,37 @@ router.post("/session/restart", (req, res, next) => {
|
|
|
1898
2043
|
router.handle(req, res, next);
|
|
1899
2044
|
});
|
|
1900
2045
|
|
|
2046
|
+
// --- Connected account profile ---------------------------------------------
|
|
2047
|
+
// Opening Connection may read only the connected account's own profile. The
|
|
2048
|
+
// service bounds, caches and context-guards every lookup; nothing here accepts
|
|
2049
|
+
// a JID or a URL from the browser.
|
|
2050
|
+
router.get(
|
|
2051
|
+
"/account/profile",
|
|
2052
|
+
asyncRoute(async (_req, res) => {
|
|
2053
|
+
res.json({ success: true, profile: await accountProfile.get() });
|
|
2054
|
+
}),
|
|
2055
|
+
);
|
|
2056
|
+
|
|
2057
|
+
router.post(
|
|
2058
|
+
"/account/profile/refresh",
|
|
2059
|
+
asyncRoute(async (_req, res) => {
|
|
2060
|
+
res.json({ success: true, profile: await accountProfile.refresh() });
|
|
2061
|
+
}),
|
|
2062
|
+
);
|
|
2063
|
+
|
|
2064
|
+
// The revision is opaque and bound to the current cache entry. An unknown,
|
|
2065
|
+
// expired or previous-account token is a plain 404 with no network.
|
|
2066
|
+
router.get(
|
|
2067
|
+
"/account/photo",
|
|
2068
|
+
asyncRoute(async (req, res) => {
|
|
2069
|
+
const revision = typeof req.query.revision === "string" ? req.query.revision : "";
|
|
2070
|
+
const picture = revision ? await accountProfile.photo(revision) : null;
|
|
2071
|
+
if (!picture) return res.sendStatus(404);
|
|
2072
|
+
res.set("X-Content-Type-Options", "nosniff");
|
|
2073
|
+
res.type(picture.mime).send(picture.bytes);
|
|
2074
|
+
}),
|
|
2075
|
+
);
|
|
2076
|
+
|
|
1901
2077
|
// ===========================================================================
|
|
1902
2078
|
// Keyword auto-delete
|
|
1903
2079
|
// ===========================================================================
|