This commit is contained in:
2022-12-04 17:03:55 +03:00
parent 5b67d372ad
commit a034eda220
10 changed files with 83 additions and 22 deletions

23
services/inbox/storage.py Normal file
View File

@@ -0,0 +1,23 @@
import asyncio
class MessagesStorage:
lock = asyncio.Lock()
chats = []
@staticmethod
async def register_chat(chat):
async with MessagesStorage.lock:
MessagesStorage.chats.append(chat)
@staticmethod
async def remove_chat(chat):
async with MessagesStorage.lock:
MessagesStorage.chats.remove(chat)
@staticmethod
async def put(message_result):
async with MessagesStorage.lock:
for chat in MessagesStorage.chats:
if message_result.message["chatId"] == chat.chat_id:
chat.queue.put_nowait(message_result)