mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-12-01 09:15:41 +08:00
feat: 优化档案搜索与头像
新增退群监控开关 发送限速
This commit is contained in:
1 parent
3462d49516
commit
719ffa0a24
33 files changed
+1025
-64
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import type { ActionLogEntry } from '../../shared/action-log'
|
||||
import type { Contact } from '../../shared/types'
|
||||
import type { WechatActionAuditRecord } from '../../shared/wechat-action'
|
||||
import * as chat from './chat-service'
|
||||
import { wechatActionGateway } from './wechat-action-gateway'
|
||||
|
||||
export interface WechatActionLogServiceDependencies {
|
||||
listAuditRecords?: () => WechatActionAuditRecord[]
|
||||
listContacts?: () => Contact[]
|
||||
}
|
||||
|
||||
export class WechatActionLogService {
|
||||
private readonly listAuditRecords: () => WechatActionAuditRecord[]
|
||||
private readonly listContacts: () => Contact[]
|
||||
|
||||
constructor(deps: WechatActionLogServiceDependencies = {}) {
|
||||
this.listAuditRecords = deps.listAuditRecords || (() => wechatActionGateway.listAuditRecords())
|
||||
this.listContacts = deps.listContacts || (() => chat.listContacts())
|
||||
}
|
||||
|
||||
list(): ActionLogEntry[] {
|
||||
let contacts: Contact[] = []
|
||||
try {
|
||||
contacts = this.listContacts()
|
||||
} catch {
|
||||
// 数据库未连接时仍可查看历史审计。
|
||||
}
|
||||
const names = new Map(
|
||||
contacts.map((contact) => [
|
||||
contact.m_nsUsrName,
|
||||
contact.m_nsNickName?.trim() || contact.remark?.trim() || contact.m_nsUsrName
|
||||
])
|
||||
)
|
||||
|
||||
return this.listAuditRecords()
|
||||
.map((record) => ({
|
||||
id: record.actionId,
|
||||
category: 'wechat_send' as const,
|
||||
source: record.origin,
|
||||
purpose: record.purpose,
|
||||
timestamp: record.finishedAt || record.startedAt || record.createdAt,
|
||||
recipientType: record.recipientType,
|
||||
recipientId: record.recipientId,
|
||||
recipientName: record.recipientName || names.get(record.recipientId),
|
||||
contentType: record.contentType,
|
||||
contentPreview: record.contentPreview,
|
||||
status: record.sendStatus,
|
||||
errorCode: record.errorCode,
|
||||
reason: record.decisionReason
|
||||
}))
|
||||
.sort((left, right) => Date.parse(right.timestamp) - Date.parse(left.timestamp))
|
||||
}
|
||||
}
|
||||
|
||||
export const wechatActionLogService = new WechatActionLogService()
|
||||
Reference in new issue
Block a user