diff --git a/src/model/chatlogitem.h b/src/model/chatlogitem.h index 73e4abde0..999d1373e 100644 --- a/src/model/chatlogitem.h +++ b/src/model/chatlogitem.h @@ -29,6 +29,7 @@ struct ChatLogMessage { bool isComplete; + bool isBroken; Message message; }; diff --git a/src/persistence/history.cpp b/src/persistence/history.cpp index 04271ff79..51b98197b 100644 --- a/src/persistence/history.cpp +++ b/src/persistence/history.cpp @@ -641,12 +641,13 @@ QList History::getMessagesForFriend(const ToxPk& friendPk, "message, file_transfers.file_restart_id, " "file_transfers.file_path, file_transfers.file_name, " "file_transfers.file_size, file_transfers.direction, " - "file_transfers.file_state FROM history " + "file_transfers.file_state, broken_messages.id FROM history " "LEFT JOIN faux_offline_pending ON history.id = faux_offline_pending.id " "JOIN peers chat ON history.chat_id = chat.id " "JOIN aliases ON sender_alias = aliases.id " "JOIN peers sender ON aliases.owner = sender.id " "LEFT JOIN file_transfers ON history.file_id = file_transfers.id " + "LEFT JOIN broken_messages ON history.id = broken_messages.id " "WHERE chat.public_key='%1' " "LIMIT %2 OFFSET %3;") .arg(friendPk.toString()) @@ -662,8 +663,9 @@ QList History::getMessagesForFriend(const ToxPk& friendPk, auto friend_key = row[3].toString(); auto display_name = QString::fromUtf8(row[4].toByteArray().replace('\0', "")); auto sender_key = row[5].toString(); + auto isBroken = !row[13].isNull(); if (row[7].isNull()) { - messages += {id, isPending, timestamp, friend_key, + messages += {id, isPending, isBroken, timestamp, friend_key, display_name, sender_key, row[6].toString()}; } else { ToxFile file; @@ -675,7 +677,7 @@ QList History::getMessagesForFriend(const ToxPk& friendPk, file.direction = static_cast(row[11].toLongLong()); file.status = static_cast(row[12].toInt()); messages += - {id, isPending, timestamp, friend_key, display_name, sender_key, file}; + {id, isPending, isBroken, timestamp, friend_key, display_name, sender_key, file}; } }; @@ -688,12 +690,13 @@ QList History::getUndeliveredMessagesForFriend(const ToxPk { auto queryText = QString("SELECT history.id, faux_offline_pending.id, timestamp, chat.public_key, " - "aliases.display_name, sender.public_key, message " + "aliases.display_name, sender.public_key, message, broken_messages.id " "FROM history " "JOIN faux_offline_pending ON history.id = faux_offline_pending.id " "JOIN peers chat on history.chat_id = chat.id " "JOIN aliases on sender_alias = aliases.id " "JOIN peers sender on aliases.owner = sender.id " + "LEFT JOIN broken_messages ON history.id = broken_messages.id " "WHERE chat.public_key='%1';") .arg(friendPk.toString()); @@ -707,7 +710,8 @@ QList History::getUndeliveredMessagesForFriend(const ToxPk auto friend_key = row[3].toString(); auto display_name = QString::fromUtf8(row[4].toByteArray().replace('\0', "")); auto sender_key = row[5].toString(); - ret += {id, isPending, timestamp, friend_key, + auto isBroken = !row[7].isNull(); + ret += {id, isPending, isBroken, timestamp, friend_key, display_name, sender_key, row[6].toString()}; }; diff --git a/src/persistence/history.h b/src/persistence/history.h index 0fe322d28..065036b3a 100644 --- a/src/persistence/history.h +++ b/src/persistence/history.h @@ -111,7 +111,7 @@ class History : public QObject, public std::enable_shared_from_this public: struct HistMessage { - HistMessage(RowId id, bool isPending, QDateTime timestamp, QString chat, QString dispName, + HistMessage(RowId id, bool isPending, bool isBroken, QDateTime timestamp, QString chat, QString dispName, QString sender, QString message) : chat{chat} , sender{sender} @@ -119,10 +119,11 @@ public: , timestamp{timestamp} , id{id} , isPending{isPending} + , isBroken{isBroken} , content(std::move(message)) {} - HistMessage(RowId id, bool isPending, QDateTime timestamp, QString chat, QString dispName, + HistMessage(RowId id, bool isPending, bool isBroken, QDateTime timestamp, QString chat, QString dispName, QString sender, ToxFile file) : chat{chat} , sender{sender} @@ -130,6 +131,7 @@ public: , timestamp{timestamp} , id{id} , isPending{isPending} + , isBroken{isBroken} , content(std::move(file)) {} @@ -140,6 +142,7 @@ public: QDateTime timestamp; RowId id; bool isPending; + bool isBroken; HistMessageContent content; };