vpn integration

This commit is contained in:
2026-04-11 22:07:59 +02:00
parent c4d27e9842
commit 00ac38d126
47 changed files with 945 additions and 749 deletions
+32 -11
View File
@@ -1,11 +1,14 @@
from app.utils import send_sync_channel_message
from .models import Torrent
from .utils import transmission_handler
from .models import Torrent, SharedUser
def on_post_save_torrent(instance: Torrent, created, **kwargs):
if created:
send_sync_channel_message(f"user_{instance.user_id}", "add_torrent", instance.id)
send_sync_channel_message(
f"user_{instance.user_id}", "add_torrent", instance.id
)
def on_pre_delete_torrent(instance: Torrent, **kwargs):
@@ -25,20 +28,38 @@ def on_shared_user_changed(sender, instance: Torrent, action, pk_set, **kwargs):
for user_id in pk_set:
send_sync_channel_message(f"user_{user_id}", "add_torrent", instance.id)
for user_id in instance.related_users:
send_sync_channel_message(f"user_{user_id}", "update_torrent", {
"torrent_id": instance.id,
"updated_fields": {"shared_users": list(instance.shared_users.all().values_list("id", flat=True))}
})
send_sync_channel_message(
f"user_{user_id}",
"update_torrent",
{
"torrent_id": instance.id,
"updated_fields": {
"shared_users": list(
instance.shared_users.all().values_list("id", flat=True)
)
},
},
)
case "pre_remove":
pass
case "post_remove":
for user_id in pk_set:
send_sync_channel_message(f"user_{user_id}", "remove_torrent", instance.id)
send_sync_channel_message(
f"user_{user_id}", "remove_torrent", instance.id
)
for user_id in instance.related_users:
send_sync_channel_message(f"user_{user_id}", "update_torrent", {
"torrent_id": instance.id,
"updated_fields": {"shared_users": list(instance.shared_users.all().values_list("id", flat=True))}
})
send_sync_channel_message(
f"user_{user_id}",
"update_torrent",
{
"torrent_id": instance.id,
"updated_fields": {
"shared_users": list(
instance.shared_users.all().values_list("id", flat=True)
)
},
},
)
case "pre_clear":
pass
case "post_clear":