diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-13 11:23:50 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-13 11:23:50 +0100 |
commit | 48cb4a237e92ead33fa32b120c503bcbb1dafce5 (patch) | |
tree | ba3e2c79abf4c0bf61ee2feeb22b09b5cc3d1114 /examples/mailtransportresource | |
parent | 2b9bd7855843b1b58f0b124b0c92b9a8c601e2ba (diff) | |
download | sink-48cb4a237e92ead33fa32b120c503bcbb1dafce5.tar.gz sink-48cb4a237e92ead33fa32b120c503bcbb1dafce5.zip |
Avoid sending the mail twice
Diffstat (limited to 'examples/mailtransportresource')
-rw-r--r-- | examples/mailtransportresource/mailtransportresource.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/mailtransportresource/mailtransportresource.cpp b/examples/mailtransportresource/mailtransportresource.cpp index a49d62b..4dc9567 100644 --- a/examples/mailtransportresource/mailtransportresource.cpp +++ b/examples/mailtransportresource/mailtransportresource.cpp | |||
@@ -53,8 +53,12 @@ public: | |||
53 | 53 | ||
54 | } | 54 | } |
55 | 55 | ||
56 | KAsync::Job<void>send(const ApplicationDomain::Mail &mail, const MailtransportResource::Settings &settings) | 56 | KAsync::Job<void> send(const ApplicationDomain::Mail &mail, const MailtransportResource::Settings &settings) |
57 | { | 57 | { |
58 | if (!syncStore().readValue(mail.identifier()).isEmpty()) { | ||
59 | SinkLog() << "Mail is already sent: " << mail.identifier(); | ||
60 | return KAsync::null(); | ||
61 | } | ||
58 | const auto data = mail.getMimeMessage(); | 62 | const auto data = mail.getMimeMessage(); |
59 | auto msg = KMime::Message::Ptr::create(); | 63 | auto msg = KMime::Message::Ptr::create(); |
60 | msg->setHead(KMime::CRLFtoLF(data)); | 64 | msg->setHead(KMime::CRLFtoLF(data)); |
@@ -81,6 +85,7 @@ public: | |||
81 | return KAsync::error<void>(1, "Failed to send the message."); | 85 | return KAsync::error<void>(1, "Failed to send the message."); |
82 | } | 86 | } |
83 | } | 87 | } |
88 | syncStore().writeValue(mail.identifier(), "sent"); | ||
84 | return KAsync::start<void>([=] { | 89 | return KAsync::start<void>([=] { |
85 | SinkLog() << "Sent mail, and triggering move to sent mail folder: " << mail.identifier(); | 90 | SinkLog() << "Sent mail, and triggering move to sent mail folder: " << mail.identifier(); |
86 | auto modifiedMail = ApplicationDomain::Mail(mResourceInstanceIdentifier, mail.identifier(), mail.revision(), QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 91 | auto modifiedMail = ApplicationDomain::Mail(mResourceInstanceIdentifier, mail.identifier(), mail.revision(), QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
@@ -132,6 +137,7 @@ public: | |||
132 | SinkTrace() << "Dispatching message."; | 137 | SinkTrace() << "Dispatching message."; |
133 | // return send(mail, mSettings); | 138 | // return send(mail, mSettings); |
134 | } else if (operation == Sink::Operation_Removal) { | 139 | } else if (operation == Sink::Operation_Removal) { |
140 | syncStore().removeValue(mail.identifier(), ""); | ||
135 | } else if (operation == Sink::Operation_Modification) { | 141 | } else if (operation == Sink::Operation_Modification) { |
136 | } | 142 | } |
137 | return KAsync::null<QByteArray>(); | 143 | return KAsync::null<QByteArray>(); |