WeKnora/internal/middleware
wizardchen 7fd566bc15 fix(im): rewrite private storage URLs to HTTP in IM channel replies
IM platforms (Feishu, Slack, Telegram, DingTalk, Mattermost, WeCom) cannot
render provider:// URLs (local://, minio://, s3://, etc.) that appear in
LLM answers containing knowledge base images. The web frontend handles
these via the authenticated /files endpoint, but IM clients need publicly
resolvable HTTP URLs.

Changes:
- Add HMAC-SHA256 presigned URL utility (internal/utils/presign.go) for
  generating time-limited, signature-verified file access URLs
- Add GET /api/v1/files/presigned endpoint that serves files without
  session auth, verified by HMAC signature and expiry
- Update localFileService.GetFileURL() to return presigned HTTP URLs
  when APP_EXTERNAL_URL is configured (cloud backends already return
  presigned URLs via their SDKs)
- Add IM content rewriting pipeline: strip <image> XML tags, strip
  citation tags, rewrite storage URLs to HTTP — applied at all IM
  output points (streaming flush, non-streaming reply, fallback)
- Add holdback buffer in streaming flush to prevent URL/tag splitting
  across chunk boundaries

Closes #1058
2026-04-30 11:40:30 +08:00
..
auth.go fix(im): rewrite private storage URLs to HTTP in IM channel replies 2026-04-30 11:40:30 +08:00
error_handler.go init commit 2025-08-05 15:08:07 +08:00
language.go fix(i18n): use WEKNORA_LANGUAGE env for prompt language fallback instead of hardcoded zh-CN 2026-04-02 12:01:25 +08:00
logger.go refactor: Update wiki prompts and ingestion logic for improved content handling 2026-04-22 21:17:31 +08:00
recovery.go fix: replace standard log with structured logger in main and recovery middleware 2026-02-06 17:59:15 +08:00
trace.go refactor: Update tenant ID handling across the application 2025-11-25 16:30:54 +08:00