fix: voice message JSON double-nesting, '{' display
- req->data now stores 'filename|duration' instead of full nested JSON - chat_core_submit_message builds the JSON with d='filename|duration' - setVoiceMessageRoles splits d field by '|' to extract filename and duration
This commit is contained in:
1 parent
ca9d1384f2
commit
fd3b125ecb
1 file changed
+6
-9
@@ -94,9 +94,11 @@ static void setVoiceMessageRoles(QStandardItem* item, const QByteArray& data,
|
||||
item->setData(ct, MsgContentTypeRole);
|
||||
|
||||
if (ct == "audio/opus") {
|
||||
QString dur = parseJsonFieldNum(data, "dur");
|
||||
QString raw = parseJsonField(data, "d");
|
||||
int pipe = raw.indexOf('|');
|
||||
QString fname = pipe >= 0 ? raw.left(pipe) : raw;
|
||||
QString dur = pipe >= 0 ? raw.mid(pipe + 1) : QString();
|
||||
if (!dur.isEmpty()) item->setData(dur + "s", MsgVoiceDurationRole);
|
||||
QString fname = parseJsonField(data, "d");
|
||||
if (!fname.isEmpty()) {
|
||||
QString fullPath = mediaDirBase + "/" + channelId + "/" + fname;
|
||||
item->setData(fullPath, MsgVoiceFileRole);
|
||||
@@ -197,13 +199,8 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
|
||||
|
||||
QFileInfo fi(filePath);
|
||||
QString fileName = fi.fileName();
|
||||
QString jsonData = QString("{\"n\":%1,\"ch\":\"%2\",\"ct\":\"audio/opus\",\"d\":\"%3\",\"dur\":%4}")
|
||||
.arg(m_db ? m_db->myNodeId() : 0)
|
||||
.arg(m_currentChannelId)
|
||||
.arg(fileName)
|
||||
.arg(durationMs / 1000.0, 0, 'f', 1);
|
||||
|
||||
QByteArray textData = jsonData.toUtf8();
|
||||
QByteArray textData = (fileName + "|" +
|
||||
QString::number(durationMs / 1000.0, 'f', 1)).toUtf8();
|
||||
auto ts = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
struct chat_msg_submit* req = (struct chat_msg_submit*)
|
||||
|
||||
Reference in new issue
Block a user