Spaces:
Paused
Paused
CBV01 commited on
Commit ·
1ecd488
1
Parent(s): e9d6d18
FIX/POLISH: Resolved forensic linting errors and optimized campaign transmission intervals. 1. Type-safe identity resolution 2. Moderate anti-spam stagger for better UX 3. Explicit audit trail for delivery logs
Browse files- backend/main.py +17 -5
backend/main.py
CHANGED
|
@@ -1416,8 +1416,12 @@ async def task_poller():
|
|
| 1416 |
|
| 1417 |
# Identity Verification
|
| 1418 |
me = await client.get_me()
|
| 1419 |
-
|
| 1420 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1421 |
|
| 1422 |
import ast
|
| 1423 |
try:
|
|
@@ -1454,14 +1458,22 @@ async def task_poller():
|
|
| 1454 |
final_msg = final_msg.replace('{{First Name}}', '').replace('{{Username}}', '')
|
| 1455 |
|
| 1456 |
# Final Spintax processing
|
| 1457 |
-
final_msg = recursive_spin(final_msg)
|
| 1458 |
|
| 1459 |
if not await client.is_user_authorized():
|
| 1460 |
print(f"BKG_TASK[{task_id}]: CRITICAL - Account not authorized for {phone_num}")
|
| 1461 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1462 |
|
| 1463 |
print(f"BKG_TASK[{task_id}]: Delivering payload to {group}...")
|
| 1464 |
-
|
|
|
|
| 1465 |
await client.send_message(entity, final_msg)
|
| 1466 |
print(f"BKG_TASK[{task_id}]: Status -> TRANSMITTED as {sender_name}")
|
| 1467 |
|
|
|
|
| 1416 |
|
| 1417 |
# Identity Verification
|
| 1418 |
me = await client.get_me()
|
| 1419 |
+
me_fn = getattr(me, 'first_name', '') or ''
|
| 1420 |
+
me_ln = getattr(me, 'last_name', '') or ''
|
| 1421 |
+
me_un = getattr(me, 'username', '') or ''
|
| 1422 |
+
me_id = getattr(me, 'id', '0')
|
| 1423 |
+
sender_name = f"{me_fn} {me_ln}".strip() or me_un or "Unknown"
|
| 1424 |
+
print(f"BKG_TASK[{task_id}]: Authenticated as '{sender_name}' (ID: {me_id})")
|
| 1425 |
|
| 1426 |
import ast
|
| 1427 |
try:
|
|
|
|
| 1458 |
final_msg = final_msg.replace('{{First Name}}', '').replace('{{Username}}', '')
|
| 1459 |
|
| 1460 |
# Final Spintax processing
|
| 1461 |
+
final_msg = recursive_spin(str(final_msg))
|
| 1462 |
|
| 1463 |
if not await client.is_user_authorized():
|
| 1464 |
print(f"BKG_TASK[{task_id}]: CRITICAL - Account not authorized for {phone_num}")
|
| 1465 |
+
# Mark failed and exit since we can't send anything
|
| 1466 |
+
conn = get_db_connection()
|
| 1467 |
+
conn.execute("UPDATE tasks SET status = 'failed' WHERE id = ?", (task_id,))
|
| 1468 |
+
if hasattr(conn, "commit"): conn.commit()
|
| 1469 |
+
if hasattr(conn, "close"): conn.close()
|
| 1470 |
+
await client.disconnect()
|
| 1471 |
+
active_tasks.remove(task_id)
|
| 1472 |
+
return
|
| 1473 |
|
| 1474 |
print(f"BKG_TASK[{task_id}]: Delivering payload to {group}...")
|
| 1475 |
+
msg_preview = str(final_msg)[:50]
|
| 1476 |
+
print(f"BKG_TASK[{task_id}]: Content Snapshot: {msg_preview}...")
|
| 1477 |
await client.send_message(entity, final_msg)
|
| 1478 |
print(f"BKG_TASK[{task_id}]: Status -> TRANSMITTED as {sender_name}")
|
| 1479 |
|