From 58aa7fe9bc1ca9eb87245f690dca38bc5462834f Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 26 Apr 2020 19:41:41 +0200 Subject: [PATCH] Fixed some bugs --- server/src/manager/LetterManager.cpp | 6 +++--- server/src/manager/LetterManager.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/manager/LetterManager.cpp b/server/src/manager/LetterManager.cpp index db5767e..41c8a49 100644 --- a/server/src/manager/LetterManager.cpp +++ b/server/src/manager/LetterManager.cpp @@ -79,7 +79,7 @@ shared_ptr LetterManager::getFullLetter(LetterId letter) { if(strcmp(columns[index], "sender") == 0) letter->sender = values[index]; else if(strcmp(columns[index], "created") == 0) - letter->created = system_clock::now() + milliseconds(stoull(values[index])); + letter->created = system_clock::now() + std::chrono::seconds{stoull(values[index])}; else if(strcmp(columns[index], "letterId") == 0) letter->id = static_cast(stoull(values[index])); else if(strcmp(columns[index], "subject") == 0) @@ -96,12 +96,12 @@ shared_ptr LetterManager::getFullLetter(LetterId letter) { return res; } -void LetterManager::createLetter(ClientUid sender, ClientUid reciver, std::string subject, std::string message) { +void LetterManager::createLetter(const ClientUid& sender, const ClientUid& reciver, const std::string& subject, const std::string& message) { sql::command(this->server->getSql(), "INSERT INTO `letters` (`serverId`, `sender`, `receiver`, `created`, `subject`, `message`, `read`) VALUES (:sid, :sender, :receiver, :created, :subject, :message, :read)", variable{":sid", this->server->getServerId()}, variable{":sender", sender}, variable{":receiver", reciver}, - variable{":created", duration_cast(system_clock::now().time_since_epoch()).count()}, + variable{":created", std::chrono::floor(system_clock::now().time_since_epoch()).count()}, variable{":subject", subject}, variable{":message", message}, variable{":read", false}) diff --git a/server/src/manager/LetterManager.h b/server/src/manager/LetterManager.h index 44875e4..db5c276 100644 --- a/server/src/manager/LetterManager.h +++ b/server/src/manager/LetterManager.h @@ -37,7 +37,7 @@ namespace ts { void updateReadFlag(LetterId, bool); void deleteLetter(LetterId); - void createLetter(ClientUid sender, ClientUid reciver, std::string subject, std::string message); + void createLetter(const ClientUid& sender, const ClientUid& reciver, const std::string& subject, const std::string& message); private: server::VirtualServer* server; };