Skip to content
Snippets Groups Projects
Commit 5a93f582 authored by Sébastien Blin's avatar Sébastien Blin Committed by Guillaume Roguez
Browse files

conversationmodel: store destination into the database when a file is accepted


Change-Id: I4f98ec32b1c5040aa8510b6fb85e5c550f2e0125
Reviewed-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 5464426c
No related branches found
No related tags found
No related merge requests found
...@@ -298,6 +298,13 @@ std::string getInteractionIdByDaemonId(Database& db, const std::string& id) ...@@ -298,6 +298,13 @@ std::string getInteractionIdByDaemonId(Database& db, const std::string& id)
return ids.empty() ? "" : ids[0]; return ids.empty() ? "" : ids[0];
} }
void updateInteractionBody(Database& db, unsigned int id,
const std::string& newBody)
{
db.update("interactions", "body=:body",
{{":body", newBody}},
"id=:id", {{":id", std::to_string(id)}});
}
void updateInteractionStatus(Database& db, unsigned int id, void updateInteractionStatus(Database& db, unsigned int id,
api::interaction::Status newStatus) api::interaction::Status newStatus)
......
...@@ -174,6 +174,15 @@ std::string getDaemonIdByInteractionId(Database& db, const std::string& id); ...@@ -174,6 +174,15 @@ std::string getDaemonIdByInteractionId(Database& db, const std::string& id);
*/ */
std::string getInteractionIdByDaemonId(Database& db, const std::string& id); std::string getInteractionIdByDaemonId(Database& db, const std::string& id);
/**
* Change the body of an interaction
* @param db
* @param id
* @param newBody
*/
void updateInteractionBody(Database& db, unsigned int id,
const std::string& newBody);
/** /**
* Change the status of an interaction * Change the status of an interaction
* @param db * @param db
......
...@@ -1295,6 +1295,7 @@ void ...@@ -1295,6 +1295,7 @@ void
ConversationModel::acceptTransfer(const std::string& convUid, uint64_t interactionId, const std::string& path) ConversationModel::acceptTransfer(const std::string& convUid, uint64_t interactionId, const std::string& path)
{ {
pimpl_->lrc.getDataTransferModel().accept(interactionId, path, 0); pimpl_->lrc.getDataTransferModel().accept(interactionId, path, 0);
database::updateInteractionBody(pimpl_->db, interactionId, path);
database::updateInteractionStatus(pimpl_->db, interactionId, interaction::Status::TRANSFER_ACCEPTED); database::updateInteractionStatus(pimpl_->db, interactionId, interaction::Status::TRANSFER_ACCEPTED);
// prepare interaction Info and emit signal for the client // prepare interaction Info and emit signal for the client
...@@ -1303,6 +1304,7 @@ ConversationModel::acceptTransfer(const std::string& convUid, uint64_t interacti ...@@ -1303,6 +1304,7 @@ ConversationModel::acceptTransfer(const std::string& convUid, uint64_t interacti
auto& interactions = pimpl_->conversations[conversationIdx].interactions; auto& interactions = pimpl_->conversations[conversationIdx].interactions;
auto it = interactions.find(interactionId); auto it = interactions.find(interactionId);
if (it != interactions.end()) { if (it != interactions.end()) {
it->second.body = path;
it->second.status = interaction::Status::TRANSFER_ACCEPTED; it->second.status = interaction::Status::TRANSFER_ACCEPTED;
pimpl_->sendContactRequest(pimpl_->conversations[conversationIdx].participants.front()); pimpl_->sendContactRequest(pimpl_->conversations[conversationIdx].participants.front());
pimpl_->dirtyConversations = true; pimpl_->dirtyConversations = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment