diff --git a/README.md b/README.md index d434768..ae35c51 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ | 加密群聊 | 创建群组、通过联系人或一次性链接及二维码邀请、管理成员和转让群主。群主可发布加密公告。群列表显示本机未读,并按账号同步置顶和免打扰。 | | 加密附件 | 两端可在私聊和群聊发送、下载最多 8 MiB 的文件,并在本机预览图片和视频。群聊支持多选、拖拽发送,以及文件、图片和视频分类。 | | 加密语音 | 两端可在私聊和群聊录制、取消或发送最长 60 秒的语音消息,接收方在本机解密播放。 | -| 消息管理 | 私聊和群聊支持引用回复、编辑文字、撤回、本机搜索和收藏。消息可转发到已建立加密会话的群或已核验的联系人设备。私聊支持可选加密已读回执。 | +| 消息管理 | 私聊和群聊支持引用回复、编辑文字、撤回、本机搜索、收藏和本机删除。可打开消息里的网页链接,并将消息转发到加密群或已核验的联系人设备。私聊支持可选加密已读回执。 | | Chromium 浏览器 | Windows 端支持独立窗口、多标签、导航、搜索、书签、历史、下载和隐私窗口,网页运行在独立会话中。 | 当前为开发预览。大文件分片、音视频和多设备历史同步仍在开发,Windows 安装包尚未发布。 [开发进度与验收记录](docs/progress.md) diff --git a/docs/progress.md b/docs/progress.md index 92ce7b3..22f5bca 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -75,7 +75,7 @@ Windows 浏览器新增可跨窗口保留的本地书签和历史,每类最多 ## 聊天中的链接 -加密文字消息中的 HTTPS 链接在端侧识别。Windows 从链接启动隔离 Chromium,Web 在独立标签页打开并隔离 opener。开发环境支持本机 HTTP。真实双端测试验证消息链接点击与 Chromium 地址显示。网页卡片与从浏览器分享给联系人仍待实现。 +私聊和群聊的加密文字消息均在端侧识别 HTTPS 链接。Windows 从链接启动隔离 Chromium,Web 在独立标签页打开并隔离 opener。开发环境支持本机 HTTP。网页卡片与从浏览器分享给联系人仍待实现。 ## 会话导航和已读回执 @@ -192,3 +192,9 @@ Windows Electron 与 Edge 验证多选发送、拖拽和移除待发文件。模 群主可生成或撤销有效 24 小时的一次性邀请链接,客户端在本机绘制二维码。Web 可以直接打开链接,Windows 群组页可以粘贴链接或邀请码。服务端只存邀请码摘要,生成新链接或转让群主会撤销旧链接。领取成功会生成待接受邀请,成员确认后才加入现有群权限流程。 接口测试验证并发领取仅一次成功、链接轮换、撤销、群主转让后失效及领取后权限隔离。Windows 与 Edge 验证二维码绘制、桌面端粘贴领取、Web 登录后领取和接受或拒绝流程。 + +## 从本机删除群消息 + +Windows 和 Web 可从本机缓存删除群消息。删除同时移除其本机收藏和分类入口,保留同步游标,重新进入群聊不会重复取回该记录。其他设备照常保留各自记录。已经另存的文件由用户在系统中管理。 + +集成测试验证 Windows 从群文件视图删除收藏文件后,重新进入群聊仍保持删除,Web 保留原消息。群链接在 Edge 新标签页与 Windows 隔离 Chromium 中实际打开。群聊、私聊和服务端投递回归共 8 项通过。 diff --git a/tests/group-chat.test.mjs b/tests/group-chat.test.mjs index 90bfd67..6d68a53 100644 --- a/tests/group-chat.test.mjs +++ b/tests/group-chat.test.mjs @@ -432,6 +432,37 @@ test('Windows 与 Web 加密群聊支持消息操作、附件、语音和成员 await chat(owner).getByRole('button', { name: '下载 ' + dropped, exact: true }).waitFor() assert.equal(await chat(owner).getByRole('button', { name: '下载 ' + rejected, exact: true }).count(), 0) + const link = base + '/healthz' + assert.equal(await send(owner, link), epoch) + const webLink = chat(owner).getByRole('link', { name: link, exact: true }) + assert.equal(await webLink.getAttribute('rel'), 'noopener noreferrer') + const popup = owner.waitForEvent('popup') + await webLink.click() + const webTab = await popup + await webTab.waitForURL(link) + assert.equal(await webTab.evaluate(() => window.opener === null), true) + await webTab.close() + const opened = desktop.waitForEvent('window') + await chat(windows).getByRole('button', { name: link, exact: true }).click() + const browserTab = await opened + await browserTab.waitForFunction((expected) => document.querySelector('#address')?.value === expected, link) + await browserTab.close() + + await historyView(windows, '群文件').click() + const localFile = chat(windows).getByRole('list', { name: '群文件' }).getByRole('listitem').filter({ hasText: firstBatch }) + await localFile.getByRole('button', { name: '收藏', exact: true }).click() + await localFile.getByRole('button', { name: '取消收藏', exact: true }).waitFor() + await localFile.getByRole('button', { name: '从本机删除', exact: true }).click() + await chat(windows).getByRole('button', { name: '确认删除群消息', exact: true }).click() + await localFile.waitFor({ state: 'detached' }) + assert.equal(await chat(owner).getByRole('button', { name: '下载 ' + firstBatch, exact: true }).count(), 1) + await work(windows).getByRole('link', { name: '联系人' }).click() + await work(windows).getByRole('link', { name: '群组' }).click() + await windows.getByRole('link', { name: new RegExp(group) }).click() + await chat(windows).getByRole('button', { name: '启用本机群聊' }).click() + await chat(windows).getByText('群加密已建立', { exact: true }).waitFor() + assert.equal(await chat(windows).getByRole('button', { name: '下载 ' + firstBatch, exact: true }).count(), 0) + const voiceUploads = [] windows.on('request', (request) => { if (request.method() === 'POST' && request.url().includes('/attachments/')) voiceUploads.push(request.url()) diff --git a/web/src/chat/GroupChat.vue b/web/src/chat/GroupChat.vue index a4d7060..6e91b5a 100644 --- a/web/src/chat/GroupChat.vue +++ b/web/src/chat/GroupChat.vue @@ -5,11 +5,12 @@ import { APIError } from '../api' import { downloadAttachment, maxAttachmentSize } from './attachments' import type { Attachment } from './attachments' import MediaPreview from './MediaPreview.vue' +import MessageText from './MessageText.vue' import ForwardDialog from './ForwardDialog.vue' import VoiceMessage from './VoiceMessage.vue' import VoiceRecorder from './VoiceRecorder.vue' import { enableChat, trust } from './chat' -import { discardPendingGroupMessage, forwardGroupMessage, groupAttachmentPath, groupQuote, publishGroup, sendGroupMessage, setGroupFavorite, synchronizeGroup } from './group-chat' +import { discardPendingGroupMessage, forwardGroupMessage, groupAttachmentPath, groupQuote, publishGroup, removeLocalGroupMessage, sendGroupMessage, setGroupFavorite, synchronizeGroup } from './group-chat' import type { ForwardDestination, GroupDetail, GroupDevice, GroupLine } from './group-chat' const props = defineProps<{ group: GroupDetail }>() @@ -35,6 +36,7 @@ const mediaLimit = ref(mediaPageSize) const replying = ref() const editing = ref() const recalling = ref() +const deleting = ref() const forwarding = ref() const forwardStatus = ref('') const files = ref([]) @@ -275,6 +277,22 @@ function favorite(line: GroupLine) { }) } +function removeLocal() { + const identity = session.identity + const message = deleting.value + if (!identity || !message) return + const matches = (line?: GroupLine) => line?.id === message.id && line.epoch === message.epoch && line.sender === message.sender + void run(async () => { + const updated = await removeLocalGroupMessage(identity, props.group, message) + if (view.value) view.value.lines = updated + if (matches(replying.value)) replying.value = undefined + if (matches(editing.value)) { editing.value = undefined; draft.value = '' } + if (matches(recalling.value)) recalling.value = undefined + if (matches(forwarding.value)) forwarding.value = undefined + deleting.value = undefined + }) +} + function beginForward(line: GroupLine) { forwardStatus.value = '' forwarding.value = line @@ -413,21 +431,29 @@ onBeforeUnmount(() => { -

{{ line.text }}

+

已编辑 -
- - -