From 654092d41253ff993095b845a6c3e338a563547e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 12 Jan 2017 12:46:50 +0100 Subject: Fix mail sending --- framework/domain/composercontroller.cpp | 19 ++++++++++++------- framework/domain/controller.cpp | 4 ++++ 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'framework/domain') diff --git a/framework/domain/composercontroller.cpp b/framework/domain/composercontroller.cpp index a4a8857f..9fb2c6f8 100644 --- a/framework/domain/composercontroller.cpp +++ b/framework/domain/composercontroller.cpp @@ -221,17 +221,22 @@ void ComposerController::send() .then>([=](const QList &resources) -> KAsync::Job { if (!resources.isEmpty()) { auto resourceId = resources[0]->identifier(); - SinkTrace() << "Sending message via resource: " << resourceId; + SinkLog() << "Sending message via resource: " << resourceId; Mail mail(resourceId); - mail.setBlobProperty("mimeMessage", message->encodedContent()); - return Store::create(mail); + mail.setMimeMessage(message->encodedContent()); + return Store::create(mail) + .then([=] { + //Trigger a sync, but don't wait for it. + Store::synchronize(Sink::SyncScope{}.resourceFilter(resourceId)).exec(); + return KAsync::null(); + }); } return KAsync::error(0, "Failed to find a MailTransport resource."); + }) + .syncThen([&] (const KAsync::Error &error) { + emit done(); }); run(job); - job = job.syncThen([&] { - emit done(); - }); } void ComposerController::updateSaveAsDraftAction() @@ -268,7 +273,7 @@ void ComposerController::saveAsDraft() return Store::create(mail); }); } else { - SinkWarning() << "Modifying an existing mail" << existingMail.identifier(); + SinkLog() << "Modifying an existing mail" << existingMail.identifier(); existingMail.setDraft(true); existingMail.setMimeMessage(message->encodedContent()); return Store::modify(existingMail); diff --git a/framework/domain/controller.cpp b/framework/domain/controller.cpp index fb971136..52f4cd1f 100644 --- a/framework/domain/controller.cpp +++ b/framework/domain/controller.cpp @@ -20,6 +20,7 @@ #include #include +#include using namespace Kube; @@ -49,6 +50,9 @@ void Controller::clear() void Controller::run(const KAsync::Job &job) { auto jobToExec = job; + jobToExec.onError([] (const KAsync::Error &error) { + SinkWarningCtx(Sink::Log::Context{"controller"}) << "Error while executing job: " << error.errorMessage; + }); //TODO handle error //TODO attach a log context to the execution that we can gather from the job? jobToExec.exec(); -- cgit v1.2.3