Repository navigation
fix: transcript delivery without an API key, add transcriptToUser - #34
Conversation
|
Thanks, this is a good catch, especially the placeholder key. Confirmed on current main: Tests pass on your branch (178/178). Two small things:
The branch conflicts with main right now ( |
b298f64 to
ca3f239
Compare
|
Thanks! Done:
The live test found one more gap in this PR's no-key path: the HTML file still pointed images at the Discord CDN. Those links expire after about a day, and immediately when the channel is deleted. Images are now embedded as data URIs, up to 5 MB per transcript so the file stays under the attachment cap, with tests in I'll rebase once #32 is in and mark it ready then. |
ca3f239 to
108769d
Compare
…ptToUser - The .env.example placeholder MSK_API_KEY was only treated as "no key" by the startup check; uploads and attachment collection still POSTed every transcript to msk-scripts.de with it. configuredKey()/isMskConfigured() now apply the same rule everywhere. - Without a key the transcript is not uploaded at all: it is attached to the log channel as an HTML file, with no "upload failed" warning. A real upload failure still falls back to the file, with the warning. - The close DM is sent only when closeOption.dmUser is on. It used to be forced whenever a fallback file existed, with a misleading "service unavailable" note. - New closeOption.transcriptToUser (default true): false keeps transcripts staff-only — the close DM carries neither link nor file. - The final transcript on delete also falls back to a log-channel file. - MSK requests get timeouts (60 s upload, 10 s otherwise) so a hung server cannot block a close or the startup key check. Claude-Session: https://claude.ai/code/session_01Kp1SLbxxAbXw3f42C1qThH
- Transcripts rendered only an embed's title and description, so the answers to the ticket questions (stored as fields of the opening embed) were missing from every transcript. Fields are now rendered, escaped, in both designs. - buildEmojiMap fetched every unique custom emoji id in parallel; a user could paste thousands of fake ids. It now fetches at most 200, ten at a time; the rest fall back to their ":name:" text. - The opening embed truncates answer fields to Discord's limits (name 256, value 1024). A longer question maxLength made addFields throw after the ticket channel had been created. Claude-Session: https://claude.ai/code/session_01Kp1SLbxxAbXw3f42C1qThH
Review feedback: the JSDoc block ended up attached to the constants instead of buildEmojiMap. Claude-Session: https://claude.ai/code/session_01HZPZxD3edzJNFFsiWsHYY1
Toggle next to dmUser in Close Options. web/dist is not rebuilt here, the maintainer rebuilds it on release. Claude-Session: https://claude.ai/code/session_01HZPZxD3edzJNFFsiWsHYY1
Without an API key the transcript is a standalone HTML file, but images still pointed at the Discord CDN: the links are signed and expire after ~24 h, and with deleteOnClose they died with the channel seconds after the close, leaving only the file name. Images (png/jpeg/gif/webp/avif/ bmp) are now embedded as data URIs, oldest first, up to 5 MB so the file stays under the 9 MB attachment cap. Found in the live test. Claude-Session: https://claude.ai/code/session_01HZPZxD3edzJNFFsiWsHYY1
108769d to
076f3ee
Compare
Description
Transcript fixes found while reviewing the bot before deploying it for our community (Uncharted Roleplay). Each commit is one change:
MSK_API_KEY="YOUR_MSK_API_KEY_HERE"from.env.examplewas treated as "no key" only bycheckApiKey().uploadTranscript()andcollectAttachments()only checked for a non-empty string, so a copied example file POSTed every transcript (plus up to 100 MB of attachments) to msk-scripts.de, which rejected it with 401.configuredKey()/isMskConfigured()now apply the same rule everywhere.closeOption.dmUser. It was forced whenever a fallback file existed (so on every close without a key), with a "service temporarily unavailable" note that wasn't true.closeOption.transcriptToUser(defaulttrue, unchanged behaviour).falsekeeps transcripts staff-only: the close DM carries neither link nor file. Useful because a reopen-then-close transcript contains everything staff wrote while the ticket was closed and hidden from the user.buildEmojiMapfetched every unique<:x:id>in parallel; a user could paste thousands of fake ids. Now at most 200, ten at a time; the rest use the:name:fallback.maxLengthmadeaddFieldsthrow after the channel had been created.Related Issue
None opened; these came out of a code review. Happy to open issues if you prefer that workflow.
Type of Change
How Was This Tested?
npm test: all existing tests pass, plus newnode:testsuites:tests/transcript-delivery.test.js(no network call without a real key, log-channel file,dmUser/transcriptToUsercombinations) andtests/transcript-fields.test.js(fields rendered and escaped, emoji cap).transcriptToUser: falsethe DM has no transcript; the transcript is stored in the database. Not tested with a real MSK key (we run without one); the keyed upload path was only changed by the key check and the timeout.tests/inline-images.test.js.Checklist
tb_custom-id prefix,client.logger, etc.)client.t(...)and all three locale files (main.json,en.json,de.json) are in sync (no new user-facing strings)initDatabase()(no schema change)MSK_API_KEY(premium features degrade gracefully)npm start) and I verified my change on a test server (see above)README.md/README_GER.md,config.example.jsonc,CLAUDE.md) where behavior, config keys, commands or the schema changed (README.md,README_GER.md,config.example.jsonc; the dashboard's config form does not have a toggle fortranscriptToUseryet, it is editable in file mode)CHANGELOG.mdentry under[Unreleased]feat:,fix:,docs:, …)Note on the related PRs
This is one of three PRs from the same review (robustness, permissions, transcripts). They are independent and each applies to
mainon its own, but they touch some of the same lines (ticketActions.js,CHANGELOG.md). Following your order: after #32, before #33; I will rebase this once #32 is merged.https://claude.ai/code/session_01Kp1SLbxxAbXw3f42C1qThH