增加群消息跨会话加密转发

This commit is contained in:
xhgit committed 2026-11-14 09:39:51 +08:00
1 parent 2e51827a07
commit c36e94fd1c
9 files changed
+212 -13

No files matched your search

+23 -2
View File
@@ -4,11 +4,12 @@ import { useSession } from '../session'
import { downloadAttachment } from './attachments'
import type { Attachment } from './attachments'
import MediaPreview from './MediaPreview.vue'
import GroupForward from './GroupForward.vue'
import VoiceMessage from './VoiceMessage.vue'
import VoiceRecorder from './VoiceRecorder.vue'
import { enableChat, trust } from './chat'
import { discardPendingGroupMessage, groupAttachmentPath, groupQuote, publishGroup, sendGroupMessage, setGroupFavorite, synchronizeGroup } from './group-chat'
import type { GroupDetail, GroupDevice, GroupLine } from './group-chat'
import { discardPendingGroupMessage, forwardGroupMessage, groupAttachmentPath, groupQuote, publishGroup, sendGroupMessage, setGroupFavorite, synchronizeGroup } from './group-chat'
import type { ForwardDestination, GroupDetail, GroupDevice, GroupLine } from './group-chat'
const props = defineProps<{ group: GroupDetail }>()
const session = useSession()
@@ -22,6 +23,8 @@ const favoritesOnly = ref(false)
const replying = ref<GroupLine>()
const editing = ref<GroupLine>()
const recalling = ref<GroupLine>()
const forwarding = ref<GroupLine>()
const forwardStatus = ref('')
const file = ref<File>()
const pendingVoice = ref<{ file: File; epoch: string }>()
const busy = ref(false)
@@ -158,6 +161,20 @@ function favorite(line: GroupLine) {
})
}
function beginForward(line: GroupLine) {
forwardStatus.value = ''
forwarding.value = line
}
function forward(destination: ForwardDestination) {
const identity = session.identity
const source = forwarding.value
if (identity && source) void run(async () => {
forwardStatus.value = await forwardGroupMessage(identity, props.group, source, destination, session.authorized)
forwarding.value = undefined
})
}
function discard() {
const identity = session.identity
if (identity) void run(async () => {
@@ -197,6 +214,7 @@ onBeforeUnmount(() => clearInterval(timer))
<section class="group-chat" aria-label="群消息">
<h3>群消息</h3>
<p v-if="error" class="error" role="alert">{{ error }}</p>
<p v-if="forwardStatus" role="status">{{ forwardStatus }}</p>
<button v-if="!code" class="primary" :disabled="busy" @click="enable">启用本机群聊</button>
<template v-else>
<p v-if="view?.warning" class="muted" role="status">{{ view.warning }}</p>
@@ -248,6 +266,7 @@ onBeforeUnmount(() => clearInterval(timer))
<small v-if="line.edited && !line.recalled" class="muted">已编辑</small>
<div v-if="!line.recalled" class="message-actions">
<button type="button" class="plain" :disabled="busy" @click="favorite(line)">{{ line.favorite ? '取消收藏' : '收藏' }}</button>
<button type="button" class="plain" :disabled="busy" @click="beginForward(line)">转发</button>
<template v-if="currentEpoch && line.epoch === currentEpoch">
<button type="button" class="plain" :disabled="busy || view?.hasPending || !!editing" @click="replying = line">引用</button>
<template v-if="line.sender === session.identity?.device.id">
@@ -258,6 +277,8 @@ onBeforeUnmount(() => clearInterval(timer))
</div>
</li>
</ul>
<GroupForward v-if="forwarding && view" :key="[forwarding.epoch, forwarding.sender, forwarding.id].join('/')"
:group-id="group.id" :pinned="view.pinned" :busy="busy" @confirm="forward" @cancel="forwarding = undefined" />
<div v-if="ready && recalling" class="confirmation">
<p>撤回后,群成员的聊天界面会更新。成员可能已保存副本。</p>
<button type="button" class="plain" :disabled="busy || view?.hasPending" @click="recall">确认撤回</button>