mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-04-25 07:26:47 +00:00
@@ -194,7 +194,7 @@ curl "http://127.0.0.1:5031/api/v1/messages?talker=xxx@chatroom&media=1&image=1&
|
||||
"messages": [
|
||||
{
|
||||
"localId": 123,
|
||||
"serverId": "456",
|
||||
"serverId": "6116895530414915131",
|
||||
"localType": 1,
|
||||
"createTime": 1738713600,
|
||||
"isSend": 0,
|
||||
|
||||
@@ -4609,6 +4609,7 @@ class ChatService {
|
||||
const createTime = this.getRowTimestampSeconds(row, ['create_time', 'createTime', 'msg_time', 'msgTime', 'time'], 0)
|
||||
const sortSeq = this.getRowInt(row, ['sort_seq'], createTime > 0 ? createTime * 1000 : 0)
|
||||
const localId = this.getRowInt(row, ['local_id'], 0)
|
||||
const serverIdRaw = this.normalizeUnsignedIntegerToken(row.server_id)
|
||||
const serverId = this.getRowInt(row, ['server_id'], 0)
|
||||
const content = this.decodeMessageContent(row.message_content, row.compress_content)
|
||||
|
||||
@@ -4635,6 +4636,7 @@ class ChatService {
|
||||
}),
|
||||
localId,
|
||||
serverId,
|
||||
serverIdRaw,
|
||||
localType,
|
||||
createTime,
|
||||
sortSeq,
|
||||
|
||||
@@ -1545,7 +1545,7 @@ class HttpService {
|
||||
talker,
|
||||
String(msg.localId),
|
||||
msg.createTime || undefined,
|
||||
msg.serverId || undefined
|
||||
this.getMessageServerId(msg) || undefined
|
||||
)
|
||||
if (result.success && result.data) {
|
||||
const fileName = `voice_${msg.localId}.wav`
|
||||
@@ -1599,9 +1599,11 @@ class HttpService {
|
||||
}
|
||||
|
||||
private toApiMessage(msg: Message, media?: ApiExportedMedia): Record<string, any> {
|
||||
const serverId = this.getMessageServerId(msg)
|
||||
|
||||
return {
|
||||
localId: msg.localId,
|
||||
serverId: msg.serverId,
|
||||
serverId: serverId || '0',
|
||||
localType: msg.localType,
|
||||
createTime: msg.createTime,
|
||||
sortSeq: msg.sortSeq,
|
||||
@@ -1617,6 +1619,27 @@ class HttpService {
|
||||
}
|
||||
}
|
||||
|
||||
private getMessageServerId(msg: Message): string {
|
||||
const raw = this.normalizeUnsignedIntToken(msg.serverIdRaw)
|
||||
if (raw && raw !== '0') return raw
|
||||
|
||||
const fallback = this.normalizeUnsignedIntToken(msg.serverId)
|
||||
return fallback && fallback !== '0' ? fallback : ''
|
||||
}
|
||||
|
||||
private normalizeUnsignedIntToken(value: unknown): string {
|
||||
if (value === null || value === undefined) return ''
|
||||
const text = String(value).trim()
|
||||
if (!text) return ''
|
||||
if (/^\d+$/.test(text)) {
|
||||
return text.replace(/^0+(?=\d)/, '')
|
||||
}
|
||||
|
||||
const numeric = Number(value)
|
||||
if (!Number.isFinite(numeric) || numeric <= 0) return ''
|
||||
return String(Math.floor(numeric))
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析时间参数
|
||||
* 支持 YYYYMMDD 格式,返回秒级时间戳
|
||||
@@ -1881,7 +1904,7 @@ class HttpService {
|
||||
timestamp: msg.createTime,
|
||||
type: this.mapMessageType(msg.localType, msg),
|
||||
content: this.getMessageContent(msg),
|
||||
platformMessageId: msg.serverId ? String(msg.serverId) : undefined,
|
||||
platformMessageId: this.getMessageServerId(msg) || undefined,
|
||||
mediaPath: mediaMap.get(msg.localId) ? `http://${this.host}:${this.port}/api/v1/media/${mediaMap.get(msg.localId)!.relativePath}` : undefined
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user