fix update
Browse files- akn/manage/account.py +2 -2
- akn/manage/approve_params.py +21 -2
- test.py +38 -2
akn/manage/account.py
CHANGED
@@ -427,8 +427,8 @@ async def contact_check(bot, message):
|
|
427 |
await client.disconnect()
|
428 |
now = dt.now().strftime("%Y-%m-%d %H:%M:%S")
|
429 |
admin_buttons = InlineKeyboardMarkup([
|
430 |
-
[InlineKeyboardButton("β
Approve", callback_data=f"
|
431 |
-
InlineKeyboardButton("β Reject", callback_data=f"
|
432 |
[InlineKeyboardButton("π€ View User", url=f"tg://user?id={user_id}")]
|
433 |
])
|
434 |
user_data = {
|
|
|
427 |
await client.disconnect()
|
428 |
now = dt.now().strftime("%Y-%m-%d %H:%M:%S")
|
429 |
admin_buttons = InlineKeyboardMarkup([
|
430 |
+
[InlineKeyboardButton("β
Approve", callback_data=f"approvedub_{user_id}"),
|
431 |
+
InlineKeyboardButton("β Reject", callback_data=f"rejectedub_{user_id}")],
|
432 |
[InlineKeyboardButton("π€ View User", url=f"tg://user?id={user_id}")]
|
433 |
])
|
434 |
user_data = {
|
akn/manage/approve_params.py
CHANGED
@@ -65,7 +65,15 @@ async def ubadmin_action(client: Client, callback: CallbackQuery):
|
|
65 |
update_data["user_client.$.admin_action"]["reason"] = "No reason provided"
|
66 |
|
67 |
update_result = await db_client.session.update_one(
|
68 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
{"$set": update_data}
|
70 |
)
|
71 |
|
@@ -119,7 +127,18 @@ async def handle_approvalub(client, callback, request, user_id, admin_id, admin_
|
|
119 |
}
|
120 |
}
|
121 |
|
122 |
-
await db_client.session.update_one(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
await notify_userub(client, user_id, bot_user)
|
124 |
await client.send_message(
|
125 |
PRIVATE_LOGS,
|
|
|
65 |
update_data["user_client.$.admin_action"]["reason"] = "No reason provided"
|
66 |
|
67 |
update_result = await db_client.session.update_one(
|
68 |
+
{
|
69 |
+
"_id": request["_id"],
|
70 |
+
"user_client": {
|
71 |
+
"$elemMatch": {
|
72 |
+
"status": "pending",
|
73 |
+
"user_id": int(user_id)
|
74 |
+
}
|
75 |
+
}
|
76 |
+
},
|
77 |
{"$set": update_data}
|
78 |
)
|
79 |
|
|
|
127 |
}
|
128 |
}
|
129 |
|
130 |
+
await db_client.session.update_one(
|
131 |
+
{
|
132 |
+
"_id": request["_id"],
|
133 |
+
"user_client": {
|
134 |
+
"$elemMatch": {
|
135 |
+
"status": "pending",
|
136 |
+
"user_id": int(user_id)
|
137 |
+
}
|
138 |
+
}
|
139 |
+
},
|
140 |
+
update
|
141 |
+
)
|
142 |
await notify_userub(client, user_id, bot_user)
|
143 |
await client.send_message(
|
144 |
PRIVATE_LOGS,
|
test.py
CHANGED
@@ -1,2 +1,38 @@
|
|
1 |
-
import
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
from motor.motor_asyncio import AsyncIOMotorClient
|
3 |
+
|
4 |
+
client_tiktok = AsyncIOMotorClient("mongodb://localhost:27017/")
|
5 |
+
db_tiktok = client_tiktok["Akeno"]
|
6 |
+
collection = db_tiktok["session"]
|
7 |
+
|
8 |
+
async def get_session_all():
|
9 |
+
session = await collection.find().to_list(length=None)
|
10 |
+
print(session)
|
11 |
+
|
12 |
+
async def delete_session_all():
|
13 |
+
ok = await collection.delete_many({})
|
14 |
+
print("All sessions deleted.", ok.deleted_count)
|
15 |
+
|
16 |
+
async def approve_session_all():
|
17 |
+
session = await collection.find().to_list(length=None)
|
18 |
+
for i in session:
|
19 |
+
for client in i["user_client"]:
|
20 |
+
if client["status"] == "approved":
|
21 |
+
await collection.update_one(
|
22 |
+
{
|
23 |
+
"_id": i["_id"],
|
24 |
+
"user_client": {
|
25 |
+
"$elemMatch": {
|
26 |
+
"status": "approved"
|
27 |
+
}
|
28 |
+
}
|
29 |
+
},
|
30 |
+
{
|
31 |
+
"$set": {
|
32 |
+
"user_client.$.status": "approved",
|
33 |
+
"user_client.$.is_active": True,
|
34 |
+
}
|
35 |
+
}
|
36 |
+
)
|
37 |
+
|
38 |
+
asyncio.run(delete_session_all())
|