randydev commited on
Commit
a1e50bc
·
verified ·
1 Parent(s): 519a5ce
Files changed (1) hide show
  1. akn/manage/approve_params.py +10 -35
akn/manage/approve_params.py CHANGED
@@ -53,30 +53,8 @@ async def ubadmin_action(client: Client, callback: CallbackQuery):
53
  await callback.message.edit_text(f"{callback.message.text}\n\n⚠️ Failed: Request not found")
54
  return
55
 
56
- update_data = {
57
- "user_client.$.status": action_type,
58
- "last_updated": dt.now().isoformat(),
59
- "user_client.$.admin_action": {
60
- "by": admin_id,
61
- "at": dt.now().isoformat(),
62
- "username": callback.from_user.username
63
- }
64
- }
65
-
66
  if action_type == "rejected":
67
- update_data["user_client.$.admin_action"]["reason"] = "No reason provided"
68
-
69
- update_result = await db_client.session.update_one(
70
- {
71
- "_id": request["_id"],
72
- "user_client.status": "pending",
73
- "user_client.user_id": int(user_id)
74
- },
75
- {"$set": update_data}
76
- )
77
-
78
- if not update_result.modified_count:
79
- await callback.answer("❌ Update failed!", show_alert=True)
80
  return
81
 
82
  if action_type == "approved":
@@ -127,24 +105,21 @@ async def handle_approvalub(client, callback, request, user_id, admin_id, admin_
127
  storage_running[user_id] = user_bots
128
 
129
  await db_client.session.update_one(
130
- {
131
- "_id": request["_id"],
132
- "user_client.status": "pending",
133
- "user_client.user_id": int(user_id)
134
- },
135
  {
136
  "$set": {
137
- "user_client.$.user_id": bot_user.id,
138
- "user_client.$.status": "approved",
139
- "user_client.$.is_active": True,
140
- "user_client.$.username": bot_user.username or "N/A",
141
- "user_client.$.started_at": dt.now().isoformat(),
142
- "user_client.$.admin_action": {
143
  "by": admin_id,
144
  "at": dt.now().isoformat()
145
  }
146
  }
147
- }
 
148
  )
149
  await notify_userub(client, user_id, bot_user)
150
  await client.send_message(
 
53
  await callback.message.edit_text(f"{callback.message.text}\n\n⚠️ Failed: Request not found")
54
  return
55
 
 
 
 
 
 
 
 
 
 
 
56
  if action_type == "rejected":
57
+ await callback.answer("Soon Fix", show_alert=True)
 
 
 
 
 
 
 
 
 
 
 
 
58
  return
59
 
60
  if action_type == "approved":
 
105
  storage_running[user_id] = user_bots
106
 
107
  await db_client.session.update_one(
108
+ {"_id": request["_id"]},
 
 
 
 
109
  {
110
  "$set": {
111
+ "user_client.$[target].user_id": bot_user.id,
112
+ "user_client.$[target].status": "approved",
113
+ "user_client.$[target].is_active": True,
114
+ "user_client.$[target].username": bot_user.username or "N/A",
115
+ "user_client.$[target].started_at": dt.now().isoformat(),
116
+ "user_client.$[target].admin_action": {
117
  "by": admin_id,
118
  "at": dt.now().isoformat()
119
  }
120
  }
121
+ },
122
+ array_filters=[{"target.user_id": int(user_id)}]
123
  )
124
  await notify_userub(client, user_id, bot_user)
125
  await client.send_message(