diff --git a/delivery_router.py b/delivery_router.py index e9bea1e..8b7b2be 100644 --- a/delivery_router.py +++ b/delivery_router.py @@ -56,11 +56,15 @@ async def send_delivery( continue # Уведомление получателю + if (exhibition:=existing.get('exhibition',{})) and (exhibition_id:=existing.get('exhibition_id')): + link = f'/profile/delivery/exhibition/{exhibition_id}' + else: + link = f'/profile/delivery' notify = await notify_in_profile(NotifyItem( user_id=str(existing["receiver"]["_id"]), type_item="delivery", title="Доставка картин", - link="/profile/delivery", + link=link, text=f"{str(existing['sender']['username'])} — прислал вам картины." )) @@ -106,13 +110,16 @@ async def accept_delivery( if not existing: errors.append({"item": item_id, "error": "Доставка не найдена или не для вас"}) continue - + if (exhibition:=existing.get('exhibition',{})) and (exhibition_id:=existing.get('exhibition_id')): + link = f'/profile/delivery/exhibition/{exhibition_id}' + else: + link = f'/profile/delivery' # Уведомление отправителю notify = await notify_in_profile(NotifyItem( user_id=str(existing["sender"]["_id"]), type_item="delivery", title="Доставка картин", - link="/profile/delivery", + link=link, text=f"Картина «{existing['title']}» получена — {str(existing['receiver']['username'])}." )) diff --git a/tasks.ipynb b/tasks.ipynb index 45a6f6b..a47bca3 100644 --- a/tasks.ipynb +++ b/tasks.ipynb @@ -678,12 +678,15 @@ " {'post_id': {'$in': other_ids}},\n", " {'$set': {'status': 'Приглашение отклонено'}} # как вы написали\n", " )\n", - "\n", + " if (exhibition:=invitation.get('exhibition',{})) and (exhibition_id:=invitation.get('exhibition_id')):\n", + " link = f'/profile/delivery/exhibition/{exhibition_id}'\n", + " else:\n", + " link = f'/profile/delivery'\n", " await notify_in_profile(NotifyItem(\n", - " user_id=invitation.get('exhibition',{}).get(\"user\",{}).get('_id'),\n", + " user_id=exhibition.get(\"user\",{}).get('_id'),\n", " type_item='c',\n", - " title=f'Выставка \"{invitation.get('exhibition',{}).get(\"title\")}\"',\n", - " link=f'/profile/delivery',\n", + " title=f'Выставка \"{exhibition.get(\"title\")}\"',\n", + " link=link,\n", " text=f'Художник принял условия'\n", " ))" ], diff --git a/tasks.py b/tasks.py index 505205b..533bdbe 100644 --- a/tasks.py +++ b/tasks.py @@ -516,12 +516,15 @@ async def accept_invitations(invitations_id: str, posts_ids: List[str]): {'post_id': {'$in': other_ids}}, {'$set': {'status': 'Приглашение отклонено'}} # как вы написали ) - + if (exhibition:=invitation.get('exhibition',{})) and (exhibition_id:=invitation.get('exhibition_id')): + link = f'/profile/delivery/exhibition/{exhibition_id}' + else: + link = f'/profile/delivery' await notify_in_profile(NotifyItem( - user_id=invitation.get('exhibition',{}).get("user",{}).get('_id'), + user_id=exhibition.get("user",{}).get('_id'), type_item='c', - title=f'Выставка "{invitation.get('exhibition',{}).get("title")}"', - link=f'/profile/delivery', + title=f'Выставка "{exhibition.get("title")}"', + link=link, text=f'Художник принял условия' ))