[EGD-3435] fix SMS send again (moved to Query)

This commit is contained in:
Mateusz Grzywacz
2020-07-16 16:20:48 +02:00
committed by Mateusz Grzywacz
parent 89cfa9252f
commit 6ebdc5f447
12 changed files with 208 additions and 32 deletions

View File

@@ -1,9 +1,10 @@
#include "SMSRecord.hpp"
#include "ContactRecord.hpp"
#include "ThreadRecord.hpp"
#include "queries/sms/QuerySMSSearchByType.hpp"
#include <log/log.hpp>
#include <PhoneNumber.hpp>
#include <PhoneNumber.hpp>
#include <optional>
SMSRecord::SMSRecord(const SMSTableRow &w, const utils::PhoneNumber::View &num)
@@ -235,3 +236,30 @@ SMSRecord SMSRecordInterface::GetByID(uint32_t id)
return SMSRecord{sms, number};
}
std::unique_ptr<db::QueryResult> SMSRecordInterface::runQuery(const db::Query *query)
{
if (const auto local_query = dynamic_cast<const db::query::SMSSearchByType *>(query)) {
return runQueryImpl(local_query);
}
return nullptr;
}
std::unique_ptr<db::query::SMSSearchByTypeResult> SMSRecordInterface::runQueryImpl(
const db::query::SMSSearchByType *query)
{
auto db_result = smsDB->sms.getManyByType(query->type, query->starting_postion, query->depth);
auto records = std::make_unique<std::vector<SMSRecord>>();
ContactRecordInterface contactInterface(contactsDB);
for (const auto &w : db_result.second) {
auto contactRec = contactInterface.GetByID(w.contactID);
if (contactRec.numbers.size() != 0) {
// TODO: or numberUser? or other number
records->push_back({w, contactRec.numbers[0].number});
}
}
return std::make_unique<db::query::SMSSearchByTypeResult>(db_result.first, *records);
}