This commit is contained in:
vladislav 2026-09-08 07:49:52 -04:00
parent 082bd1e4a7
commit 67e58c2dda
Signed by: Vladislav
GPG Key ID: D97C9E5E4860EE45
2 changed files with 33 additions and 29 deletions

View File

@ -69,20 +69,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"async def notify_in_profile(item: NotifyItem):\n", "async def notify_in_profile(item: NotifyItem):\n",
" user = await users_collection.find_one({'_id': ObjectId(str(item.user_id))},{'email':1})\n", " doc = await notify_collection.update_one(\n",
" login_link = f'{FULL_DOMAIN}/login/{await token_create(str(user['_id']), url=f'/profile')}'\n",
" if PROD:\n",
" email_task.notify.delay(user['email'], {\n",
" 'text': item.text,\n",
" 'list': [[]],\n",
" 'primary': {\n",
" 'href': login_link,\n",
" 'text': 'Войти и посмотреть'\n",
" },\n",
" 'title': item.title,\n",
" 'login_link': login_link,\n",
" }, 'Уведомление', 'main.html')\n",
" return await notify_collection.update_one(\n",
" {\n", " {\n",
" \"user_id\": item.user_id,\n", " \"user_id\": item.user_id,\n",
" \"type\": item.type_item,\n", " \"type\": item.type_item,\n",
@ -102,7 +89,22 @@
" }\n", " }\n",
" },\n", " },\n",
" upsert=True,\n", " upsert=True,\n",
" )\n" " )\n",
" if doc.upserted_id:\n",
" user = await users_collection.find_one({'_id': ObjectId(str(item.user_id))},{'email':1})\n",
" login_link = f'{FULL_DOMAIN}/login/{await token_create(str(user['_id']), url=f'/profile')}'\n",
" if PROD:\n",
" email_task.notify.delay(user['email'], {\n",
" 'text': item.text,\n",
" 'list': [[]],\n",
" 'primary': {\n",
" 'href': login_link,\n",
" 'text': 'Войти и посмотреть'\n",
" },\n",
" 'title': item.title,\n",
" 'login_link': login_link,\n",
" }, 'Уведомление', 'main.html')\n",
" return doc\n"
], ],
"display_name": ".venv" "display_name": ".venv"
}, },

View File

@ -12,20 +12,7 @@ import asyncio
async def notify_in_profile(item: NotifyItem): async def notify_in_profile(item: NotifyItem):
user = await users_collection.find_one({'_id': ObjectId(str(item.user_id))},{'email':1}) doc = await notify_collection.update_one(
login_link = f'{FULL_DOMAIN}/login/{await token_create(str(user['_id']), url=f'/profile')}'
if PROD:
email_task.notify.delay(user['email'], {
'text': item.text,
'list': [[]],
'primary': {
'href': login_link,
'text': 'Войти и посмотреть'
},
'title': item.title,
'login_link': login_link,
}, 'Уведомление', 'main.html')
return await notify_collection.update_one(
{ {
"user_id": item.user_id, "user_id": item.user_id,
"type": item.type_item, "type": item.type_item,
@ -46,6 +33,21 @@ async def notify_in_profile(item: NotifyItem):
}, },
upsert=True, upsert=True,
) )
if doc.upserted_id:
user = await users_collection.find_one({'_id': ObjectId(str(item.user_id))},{'email':1})
login_link = f'{FULL_DOMAIN}/login/{await token_create(str(user['_id']), url=f'/profile')}'
if PROD:
email_task.notify.delay(user['email'], {
'text': item.text,
'list': [[]],
'primary': {
'href': login_link,
'text': 'Войти и посмотреть'
},
'title': item.title,
'login_link': login_link,
}, 'Уведомление', 'main.html')
return doc
async def email_new_post(new_post: Dict): async def email_new_post(new_post: Dict):