~aleteoryx/muditaos

e832fda6789d45fbf201d5ebcab55b36b70ce89c — Mateusz Grzywacz 5 years ago 17c9d3e
[feature] small fixes in message types etc
M module-apps/application-messages/ApplicationMessages.cpp => module-apps/application-messages/ApplicationMessages.cpp +1 -1
@@ 257,7 257,7 @@ namespace app
        // update date sent - it will display an old, failed sms at the the bottom, but this is correct
        auto time         = utils::time::Timestamp();
        resendRecord.date = time.getTime();
        return DBServiceAPI::SMSUpdate(this, resendRecord) != DB_ID_NONE;
        return DBServiceAPI::SMSUpdate(this, resendRecord);
    }

    bool ApplicationMessages::handleSendSmsFromThread(const utils::PhoneNumber::View &number, const UTF8 &body)

M module-db/Interface/SMSRecord.cpp => module-db/Interface/SMSRecord.cpp +15 -20
@@ 7,16 7,10 @@
#include <optional>

SMSRecord::SMSRecord(const SMSTableRow &w, const utils::PhoneNumber::View &num)
    : date(w.date), dateSent(w.dateSent), errorCode(w.errorCode), body(w.body), type(w.type), threadID(w.threadID),
      contactID(w.contactID), number(num)
{
    ID        = w.ID;
    date      = w.date;
    dateSent  = w.dateSent;
    errorCode = w.errorCode;
    number    = num;
    body      = w.body;
    type      = w.type;
    threadID  = w.threadID;
    contactID = w.contactID;
    this->ID = w.ID;
}

SMSRecordInterface::SMSRecordInterface(SmsDB *smsDb, ContactsDB *contactsDb) : smsDB(smsDb), contactsDB(contactsDb)


@@ 158,21 152,22 @@ std::unique_ptr<std::vector<SMSRecord>> SMSRecordInterface::GetLimitOffset(uint3
    return records;
}

bool SMSRecordInterface::Update(const SMSRecord &rec)
bool SMSRecordInterface::Update(const SMSRecord &recUpdated)
{
    auto sms = smsDB->sms.getById(rec.ID);
    if (!sms.isValid()) {

    auto recCurrent = GetByID(recUpdated.ID);
    if (!recCurrent.isValid()) { // if updating non-existent entry
        return false;
    }

    return smsDB->sms.update(SMSTableRow{{.ID = rec.ID},
                                         .threadID  = sms.threadID,
                                         .contactID = sms.contactID,
                                         .date      = rec.date,
                                         .dateSent  = rec.dateSent,
                                         .errorCode = rec.errorCode,
                                         .body      = rec.body,
                                         .type      = rec.type});
    return smsDB->sms.update(SMSTableRow{{.ID = recUpdated.ID},
                                         .threadID  = recCurrent.threadID,
                                         .contactID = recCurrent.contactID,
                                         .date      = recUpdated.date,
                                         .dateSent  = recUpdated.dateSent,
                                         .errorCode = recUpdated.errorCode,
                                         .body      = recUpdated.body,
                                         .type      = recUpdated.type});
}

bool SMSRecordInterface::RemoveByID(uint32_t id)

M module-db/Interface/SMSRecord.hpp => module-db/Interface/SMSRecord.hpp +1 -1
@@ 41,7 41,7 @@ class SMSRecordInterface : public RecordInterface<SMSRecord, SMSRecordField>
    bool Add(const SMSRecord &rec) override final;
    bool RemoveByID(uint32_t id) override final;
    bool RemoveByField(SMSRecordField field, const char *str) override final;
    bool Update(const SMSRecord &rec) override final;
    bool Update(const SMSRecord &recUpdated) override final;
    SMSRecord GetByID(uint32_t id) override final;

    uint32_t GetCount() override final;

M module-db/Interface/ThreadRecord.hpp => module-db/Interface/ThreadRecord.hpp +5 -9
@@ 16,19 16,15 @@ struct ThreadRecord : Record
    uint32_t msgCount       = 0;
    uint32_t unreadMsgCount = 0;
    UTF8 snippet;
    SMSType type            = SMSType::UNKNOWN;
    uint32_t contactID      = DB_ID_NONE;
    SMSType type       = SMSType::UNKNOWN;
    uint32_t contactID = DB_ID_NONE;

    ThreadRecord() = default;
    ThreadRecord(const ThreadsTableRow &rec)
        : date(rec.date), msgCount(rec.msgCount), unreadMsgCount(rec.unreadMsgCount), snippet(rec.snippet),
          type(rec.type), contactID(rec.contactID)
    {
        ID             = rec.ID;
        date           = rec.date;
        msgCount       = rec.msgCount;
        unreadMsgCount = rec.unreadMsgCount;
        snippet        = rec.snippet;
        type           = rec.type;
        contactID      = rec.contactID;
        ID = rec.ID;
    }

    bool isUnread() const

M module-services/service-db/api/DBServiceAPI.cpp => module-services/service-db/api/DBServiceAPI.cpp +1 -3
@@ 106,9 106,7 @@ SMSRecord DBServiceAPI::SMSGetLastRecord(sys::Service *serv)
        return (*smsResponse->records)[0];
    }
    else {
        SMSRecord rec;
        rec.ID = 0;
        return rec;
        return SMSRecord();
    }
}


M module-services/service-db/messages/DBNotificationMessage.hpp => module-services/service-db/messages/DBNotificationMessage.hpp +1 -1
@@ 12,7 12,7 @@ namespace db
    {
      public:
        NotificationMessage(db::Interface::Name interface, Query::Type type);
        db::Interface::Name interface;
        const db::Interface::Name interface;
        const Query::Type type;
    };
} // namespace db