mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-01-22 05:11:05 -05:00
ui: Don't load pan users from the db, pass them over the queue.
This commit is contained in:
parent
dae6084919
commit
62d0e5607e
@ -91,6 +91,8 @@ class ProxyDaemon:
|
|||||||
database_name = "pan.db"
|
database_name = "pan.db"
|
||||||
|
|
||||||
def __attrs_post_init__(self):
|
def __attrs_post_init__(self):
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
self.homeserver_url = self.homeserver.geturl()
|
self.homeserver_url = self.homeserver.geturl()
|
||||||
self.hostname = self.homeserver.hostname
|
self.hostname = self.homeserver.hostname
|
||||||
self.store = PanStore(self.data_dir)
|
self.store = PanStore(self.data_dir)
|
||||||
@ -130,6 +132,12 @@ class ProxyDaemon:
|
|||||||
pan_client.load_store()
|
pan_client.load_store()
|
||||||
self.pan_clients[user_id] = pan_client
|
self.pan_clients[user_id] = pan_client
|
||||||
|
|
||||||
|
loop.create_task(
|
||||||
|
self.send_queue.put(
|
||||||
|
UpdateUsersMessage(self.name, user_id, pan_client.device_id)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
pan_client.start_loop()
|
pan_client.start_loop()
|
||||||
|
|
||||||
async def _find_client(self, access_token):
|
async def _find_client(self, access_token):
|
||||||
@ -542,7 +550,9 @@ class ProxyDaemon:
|
|||||||
|
|
||||||
logger.info(f"Succesfully started new background sync client for " f"{user_id}")
|
logger.info(f"Succesfully started new background sync client for " f"{user_id}")
|
||||||
|
|
||||||
await self.send_queue.put(UpdateUsersMessage())
|
await self.send_queue.put(
|
||||||
|
UpdateUsersMessage(self.name, user_id, pan_client.device_id)
|
||||||
|
)
|
||||||
|
|
||||||
self.pan_clients[user_id] = pan_client
|
self.pan_clients[user_id] = pan_client
|
||||||
|
|
||||||
|
@ -54,7 +54,9 @@ class DaemonResponse(Message):
|
|||||||
|
|
||||||
@attr.s
|
@attr.s
|
||||||
class UpdateUsersMessage(Message):
|
class UpdateUsersMessage(Message):
|
||||||
pass
|
server = attr.ib()
|
||||||
|
user_id = attr.ib()
|
||||||
|
device_id = attr.ib()
|
||||||
|
|
||||||
|
|
||||||
@attr.s
|
@attr.s
|
||||||
|
@ -117,12 +117,10 @@ class Control:
|
|||||||
self.store = store
|
self.store = store
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
self.id_counter = id_counter
|
self.id_counter = id_counter
|
||||||
self.users = defaultdict(list)
|
self.users = defaultdict(set)
|
||||||
self.update_users()
|
|
||||||
|
|
||||||
def update_users(self):
|
def update_users(self, message):
|
||||||
for server in self.server_list:
|
self.users[message.server].add((message.user_id, message.device_id))
|
||||||
self.users[server.name] = self.store.load_users(server.name)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def message_id(self):
|
def message_id(self):
|
||||||
@ -369,7 +367,6 @@ class GlibT:
|
|||||||
self.loop = None
|
self.loop = None
|
||||||
|
|
||||||
self.store = PanStore(self.data_dir)
|
self.store = PanStore(self.data_dir)
|
||||||
self.users = self.store.load_all_users()
|
|
||||||
|
|
||||||
id_counter = IdCounter()
|
id_counter = IdCounter()
|
||||||
|
|
||||||
@ -489,7 +486,7 @@ class GlibT:
|
|||||||
self.device_if.update_devices()
|
self.device_if.update_devices()
|
||||||
|
|
||||||
elif isinstance(message, UpdateUsersMessage):
|
elif isinstance(message, UpdateUsersMessage):
|
||||||
self.control_if.update_users()
|
self.control_if.update_users(message)
|
||||||
|
|
||||||
elif isinstance(message, UnverifiedDevicesSignal):
|
elif isinstance(message, UnverifiedDevicesSignal):
|
||||||
self.control_if.UnverifiedDevices(
|
self.control_if.UnverifiedDevices(
|
||||||
|
Loading…
Reference in New Issue
Block a user