diff options
Diffstat (limited to 'framework/domain/actions/sinkactions.cpp')
-rw-r--r-- | framework/domain/actions/sinkactions.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index f996b91d..39b39a0a 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp | |||
@@ -98,10 +98,9 @@ static ActionHandlerHelper synchronizeHandler("org.kde.kube.actions.synchronize" | |||
98 | static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", | 98 | static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", |
99 | [](Context *context) -> bool { | 99 | [](Context *context) -> bool { |
100 | auto accountId = context->property("accountId").value<QByteArray>(); | 100 | auto accountId = context->property("accountId").value<QByteArray>(); |
101 | auto message = context->property("message").value<KMime::Message::Ptr>(); | 101 | return !accountId.isEmpty(); |
102 | return !accountId.isEmpty() && message; | ||
103 | }, | 102 | }, |
104 | [](Context *context) { | 103 | ActionHandlerHelper::JobHandler{[](Context *context) -> KAsync::Job<void> { |
105 | auto accountId = context->property("accountId").value<QByteArray>(); | 104 | auto accountId = context->property("accountId").value<QByteArray>(); |
106 | auto message = context->property("message").value<KMime::Message::Ptr>(); | 105 | auto message = context->property("message").value<KMime::Message::Ptr>(); |
107 | SinkLog() << "Sending a mail: "; | 106 | SinkLog() << "Sending a mail: "; |
@@ -109,7 +108,7 @@ static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", | |||
109 | Query query; | 108 | Query query; |
110 | query.containsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::transport); | 109 | query.containsFilter<ApplicationDomain::SinkResource::Capabilities>(ApplicationDomain::ResourceCapabilities::Mail::transport); |
111 | query.filter<SinkResource::Account>(accountId); | 110 | query.filter<SinkResource::Account>(accountId); |
112 | Store::fetchAll<ApplicationDomain::SinkResource>(query) | 111 | return Store::fetchAll<ApplicationDomain::SinkResource>(query) |
113 | .then<void, QList<ApplicationDomain::SinkResource::Ptr>>([=](const QList<ApplicationDomain::SinkResource::Ptr> &resources) -> KAsync::Job<void> { | 112 | .then<void, QList<ApplicationDomain::SinkResource::Ptr>>([=](const QList<ApplicationDomain::SinkResource::Ptr> &resources) -> KAsync::Job<void> { |
114 | if (!resources.isEmpty()) { | 113 | if (!resources.isEmpty()) { |
115 | auto resourceId = resources[0]->identifier(); | 114 | auto resourceId = resources[0]->identifier(); |
@@ -120,18 +119,18 @@ static ActionHandlerHelper sendMailHandler("org.kde.kube.actions.sendmail", | |||
120 | } | 119 | } |
121 | SinkWarning() << "Failed to find a mailtransport resource"; | 120 | SinkWarning() << "Failed to find a mailtransport resource"; |
122 | return KAsync::error<void>(0, "Failed to find a MailTransport resource."); | 121 | return KAsync::error<void>(0, "Failed to find a MailTransport resource."); |
123 | }).exec(); | 122 | }); |
124 | } | 123 | }} |
125 | ); | 124 | ); |
126 | 125 | ||
127 | static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", | 126 | static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", |
128 | [](Context *context) -> bool { | 127 | [](Context *context) -> bool { |
129 | auto accountId = context->property("accountId").value<QByteArray>(); | 128 | auto accountId = context->property("accountId").value<QByteArray>(); |
130 | auto message = context->property("message").value<KMime::Message::Ptr>(); | 129 | return !accountId.isEmpty(); |
131 | return !accountId.isEmpty() && message; | ||
132 | }, | 130 | }, |
133 | ActionHandlerHelper::JobHandler([](Context *context) -> KAsync::Job<void> { | 131 | ActionHandlerHelper::JobHandler([](Context *context) -> KAsync::Job<void> { |
134 | SinkLog() << "Executing the save-as-draft action"; | 132 | SinkLog() << "Executing the save-as-draft action"; |
133 | SinkLog() << *context; | ||
135 | const auto accountId = context->property("accountId").value<QByteArray>(); | 134 | const auto accountId = context->property("accountId").value<QByteArray>(); |
136 | const auto message = context->property("message").value<KMime::Message::Ptr>(); | 135 | const auto message = context->property("message").value<KMime::Message::Ptr>(); |
137 | auto existingMail = context->property("existingMail").value<Mail>(); | 136 | auto existingMail = context->property("existingMail").value<Mail>(); |