From 076d67b51331efbac9cbb7685f34e6dbacfbc30c Mon Sep 17 00:00:00 2001 From: Florent Daigniere Date: Sat, 29 Oct 2022 17:02:52 +0200 Subject: [PATCH] follow the protocol --- core/base/libs/podop/podop/dovecot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/base/libs/podop/podop/dovecot.py b/core/base/libs/podop/podop/dovecot.py index b1319f51..c90e188d 100644 --- a/core/base/libs/podop/podop/dovecot.py +++ b/core/base/libs/podop/podop/dovecot.py @@ -33,6 +33,8 @@ class DictProtocol(asyncio.Protocol): self.dict = None # Dictionary of active transaction lists per transaction id self.transactions = {} + # Dictionary of user per transaction id + self.transactions_user = {} super(DictProtocol, self).__init__() def connection_made(self, transport): @@ -83,7 +85,7 @@ class DictProtocol(asyncio.Protocol): key_type, key = key.decode("utf8").split("/", 1) try: result = await self.dict.get( - key, ns=(self.user if key_type == "priv" else None) + key, ns=((user if user else self.user) if key_type == "priv" else None) ) if type(result) is str: response = result.encode("utf8") @@ -99,6 +101,7 @@ class DictProtocol(asyncio.Protocol): """ Process a dict begin message """ self.transactions[transaction_id] = {} + self.transactions_user[transaction_id] = user if user else self.user def process_set(self, transaction_id, key, value): """ Process a dict set message @@ -116,10 +119,11 @@ class DictProtocol(asyncio.Protocol): key_type, key = key.decode("utf8").split("/", 1) result = await self.dict.set( key, json.loads(value), - ns=(self.user if key_type == "priv" else None) + ns=(self.transactions_user[transaction_id] if key_type == "priv" else None) ) # Remove stored transaction del self.transactions[transaction_id] + del self.transactions_user[transaction_id] return self.reply(b"O", transaction_id) def reply(self, command, *args):