vpn integration
This commit is contained in:
+32
-11
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user