feature: command for subscriptions

This commit is contained in:
Jean-Baptiste Pasquier
2020-10-15 13:54:37 +02:00
parent fc67e73701
commit f50d423690
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,20 @@
from django.core.management.base import BaseCommand
from django.conf import settings
from djangoldp_notification.models import Subscription
class Command(BaseCommand):
help = 'Create required subscriptions'
def handle(self, *args, **options):
host = getattr(settings, 'SITE_URL')
jabber_host = getattr(settings, 'JABBER_DEFAULT_HOST')
xmpp = getattr(settings, 'PROSODY_HTTP_URL')
Subscription.objects.get_or_create(object=host+"/circles/", inbox=xmpp + "/conference." + jabber_host + "/happydev_muc_admin", field=None)
Subscription.objects.get_or_create(object=host+"/projects/", inbox=xmpp + "/conference." + jabber_host + "/happydev_muc_admin", field=None)
Subscription.objects.get_or_create(object=host+"/users/", inbox=xmpp + "/" + jabber_host + "/happydev_user_admin", field=None)
Subscription.objects.get_or_create(object=host+"/profiles/", inbox=xmpp + "/" + jabber_host + "/happydev_user_admin", field="user")
Subscription.objects.get_or_create(object=host+"/chatprofiles/", inbox=xmpp + "/" + jabber_host + "/happydev_user_admin", field="user")
Subscription.objects.get_or_create(object=host+"/accounts/", inbox=xmpp + "/" + jabber_host + "/happydev_user_admin", field="user")
self.stdout.write(self.style.SUCCESS("Successfully created subscriptions\nhost: "+host+"\nxmpp server: "+xmpp+"\njabber host: "+jabber_host))