summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/pixelated/config/app_factory.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/service/pixelated/config/app_factory.py b/service/pixelated/config/app_factory.py
index 9ea00bb9..4aa789e0 100644
--- a/service/pixelated/config/app_factory.py
+++ b/service/pixelated/config/app_factory.py
@@ -30,12 +30,19 @@ from leap.common.events import (
register,
events_pb2 as proto
)
-from pixelated.controllers import sync_info_controller
-def init_index_and_delete_duplicate_inboxes(querier, search_engine, mail_service):
+def init_index_and_remove_dupes(querier, search_engine, mail_service):
def wrapper(*args, **kwargs):
- querier.remove_inbox_duplicates()
+ querier.remove_duplicates()
+ search_engine.index_mails(mail_service.all_mails(), callback=querier.mark_all_as_not_recent)
+
+ return wrapper
+
+
+def update_info_sync_and_index_partial(sync_info_controller, search_engine, mail_service):
+ def wrapper(soledad_sync_data):
+ sync_info_controller.set_sync_info(soledad_sync_data)
search_engine.index_mails(mail_service.all_mails())
return wrapper
@@ -90,13 +97,18 @@ def create_app(debug_enabled, app):
tags_controller = TagsController(search_engine=search_engine)
sync_info_controller = SyncInfoController()
- register(signal=proto.SOLEDAD_SYNC_RECEIVE_STATUS, callback=sync_info_controller.set_sync_info)
+
+ register(signal=proto.SOLEDAD_SYNC_RECEIVE_STATUS,
+ callback=update_info_sync_and_index_partial(sync_info_controller=sync_info_controller,
+ search_engine=search_engine,
+ mail_service=mail_service))
register(signal=proto.SOLEDAD_DONE_DATA_SYNC,
- callback=init_index_and_delete_duplicate_inboxes(querier=soledad_querier,
+ callback=init_index_and_remove_dupes(querier=soledad_querier,
search_engine=search_engine,
mail_service=mail_service))
- _setup_routes(app, home_controller, mails_controller, tags_controller, features_controller, sync_info_controller)
+ _setup_routes(app, home_controller, mails_controller, tags_controller, features_controller,
+ sync_info_controller)
app.run(host=app.config['HOST'], debug=debug_enabled,
port=app.config['PORT'], use_reloader=False)