summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/domain/composercontroller.cpp19
-rw-r--r--framework/domain/controller.cpp4
2 files changed, 16 insertions, 7 deletions
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()
221 .then<void, QList<ApplicationDomain::SinkResource::Ptr>>([=](const QList<ApplicationDomain::SinkResource::Ptr> &resources) -> KAsync::Job<void> { 221 .then<void, QList<ApplicationDomain::SinkResource::Ptr>>([=](const QList<ApplicationDomain::SinkResource::Ptr> &resources) -> KAsync::Job<void> {
222 if (!resources.isEmpty()) { 222 if (!resources.isEmpty()) {
223 auto resourceId = resources[0]->identifier(); 223 auto resourceId = resources[0]->identifier();
224 SinkTrace() << "Sending message via resource: " << resourceId; 224 SinkLog() << "Sending message via resource: " << resourceId;
225 Mail mail(resourceId); 225 Mail mail(resourceId);
226 mail.setBlobProperty("mimeMessage", message->encodedContent()); 226 mail.setMimeMessage(message->encodedContent());
227 return Store::create(mail); 227 return Store::create(mail)
228 .then<void>([=] {
229 //Trigger a sync, but don't wait for it.
230 Store::synchronize(Sink::SyncScope{}.resourceFilter(resourceId)).exec();
231 return KAsync::null<void>();
232 });
228 } 233 }
229 return KAsync::error<void>(0, "Failed to find a MailTransport resource."); 234 return KAsync::error<void>(0, "Failed to find a MailTransport resource.");
235 })
236 .syncThen<void>([&] (const KAsync::Error &error) {
237 emit done();
230 }); 238 });
231 run(job); 239 run(job);
232 job = job.syncThen<void>([&] {
233 emit done();
234 });
235} 240}
236 241
237void ComposerController::updateSaveAsDraftAction() 242void ComposerController::updateSaveAsDraftAction()
@@ -268,7 +273,7 @@ void ComposerController::saveAsDraft()
268 return Store::create(mail); 273 return Store::create(mail);
269 }); 274 });
270 } else { 275 } else {
271 SinkWarning() << "Modifying an existing mail" << existingMail.identifier(); 276 SinkLog() << "Modifying an existing mail" << existingMail.identifier();
272 existingMail.setDraft(true); 277 existingMail.setDraft(true);
273 existingMail.setMimeMessage(message->encodedContent()); 278 existingMail.setMimeMessage(message->encodedContent());
274 return Store::modify(existingMail); 279 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 @@
20 20
21#include <QQmlEngine> 21#include <QQmlEngine>
22#include <QMetaProperty> 22#include <QMetaProperty>
23#include <sink/log.h>
23 24
24using namespace Kube; 25using namespace Kube;
25 26
@@ -49,6 +50,9 @@ void Controller::clear()
49void Controller::run(const KAsync::Job<void> &job) 50void Controller::run(const KAsync::Job<void> &job)
50{ 51{
51 auto jobToExec = job; 52 auto jobToExec = job;
53 jobToExec.onError([] (const KAsync::Error &error) {
54 SinkWarningCtx(Sink::Log::Context{"controller"}) << "Error while executing job: " << error.errorMessage;
55 });
52 //TODO handle error 56 //TODO handle error
53 //TODO attach a log context to the execution that we can gather from the job? 57 //TODO attach a log context to the execution that we can gather from the job?
54 jobToExec.exec(); 58 jobToExec.exec();