MCPcopy Create free account
hub / github.com/CommE2E/comm / replaceMessage

Method replaceMessage

native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp:333–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331}
332
333void 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
366void SQLiteQueryExecutor::updateMessageSearchIndex(
367 std::string originalMessageID,

Callers 2

executeMethod · 0.45
storeMessageInfosMethod · 0.45

Calls 1

getConnectionMethod · 0.95

Tested by

no test coverage detected