Repository navigation
notify: make the summary and asset limits configurable - #172
Merged
Merged
Conversation
The IM renderers cut the summary of a single push at 120 characters and listed at most 3 assets, as fixed constants. Both are now global settings in the settings table, read by the delivery engine when it renders: notify_summary_max_runes 0-4000, default 120 notify_assets_max_shown 0-50, default 3 0 means no truncation and an unset key keeps 120 / 3. PUT /api/settings answers 400 for a value outside the bounds. The limits travel on notify.Message, so the notify package still does not touch the database. With no truncation, nothing bounded a single item in a Feishu card, and Feishu rejects an oversized request as a whole. feishuCard now truncates an item's text as the final backstop, the role TruncateBytes plays in markdownBody for DingTalk and WeCom. feishuMaxCardBytes goes from 24000 to 16000: Feishu custom bots cap the request body at 20 KB, which the old value exceeded. Refs #168.
tuhoangwkm
pushed a commit
to tuhoangwkm/ARTEX
that referenced
this pull request
Nov 11, 2026
PR BaaRai#172 made the summary length and the number of assets listed in an IM message configurable, but only through the API. The Notifications page now shows both next to the other global settings: Summary length (characters) notify_summary_max_runes 0-4000 Assets listed per finding notify_assets_max_shown 0-50 The values are read from GET /api/settings (they are not part of /notify/meta) and saved with the existing "Save global settings" PUT. Each field carries a help text stating that 0 means no truncation. A value that is not a whole number within the bounds marks the input invalid and blocks the save with a toast. The check runs before the request because the backend applies the fields of one PUT in order, so a 400 on a limit would leave the URL and digest interval already saved. An empty field is not submitted and keeps the stored value.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The summary length and the number of assets listed in IM notifications are now two global settings instead of the fixed constants
maxSummaryRunes = 120andmaxAssetsShown = 3. This is the second change for #168; the "and N more" count was fixed in #170.settingstable,GET/PUT /api/settings)0notify_summary_max_runesnotify_assets_max_shownnotify/:Messagecarries an optionalLimits;nilrenders with the old 120 / 3. The DingTalk/WeCom markdown, Feishu card, Telegram and email renderers read it instead of the constants, which stay asDefaultMaxSummaryRunes/DefaultMaxAssetsShown. The package still does not touch the database.server/: the two keys sit next to the othernotify_*settings and use the sameGetSetting/SetSettingstore. The delivery engine reads them when it renders (realtime and digest), and so does the channel test message.PUT /api/settingsanswers 400 for a value outside the bounds; a stored value that is unparseable or out of bounds reads as the default.0, nothing bounded a single item in a card, and Feishu rejects an oversized request as a whole.feishuCardnow truncates an item's text as the final backstop, the roleTruncateBytesplays inmarkdownBodyfor DingTalk (20000 bytes) and WeCom (4096 bytes).Why
Reported in #168: on a host with no link-back URL the IM message is the only place a reviewer sees the finding, and 120 characters / 3 assets could not be changed.
Decisions to review
feishuMaxCardBytesgoes from 24000 to 16000. The Feishu custom bot guide caps the request body at 20 KB ("发送消息时,请求体的数据大小不能超过 20 KB"), so a guard at 24000 would not have kept a message inside the limit. This also makes Feishu digests split a little earlier than before. The new test measures the request body sent on the wire: 16157 bytes for a single push and 16370 for a digest with an oversized first item; with the constant back at 24000 it fails at 24157 and 24370.Not included
/api/settingsonly.Verification
Run in WSL (Go 1.26.10, linux/amd64) on the committed tree, against a throwaway
postgres:16-alpinecontainer that was removed afterwards.server/server.gohas one unformatted struct that is already unformatted onmain; this change does not touch it.go build ./...: pass.go vet ./...: pass.ARTEX_PG_DSN=... go test -p 1 ./... -count=1on a fresh database (the CI command): pass, all 14 packages with testsok, 0 failures.go test -race ./notify -count=1: pass.notify, no database:TestMessageLimitsApplyToSinglePush(unset / 0 / custom values across the markdown, Feishu, Telegram and email renderers),TestMessageLimitsApplyToDigestAssets,TestFeishuUntruncatedItemStaysWithinBodyLimit.server, no database:TestNotifyLimitValue.server, Postgres:TestNotifyLimitSettingsRoundTrip(unset reads 120 / 3; 500/10, 0/0 and 4000/50 round-trip throughPUT /api/settings, the settings rows and the delivery engine's reader; -1, 4001 and 51 answer 400 and leave the stored value alone),TestNotifySummaryLimitReachesDelivery(a 300-character summary is cut at 120 with the key unset and sent whole to a fake DingTalk receiver once the key is 0).go test ./... -count=1withoutARTEX_PG_DSN: every package passes exceptserver, where 44 tests fail with "no database config found". 42 of them are existing tests; the 2 new Postgres tests use the same fixture and fail the same way instead of skipping.Not verified:
dbtests on duplicate rows left by the first run. CI already notes that thedbtests are not idempotent across runs; this change does not touchdb/.Do not merge before
go,shellandwebare green on the exact head SHA.