| 331 | } |
| 332 | |
| 333 | void SQLiteQueryExecutor::replaceMessage( |
| 334 | const Message &message, |
| 335 | bool backupItem) const { |
| 336 | int sidebarSourceTypeInt = static_cast<int>(MessageType::SIDEBAR_SOURCE); |
| 337 | std::string sidebarSourceType = std::to_string(sidebarSourceTypeInt); |
| 338 | |
| 339 | std::string tableName = backupItem ? "backup_messages" : "messages"; |
| 340 | std::string replaceMessageSQL = "REPLACE INTO " + tableName + |
| 341 | "(" |
| 342 | " id, local_id, thread, user, type, future_type, content, time, " |
| 343 | " target_message" |
| 344 | ")" |
| 345 | "VALUES ( " |
| 346 | " :id, :local_id, :thread, :user, :type, :future_type, :content, :time," |
| 347 | " IIF(" |
| 348 | " JSON_VALID(:content)," |
| 349 | " COALESCE(" |
| 350 | " JSON_EXTRACT(:content, '$.targetMessageID')," |
| 351 | " IIF(" |
| 352 | " :type = " + |
| 353 | sidebarSourceType + |
| 354 | "," |
| 355 | " JSON_EXTRACT(:content, '$.id')," |
| 356 | " NULL" |
| 357 | " )" |
| 358 | " )," |
| 359 | " NULL" |
| 360 | " )" |
| 361 | ");"; |
| 362 | |
| 363 | replaceEntity<Message>(this->getConnection(), replaceMessageSQL, message); |
| 364 | } |
| 365 | |
| 366 | void SQLiteQueryExecutor::updateMessageSearchIndex( |
| 367 | std::string originalMessageID, |
no test coverage detected