mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-08-18 03:57:02 +08:00
feat: 添加微信消息防撤回功能
This commit is contained in:
@@ -8,6 +8,7 @@ import type {
|
||||
DatabaseKeyValidationCode,
|
||||
DatabaseKeyValidationResult
|
||||
} from '../../shared/database-key'
|
||||
import { mergeRecallArchiveMessages, recordRecallArchiveMessages } from './recall-archive-service'
|
||||
|
||||
export function getCurrentKey(): string {
|
||||
if (!dbRef) return ''
|
||||
@@ -49,8 +50,11 @@ export interface FormattedMessage {
|
||||
voiceDataUrl?: string
|
||||
voiceDuration?: number
|
||||
localId?: number
|
||||
serverId?: string
|
||||
createTime?: number
|
||||
sessionId?: string
|
||||
recalled?: boolean
|
||||
recalledBy?: string
|
||||
}
|
||||
|
||||
export interface GroupSnapshot {
|
||||
@@ -163,7 +167,7 @@ export function getContactAvatars(usernames: string[]): Record<string, string> {
|
||||
return dbRef.getWcdb4Client().getAvatarUrls(normalized)
|
||||
}
|
||||
|
||||
export function listMessages(
|
||||
function listSourceMessages(
|
||||
userMd5: string,
|
||||
startTime?: number,
|
||||
endTime?: number,
|
||||
@@ -264,8 +268,12 @@ export function listMessages(
|
||||
|
||||
if (msgType === 34) content = '[语音消息]'
|
||||
|
||||
const recoveredFromRecallJournal = Boolean(msg['_wxe_recovered'] || msg.raw?.['_wxe_recovered'])
|
||||
|
||||
return {
|
||||
id: msg.mesLocalID || Math.random().toString(),
|
||||
id: recoveredFromRecallJournal
|
||||
? `recovered:${msg.mesLocalID || msg.serverId || createTime}`
|
||||
: msg.mesLocalID || Math.random().toString(),
|
||||
from: contentData?.type === 'system' ? 'system' : isMine ? 'assistant' : 'user',
|
||||
isSender: isMine,
|
||||
type: displayType,
|
||||
@@ -276,7 +284,9 @@ export function listMessages(
|
||||
senderId,
|
||||
sessionId: username,
|
||||
localId,
|
||||
serverId: typeof msg.serverId === 'string' ? msg.serverId : undefined,
|
||||
createTime,
|
||||
recoveredFromRecallJournal,
|
||||
contentData
|
||||
}
|
||||
})
|
||||
@@ -287,6 +297,19 @@ export function listMessages(
|
||||
return formatted
|
||||
}
|
||||
|
||||
export function listMessages(
|
||||
userMd5: string,
|
||||
startTime?: number,
|
||||
endTime?: number,
|
||||
options?: { limit?: number }
|
||||
): FormattedMessage[] {
|
||||
const sourceMessages = listSourceMessages(userMd5, startTime, endTime, options)
|
||||
if (!dbRef) return sourceMessages
|
||||
const username = dbRef.getWcdb4Client().getUsernameByMd5(userMd5) || ''
|
||||
recordRecallArchiveMessages(userMd5, username, sourceMessages)
|
||||
return mergeRecallArchiveMessages(userMd5, sourceMessages, startTime, endTime, options?.limit)
|
||||
}
|
||||
|
||||
export function getGroupSnapshot(userMd5: string): GroupSnapshot | null {
|
||||
if (!dbRef) return null
|
||||
const wcdb4Client = dbRef.getWcdb4Client()
|
||||
|
||||
Reference in New Issue
Block a user