This commit is contained in:
vladislav 2026-08-17 13:48:37 -04:00
parent d27263094a
commit 2b16ae3bb6
Signed by: Vladislav
GPG Key ID: D97C9E5E4860EE45
2 changed files with 26 additions and 18 deletions

View File

@ -4170,16 +4170,20 @@
" user: Dict = Security(get_current_user)\n",
"):\n",
" data = await invitations_collection.find_one({'_id': ObjectId(invitation_id)})\n",
" match_ = {\n",
" \"$or\": [\n",
" {\"sender._id\": user.get('_id')},\n",
" {\"user._id\": user.get('_id')},\n",
" {\"receiver._id\": user.get('_id')}\n",
" ],\n",
" 'prod': PROD,\n",
" }\n",
" if data.get('competition'):\n",
" match_.update({'competition_id': data.get('competition').get('_id')})\n",
" if data.get('exhibition_id'):\n",
" match_.update({'exhibition_id': data.get('exhibition_id')})\n",
" cursor = delivery_collection.aggregate([\n",
" {\"$match\": {\n",
" \"$or\": [\n",
" {\"sender._id\": user.get('_id')},\n",
" {\"user._id\": user.get('_id')},\n",
" {\"receiver._id\": user.get('_id')}\n",
" ],\n",
" 'prod': PROD,\n",
" 'competition_id': data.get('competition').get('_id'),\n",
" }},\n",
" {\"$match\": match_},\n",
" {\"$sort\": {\"_id\": -1}},\n",
" {\"$group\": {\n",
" \"_id\": \"$post_id\",\n",

22
main.py
View File

@ -3185,16 +3185,20 @@ async def profile_invitation(
user: Dict = Security(get_current_user)
):
data = await invitations_collection.find_one({'_id': ObjectId(invitation_id)})
match_ = {
"$or": [
{"sender._id": user.get('_id')},
{"user._id": user.get('_id')},
{"receiver._id": user.get('_id')}
],
'prod': PROD,
}
if data.get('competition'):
match_.update({'competition_id': data.get('competition').get('_id')})
if data.get('exhibition_id'):
match_.update({'exhibition_id': data.get('exhibition_id')})
cursor = delivery_collection.aggregate([
{"$match": {
"$or": [
{"sender._id": user.get('_id')},
{"user._id": user.get('_id')},
{"receiver._id": user.get('_id')}
],
'prod': PROD,
'competition_id': data.get('competition').get('_id'),
}},
{"$match": match_},
{"$sort": {"_id": -1}},
{"$group": {
"_id": "$post_id",