diff options
Diffstat (limited to 'framework/domain/actions/sinkactions.cpp')
-rw-r--r-- | framework/domain/actions/sinkactions.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/framework/domain/actions/sinkactions.cpp b/framework/domain/actions/sinkactions.cpp index 5dbe623c..e8f1824b 100644 --- a/framework/domain/actions/sinkactions.cpp +++ b/framework/domain/actions/sinkactions.cpp | |||
@@ -120,27 +120,15 @@ static ActionHandlerHelper saveAsDraft("org.kde.kube.actions.save-as-draft", | |||
120 | 120 | ||
121 | if (existingMail.identifier().isEmpty()) { | 121 | if (existingMail.identifier().isEmpty()) { |
122 | Sink::Query query; | 122 | Sink::Query query; |
123 | query += Sink::Query::RequestedProperties(QByteArrayList() << "name"); | 123 | //TODO replace with capability filter |
124 | query += Sink::Query::PropertyContainsFilter("specialpurpose", "drafts"); | 124 | query += Sink::Query::PropertyFilter("type", "org.kde.maildir"); |
125 | query += Sink::Query::AccountFilter(accountId); | 125 | query += Sink::Query::AccountFilter(accountId); |
126 | qWarning() << "fetching the drafts folder"; | 126 | return Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(query) |
127 | return Sink::Store::fetchAll<Sink::ApplicationDomain::Folder>(query) | 127 | .then<void, KAsync::Job<void>, Sink::ApplicationDomain::SinkResource>([=](const Sink::ApplicationDomain::SinkResource &resource) -> KAsync::Job<void> { |
128 | .then<void, QList<Sink::ApplicationDomain::Folder::Ptr>>([=](const QList<Sink::ApplicationDomain::Folder::Ptr> folders) { | 128 | Sink::ApplicationDomain::Mail mail(resource.identifier()); |
129 | qWarning() << "fetched a drafts folder" << folders.size(); | 129 | mail.setProperty("draft", true); |
130 | if (folders.isEmpty()) { | ||
131 | return KAsync::error<void>(1, "Failed to find a drafts folder."); | ||
132 | } | ||
133 | if (folders.size() > 1) { | ||
134 | qWarning() << "Found too many draft folders (taking the first): " << folders; | ||
135 | } | ||
136 | const auto folder = folders.first(); | ||
137 | Sink::ApplicationDomain::Mail mail(folder->resourceInstanceIdentifier()); | ||
138 | mail.setProperty("folder", folder->identifier()); | ||
139 | mail.setBlobProperty("mimeMessage", message->encodedContent()); | 130 | mail.setBlobProperty("mimeMessage", message->encodedContent()); |
140 | return Sink::Store::create(mail); | 131 | return Sink::Store::create(mail); |
141 | }) | ||
142 | .then<void>([](){ | ||
143 | qWarning() << "done"; | ||
144 | }); | 132 | }); |
145 | } else { | 133 | } else { |
146 | qWarning() << "Modifying an existing mail"; | 134 | qWarning() << "Modifying an existing mail"; |