增加 Windows 与 Web 端到端加密群语音

This commit is contained in:
xhgit committed 2026-11-14 09:17:52 +08:00
1 parent 9c84b38fd9
commit de722039d6
8 files changed
+125 -16

No files matched your search

+2 -1
View File
@@ -239,7 +239,7 @@ export function discardPendingGroupMessage(identity: ChatIdentity, group: GroupD
})
}
export function sendGroupMessage(identity: ChatIdentity, group: GroupDetail, message: string | File, call: Call) {
export function sendGroupMessage(identity: ChatIdentity, group: GroupDetail, message: string | File, call: Call, expectedEpoch?: string) {
return update(identity, async (state, save, factory) => {
const text = typeof message === 'string' ? message.trim() : ''
let content: Uint8Array = encoder.encode(text)
@@ -248,6 +248,7 @@ export function sendGroupMessage(identity: ChatIdentity, group: GroupDetail, mes
const epochs = await call<Epoch[]>(path(group) + '/epochs')
const epoch = epochs.find((item) => item.current && item.membershipVersion === group.membershipVersion)
if (!epoch || !matchesEpoch(chat.epochs[epoch.id], epoch, group)) throw new Error('群成员或设备已变更,请先建立新世代')
if (expectedEpoch && epoch.id !== expectedEpoch) throw new Error('群加密会话已变更,请重新录音')
if (chat.pendingMessage) throw new Error('请先刷新以重试待发消息')
const id = crypto.randomUUID()
const own = chat.epochs[epoch.id]!.roster[identity.device.id]