fix: remove duplicate VK schedule toggles
This commit is contained in:
1 parent
c64ec6a2bf
commit
d70b9e5864
2 files changed
+6
-2
No files matched your search
@@ -652,6 +652,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||
item = store.get_conversation(item_id)
|
||||
else:
|
||||
store._execute("UPDATE vk_schedules SET active=? WHERE id=?", (bool(payload.get("active")), item_id))
|
||||
if bool(payload.get("active")):
|
||||
store._execute("UPDATE vk_conversations SET mailing_enabled=TRUE WHERE peer_id=(SELECT peer_id FROM vk_schedules WHERE id=?)", (item_id,))
|
||||
else:
|
||||
store._execute("UPDATE vk_conversations SET mailing_enabled=FALSE WHERE peer_id=(SELECT peer_id FROM vk_schedules WHERE id=?) AND NOT EXISTS (SELECT 1 FROM vk_schedules other WHERE other.peer_id=vk_conversations.peer_id AND other.active=TRUE)", (item_id,))
|
||||
item = next((x for x in store.list_schedules() if x["id"] == item_id), None)
|
||||
if item is None: self._json(404, {"error": "Запись не найдена"})
|
||||
else: self._json(200, {"item": item})
|
||||
|
||||
Reference in new issue
Block a user