diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-05 14:21:48 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-05 14:21:48 +0100 |
commit | 889bda7e1d885498813ec03c16d84cb052c604b4 (patch) | |
tree | 92eba0b4c9b6af67244adeae83781c124c4e96af /common/resourcefacade.cpp | |
parent | 3ab66dd16323d8e25e7322dce0fc0cbe9eae7685 (diff) | |
download | sink-889bda7e1d885498813ec03c16d84cb052c604b4.tar.gz sink-889bda7e1d885498813ec03c16d84cb052c604b4.zip |
Remove resources and identities with the account
Diffstat (limited to 'common/resourcefacade.cpp')
-rw-r--r-- | common/resourcefacade.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/common/resourcefacade.cpp b/common/resourcefacade.cpp index 1c6b0c8..091970c 100644 --- a/common/resourcefacade.cpp +++ b/common/resourcefacade.cpp | |||
@@ -376,6 +376,21 @@ QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename ApplicationDomain | |||
376 | return qMakePair(KAsync::null<void>(), runner->emitter()); | 376 | return qMakePair(KAsync::null<void>(), runner->emitter()); |
377 | } | 377 | } |
378 | 378 | ||
379 | KAsync::Job<void> AccountFacade::remove(const Sink::ApplicationDomain::SinkAccount &account) | ||
380 | { | ||
381 | using namespace Sink::ApplicationDomain; | ||
382 | auto job = KAsync::null(); | ||
383 | |||
384 | //Remove all resources | ||
385 | job = job.then(Store::fetch<SinkResource>(Sink::Query{}.filter<SinkResource::Account>(account))) | ||
386 | .each([] (const SinkResource::Ptr &resource) { return Store::remove(*resource); }); | ||
387 | //Remove all identities | ||
388 | job = job.then(Store::fetch<Identity>(Sink::Query{}.filter<Identity::Account>(account))) | ||
389 | .each([] (const Identity::Ptr &identity) { return Store::remove(*identity); }); | ||
390 | |||
391 | return job.then(LocalStorageFacade<Sink::ApplicationDomain::SinkAccount>::remove(account)); | ||
392 | } | ||
393 | |||
379 | IdentityFacade::IdentityFacade() : LocalStorageFacade<Sink::ApplicationDomain::Identity>("identities", "type") | 394 | IdentityFacade::IdentityFacade() : LocalStorageFacade<Sink::ApplicationDomain::Identity>("identities", "type") |
380 | { | 395 | { |
381 | } | 396 | } |