summaryrefslogtreecommitdiff
path: root/src/account.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/account.cc')
-rw-r--r--src/account.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/account.cc b/src/account.cc
index 58812db9..358aa09a 100644
--- a/src/account.cc
+++ b/src/account.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2013, John Wiegley. All rights reserved.
+ * Copyright (c) 2003-2015, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -139,6 +139,36 @@ void account_t::add_post(post_t * post)
}
}
+void account_t::add_deferred_post(const string& uuid, post_t * post)
+{
+ if (! deferred_posts)
+ deferred_posts = deferred_posts_map_t();
+
+ deferred_posts_map_t::iterator i = deferred_posts->find(uuid);
+ if (i == deferred_posts->end()) {
+ posts_list lst;
+ lst.push_back(post);
+ deferred_posts->insert(deferred_posts_map_t::value_type(uuid, lst));
+ } else {
+ (*i).second.push_back(post);
+ }
+}
+
+void account_t::apply_deferred_posts()
+{
+ if (deferred_posts) {
+ foreach (deferred_posts_map_t::value_type& pair, *deferred_posts) {
+ foreach (post_t * post, pair.second)
+ post->account->add_post(post);
+ }
+ deferred_posts = none;
+ }
+
+ // Also apply in child accounts
+ foreach (const accounts_map::value_type& pair, accounts)
+ pair.second->apply_deferred_posts();
+}
+
bool account_t::remove_post(post_t * post)
{
// It's possible that 'post' wasn't yet in this account, but try to