mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
优化转账类消息导出
This commit is contained in:
@@ -534,11 +534,14 @@ class ExportService {
|
|||||||
groupNicknamesMap: Map<string, string>,
|
groupNicknamesMap: Map<string, string>,
|
||||||
getContactName: (username: string) => Promise<string>
|
getContactName: (username: string) => Promise<string>
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
const xmlType = this.extractXmlValue(content, 'type')
|
const normalizedContent = this.normalizeAppMessageContent(content || '')
|
||||||
if (xmlType !== '2000') return null
|
if (!normalizedContent) return null
|
||||||
|
|
||||||
const payerUsername = this.extractXmlValue(content, 'payer_username')
|
const xmlType = this.extractXmlValue(normalizedContent, 'type')
|
||||||
const receiverUsername = this.extractXmlValue(content, 'receiver_username')
|
if (xmlType && xmlType !== '2000') return null
|
||||||
|
|
||||||
|
const payerUsername = this.extractXmlValue(normalizedContent, 'payer_username')
|
||||||
|
const receiverUsername = this.extractXmlValue(normalizedContent, 'receiver_username')
|
||||||
if (!payerUsername || !receiverUsername) return null
|
if (!payerUsername || !receiverUsername) return null
|
||||||
|
|
||||||
const cleanedMyWxid = myWxid ? this.cleanAccountDirName(myWxid) : ''
|
const cleanedMyWxid = myWxid ? this.cleanAccountDirName(myWxid) : ''
|
||||||
@@ -3955,6 +3958,15 @@ class ExportService {
|
|||||||
const isGroup = sessionId.includes('@chatroom')
|
const isGroup = sessionId.includes('@chatroom')
|
||||||
const sessionInfo = await this.getContactInfo(sessionId)
|
const sessionInfo = await this.getContactInfo(sessionId)
|
||||||
const myInfo = await this.getContactInfo(cleanedMyWxid)
|
const myInfo = await this.getContactInfo(cleanedMyWxid)
|
||||||
|
const contactCache = new Map<string, { success: boolean; contact?: any; error?: string }>()
|
||||||
|
const getContactCached = async (username: string) => {
|
||||||
|
if (contactCache.has(username)) {
|
||||||
|
return contactCache.get(username)!
|
||||||
|
}
|
||||||
|
const result = await wcdbService.getContact(username)
|
||||||
|
contactCache.set(username, result)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
onProgress?.({
|
onProgress?.({
|
||||||
current: 0,
|
current: 0,
|
||||||
@@ -3974,6 +3986,24 @@ class ExportService {
|
|||||||
return { success: false, error: '该会话在指定时间范围内没有消息' }
|
return { success: false, error: '该会话在指定时间范围内没有消息' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const senderUsernames = new Set<string>()
|
||||||
|
for (const msg of collected.rows) {
|
||||||
|
if (msg.senderUsername) senderUsernames.add(msg.senderUsername)
|
||||||
|
}
|
||||||
|
senderUsernames.add(sessionId)
|
||||||
|
await this.preloadContacts(senderUsernames, contactCache)
|
||||||
|
|
||||||
|
const groupNicknameCandidates = isGroup
|
||||||
|
? this.buildGroupNicknameIdCandidates([
|
||||||
|
...Array.from(senderUsernames.values()),
|
||||||
|
...collected.rows.map(msg => msg.senderUsername),
|
||||||
|
cleanedMyWxid
|
||||||
|
])
|
||||||
|
: []
|
||||||
|
const groupNicknamesMap = isGroup
|
||||||
|
? await this.getGroupNicknamesForRoom(sessionId, groupNicknameCandidates)
|
||||||
|
: new Map<string, string>()
|
||||||
|
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
await this.mergeGroupMembers(sessionId, collected.memberSet, options.exportAvatars === true)
|
await this.mergeGroupMembers(sessionId, collected.memberSet, options.exportAvatars === true)
|
||||||
}
|
}
|
||||||
@@ -4186,6 +4216,23 @@ class ExportService {
|
|||||||
if (mediaItem && (msg.localType === 3 || msg.localType === 47)) {
|
if (mediaItem && (msg.localType === 3 || msg.localType === 47)) {
|
||||||
textContent = ''
|
textContent = ''
|
||||||
}
|
}
|
||||||
|
if (textContent.startsWith('[转账]') && msg.content) {
|
||||||
|
const transferDesc = await this.resolveTransferDesc(
|
||||||
|
msg.content,
|
||||||
|
cleanedMyWxid,
|
||||||
|
groupNicknamesMap,
|
||||||
|
async (username) => {
|
||||||
|
const c = await getContactCached(username)
|
||||||
|
if (c.success && c.contact) {
|
||||||
|
return c.contact.remark || c.contact.nickName || c.contact.alias || username
|
||||||
|
}
|
||||||
|
return username
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if (transferDesc) {
|
||||||
|
textContent = textContent.replace('[转账]', `[转账] (${transferDesc})`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mediaHtml = ''
|
let mediaHtml = ''
|
||||||
if (mediaItem?.kind === 'image') {
|
if (mediaItem?.kind === 'image') {
|
||||||
|
|||||||
Reference in New Issue
Block a user