diff --git a/.github/scripts/d1-migration-manifest.mjs b/.github/scripts/d1-migration-manifest.mjs index a3ae9786..1f040765 100644 --- a/.github/scripts/d1-migration-manifest.mjs +++ b/.github/scripts/d1-migration-manifest.mjs @@ -168,6 +168,27 @@ export const D1_MIGRATIONS = [ file: "worker/migrations/2026-09-11-user-blocks.sql", artifacts: ["table:user_blocks", "index:idx_user_blocks_blocked"], }, + { + id: "2026-09-12-r2-reference-invariants", + file: "worker/migrations/2026-09-12-r2-reference-invariants.sql", + artifacts: [ + "trigger:prevent_general_member_removal", + "trigger:prevent_pending_message_attachment_insert", + "trigger:prevent_pending_message_attachment_update", + "trigger:prevent_pending_user_avatar_insert", + "trigger:prevent_pending_user_avatar_update", + "trigger:prevent_pending_channel_avatar_insert", + "trigger:prevent_pending_channel_avatar_update", + "trigger:prevent_pending_site_icon_insert", + "trigger:prevent_pending_site_icon_update", + ], + rerunnable: true, + }, + { + id: "2026-09-12-user-bio", + file: "worker/migrations/2026-09-12-user-bio.sql", + artifacts: ["column:users.bio"], + }, ]; // b3f6855 曾发布、0c13e8f 已撤回的迁移:仅识别历史 ledger,不要求新安装创建废弃表,也不删除旧数据。 diff --git a/.github/scripts/prepare-vditor-assets.mjs b/.github/scripts/prepare-vditor-assets.mjs new file mode 100644 index 00000000..13f7cfc7 --- /dev/null +++ b/.github/scripts/prepare-vditor-assets.mjs @@ -0,0 +1,28 @@ +import { copyFile, mkdir, readFile, rm } from "node:fs/promises"; +import { dirname, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const repositoryRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../.."); +const packageRoot = resolve(repositoryRoot, "node_modules/vditor"); +const targetRoot = resolve(repositoryRoot, "frontend/public/vendor/vditor"); +const packageMetadata = JSON.parse(await readFile(resolve(packageRoot, "package.json"), "utf8")); +const runtimeFiles = [ + "dist/css/content-theme/light.css", + "dist/js/icons/ant.js", + "dist/js/i18n/en_US.js", + "dist/js/i18n/zh_CN.js", + "dist/js/lute/lute.min.js", +]; + +// 只发布聊天编辑器真正会请求的运行时,避免把公式、图表和全量高亮包带进站点。 +await rm(targetRoot, { recursive: true, force: true }); +for (const relativePath of runtimeFiles) { + const targetPath = resolve(targetRoot, relativePath); + await mkdir(dirname(targetPath), { recursive: true }); + await copyFile(resolve(packageRoot, relativePath), targetPath); +} +await mkdir(targetRoot, { recursive: true }); +await copyFile(resolve(packageRoot, "LICENSE"), resolve(targetRoot, "LICENSE")); +await readFile(resolve(targetRoot, "dist/js/lute/lute.min.js")); + +console.log(`Prepared Vditor ${packageMetadata.version} runtime assets.`); diff --git a/.github/workflows/deploy-worker.yml b/.github/workflows/deploy-worker.yml index aba4887a..e941bc1c 100644 --- a/.github/workflows/deploy-worker.yml +++ b/.github/workflows/deploy-worker.yml @@ -7,6 +7,7 @@ on: paths: - "worker/**" - "frontend/**" + - "shared/**" - "test/**" - ".github/scripts/**" - ".github/workflows/deploy-worker.yml" diff --git a/.gitignore b/.gitignore index 193e1535..359ca366 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ AGENTS.md Agent.md frontend/dist/ frontend/demo-dist/ +frontend/public/vendor/vditor/ .playwright-cli/ .tmp/ worker/src/generated/ diff --git a/CHANGELOG.md b/CHANGELOG.md index d86a40d9..3d005227 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,22 @@ EdgeChat 从 `2.1.2` 起正式采用语义化版本。更早的版本号依据已经完成的主要里程碑补记,用于说明项目演进,不对应历史 Git 标签。 +## 2.5.0 - 2026-09-12 + +- 网页群聊与私聊正文统一支持安全 Markdown,保留结构化提及、HTTP(S) 自动链接、纯文本摘要和 Markdown 原文复制。 +- 消息输入栏可原位展开 Vditor WYSIWYG 编辑器;完整编辑器、专用样式与自托管运行时仅在首次点击后加载,并继续复用原草稿、附件、回复和发送链路。 +- 原始 HTML、远程图片和动态媒体预览在编辑阶段即安全降级,不新增后端接口、数据库迁移或云资源;本次按需求仅完成本地实现与验证,未部署。 + +## 2.4.0 - 2026-09-12 + +- 新增站内可见的纯文本个人简介与可复用用户资料卡,支持 Web 设置编辑、消息/成员/私信头像入口和移动浏览器底部面板。 +- 资料按需读取,外部身份独立展示;复用既有私信与拉黑链路,完善部分更新、请求竞态和弹层焦点管理。 +- 升级须先执行 `2026-09-12-user-bio` D1 迁移;GitHub Actions 自动迁移和维护自检清单已接入,无新增云资源。 + +## 2.3.0 - 2026-09-12 + +- 新增网页端分层消息通知:前台其他会话使用 Telegram Web 风格右下角 Toast,前台当前会话仅在提及或回复时提示,后台或最小化继续使用系统通知。 + ## 2.2.1 - 2026-09-11 - 修复刷新后私信顶栏丢失拉黑状态、需要重复点击才能解除拉黑的问题。 diff --git a/README.en.md b/README.en.md index fdfc3a42..d5f65fe6 100644 --- a/README.en.md +++ b/README.en.md @@ -119,6 +119,7 @@ Admins can bind any group in EdgeChat to a Telegram group. Once bound, messages - Real-time messaging, paginated history, Telegram-style voice messages, and file messages - Block or unblock contacts from the direct-message header; direct messages pause in both directions while blocked - The web client supports Telegram-style replies, quoted-message navigation, and reply-aware direct-attention alerts +- The foreground web client shows Telegram Web-style bottom-right alerts for other conversations; the current conversation only alerts for mentions or replies, while background tabs continue to use browser system notifications - Web and Android recording, waveform seeking, playback speed controls, and two-way Telegram voice/audio sync - File uploads and avatar management - Scheduled hard deletion of expired messages diff --git a/README.ja.md b/README.ja.md index bdf8e2ec..db07e6d2 100644 --- a/README.ja.md +++ b/README.ja.md @@ -119,6 +119,7 @@ EdgeChat は Cloudflare 上にデプロイするチーム向けチャットシ - リアルタイムメッセージ、履歴のページング、Telegram 風ボイスメッセージ、ファイルメッセージ - ダイレクトメッセージのヘッダーから相手をブロック/解除でき、ブロック中は双方の送信を停止 - Web では Telegram 風の返信、引用元へのジャンプ、返信を含む「メンション」優先通知に対応 +- Web が前面にある場合、別の会話からのメッセージは Telegram Web 風の右下通知で表示し、現在の会話はメンションまたは返信時のみ通知する。バックグラウンドではブラウザのシステム通知を引き続き使用 - Web / Android の録音、波形シーク、倍速再生、Telegram voice/audio の双方向同期 - ファイルアップロードとアバター管理 - 期限切れメッセージの定期ハード削除に対応 diff --git a/README.md b/README.md index f33413e4..37e62801 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ EdgeChat 是一个部署在 Cloudflare 上的团队聊天系统:账号体系 - 实时消息、历史消息分页、Telegram 风格语音消息与文件消息 - 可在私信顶部拉黑或解除拉黑联系人,拉黑期间双方均无法继续发送私信 - 网页支持 Telegram 风格消息回复、引用跳转,以及将回复纳入「有人@我」优先提醒 +- 网页前台收到其他会话消息时显示 Telegram Web 风格右下角通知;当前会话仅为 @提及或回复提示,网页后台继续使用浏览器系统通知 - 网页和 Android 均支持录音、波形进度、倍速播放;Telegram voice/audio 可双向同步 - 文件上传与头像管理 - 支持定时硬删除过期消息 diff --git a/docs/api/edgechat-v1.openapi.yaml b/docs/api/edgechat-v1.openapi.yaml index 46cb34e5..09ed4f4b 100644 --- a/docs/api/edgechat-v1.openapi.yaml +++ b/docs/api/edgechat-v1.openapi.yaml @@ -237,20 +237,71 @@ paths: /me/profile: patch: operationId: updateProfile + description: | + Updates only explicitly supplied fields of the authenticated user. + Omitted bio/displayName/avatarKey fields keep their existing values. + bio is plain text: normalize CRLF/CR to LF, trim surrounding whitespace, + then validate at most 200 Unicode code points. Empty or whitespace-only + bio clears it. Non-string or over-limit bio is rejected without truncation. + avatarKey null clears the avatar. A client-supplied target user ID is ignored. + The same business logic is available at PATCH /api/me/profile. requestBody: required: true content: application/json: schema: type: object - required: [displayName] properties: displayName: { type: string } + bio: + type: string + description: Optional site-visible bio, at most 200 Unicode code points after normalization. avatarKey: { type: [string, "null"] } - clearAvatar: { type: boolean } responses: "200": description: Updated session + content: + application/json: + schema: + type: object + properties: + session: { $ref: "#/components/schemas/Session" } + "400": + description: Invalid profile input + "401": + description: Authentication required + /users/{userId}/profile: + get: + operationId: getUserProfile + description: | + Reads the current public profile of one local account. Requires authentication; + all signed-in site users have the same visibility as the user directory. + Deleted, disabled and nonexistent accounts all return the same unavailable response. + External identities (including numeric Telegram IDs) must not use this endpoint. + Bio is site-visible plain text, not end-to-end encrypted, and is not included in + message, reply, member, DM or bootstrap user summaries. + Also available at GET /api/users/{userId}/profile through the shared v1 proxy. + parameters: + - name: userId + in: path + required: true + schema: { type: integer, minimum: 1, maximum: 9007199254740991 } + responses: + "200": + description: Explicit public-field whitelist + content: + application/json: + schema: + type: object + required: [profile] + properties: + profile: { $ref: "#/components/schemas/UserProfile" } + "400": + description: Invalid local user ID + "401": + description: Authentication required + "404": + description: User profile unavailable /rooms/{kind}/{roomId}/messages: get: operationId: listRoomMessages @@ -523,6 +574,9 @@ components: username: { type: string } displayName: { type: string } avatarUrl: { type: string } + bio: + type: string + description: Present on Web login, profile update and session restore; omitted by older/device session producers. isAdmin: { type: boolean } sessionVersion: { type: integer } deviceSessionId: { type: string } @@ -534,6 +588,16 @@ components: username: { type: string } displayName: { type: string } avatarUrl: { type: string } + UserProfile: + type: object + additionalProperties: false + required: [id, username, displayName, avatarUrl, bio] + properties: + id: { type: integer, minimum: 1, maximum: 9007199254740991 } + username: { type: string } + displayName: { type: string } + avatarUrl: { type: string } + bio: { type: string, maxLength: 200, default: "" } Channel: type: object required: [id, name, kind] diff --git a/frontend/src/api.js b/frontend/src/api.js index a26c57a3..03b07d5c 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -88,6 +88,9 @@ export default { getUsers() { return request('/users'); }, + getUserProfile(userId, options = {}) { + return request(`/users/${encodeURIComponent(userId)}/profile`, options); + }, bootstrap() { return request('/bootstrap'); }, diff --git a/frontend/src/components/chat/InAppNotificationStack.vue b/frontend/src/components/chat/InAppNotificationStack.vue new file mode 100644 index 00000000..4eb5a5df --- /dev/null +++ b/frontend/src/components/chat/InAppNotificationStack.vue @@ -0,0 +1,223 @@ + + + + + diff --git a/frontend/src/components/chat/MemberPanel.vue b/frontend/src/components/chat/MemberPanel.vue index 630e76ec..17ce5fc9 100644 --- a/frontend/src/components/chat/MemberPanel.vue +++ b/frontend/src/components/chat/MemberPanel.vue @@ -37,7 +37,7 @@ defineProps({ } }); -const emit = defineEmits(['close', 'update:inviteUserId', 'invite', 'remove-member', 'delete-group']); +const emit = defineEmits(['close', 'update:inviteUserId', 'invite', 'remove-member', 'delete-group', 'open-profile']);