fix(01-05): align matrix confirmation scope with user and room
- carry Matrix room_id through command callbacks - persist pending confirmations by user_id and room_id
This commit is contained in:
parent
97a3dc35ea
commit
35695e043f
4 changed files with 62 additions and 25 deletions
|
|
@ -11,12 +11,20 @@ def make_handle_confirm(store=None):
|
|||
if store is None:
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Нет ожидающих подтверждений.")]
|
||||
|
||||
pending = await get_pending_confirm(store, event.chat_id)
|
||||
room_id = event.payload.get("room_id")
|
||||
pending = None
|
||||
if room_id:
|
||||
pending = await get_pending_confirm(store, event.user_id, room_id)
|
||||
if not pending:
|
||||
pending = await get_pending_confirm(store, event.chat_id)
|
||||
if not pending:
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Нет ожидающих подтверждений.")]
|
||||
|
||||
description = pending.get("description", "действие")
|
||||
await clear_pending_confirm(store, event.chat_id)
|
||||
if room_id:
|
||||
await clear_pending_confirm(store, event.user_id, room_id)
|
||||
else:
|
||||
await clear_pending_confirm(store, event.chat_id)
|
||||
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text=f"Подтверждено: {description}")]
|
||||
|
||||
|
|
@ -30,11 +38,19 @@ def make_handle_cancel(store=None):
|
|||
if store is None:
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Нет ожидающих подтверждений.")]
|
||||
|
||||
pending = await get_pending_confirm(store, event.chat_id)
|
||||
room_id = event.payload.get("room_id")
|
||||
pending = None
|
||||
if room_id:
|
||||
pending = await get_pending_confirm(store, event.user_id, room_id)
|
||||
if not pending:
|
||||
pending = await get_pending_confirm(store, event.chat_id)
|
||||
if not pending:
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Нет ожидающих подтверждений.")]
|
||||
|
||||
await clear_pending_confirm(store, event.chat_id)
|
||||
if room_id:
|
||||
await clear_pending_confirm(store, event.user_id, room_id)
|
||||
else:
|
||||
await clear_pending_confirm(store, event.chat_id)
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Действие отменено.")]
|
||||
|
||||
return handle_cancel
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue