def action_queue(request, config): from inbox.server.actions import base q = base.get_queue() request.addfinalizer(q.empty) # make sure it's empty to start out with too q.empty() return q
def copy(self, thread_id, from_folder, to_folder): """ Copy thread locally and also sync back to the backend. """ account = self.namespace.account assert account is not None, "can't copy mail with this namespace" # make local change with session_scope() as db_session: copy_thread(self.namespace.id, db_session, thread_id, from_folder, to_folder) # sync it to the account backend q = actions.get_queue() q.enqueue(actions.get_copy_fn(account), account.id, thread_id, from_folder, to_folder) # XXX TODO register a failure handler that reverses the local state # change if the change fails to go through return "OK"
def archive(self, thread_id): """ Archive thread locally and also sync back to the backend. """ account = self.namespace.account assert account is not None, "can't archive mail with this namespace" # make local change with session_scope() as db_session: archive_thread(self.namespace.id, db_session, thread_id) # sync it to the account backend q = actions.get_queue() q.enqueue(actions.get_archive_fn(account), account.id, thread_id) # XXX TODO register a failure handler that reverses the local state # change if the change fails to go through---this could cause our # repository to get out of sync with the remote if another client # does the same change in the meantime and we apply that change and # *then* the change reversal goes through... but we can make this # eventually consistent by doing a full comparison once a day or # something. return "OK"
def delete(self, thread_id, folder_name): """ Delete thread locally and also sync back to the backend. This really just removes the entry from the folder. Message data that no longer belongs to any messages is garbage-collected asynchronously. """ account = self.namespace.account assert account is not None, "can't delete mail with this namespace" # make local change with session_scope() as db_session: delete_thread(self.namespace.id, db_session, thread_id, folder_name) # sync it to the account backend q = actions.get_queue() q.enqueue(actions.get_delete_fn(account), account.id, thread_id, folder_name) # XXX TODO register a failure handler that reverses the local state # change if the change fails to go through return "OK"