Peter Sanchez avatar Peter Sanchez committed 70bebfd

Added subscription_needs_update signal. Much more user friendly than automatically re-subscribing.

Comments (0)

Files changed (2)

djpubsubhubbub/signals.py

 pre_subscribe = Signal(providing_args=['created'])
 verified = Signal()
 updated = Signal(providing_args=['update'])
+subscription_needs_update = Signal(providing_args=['hub_url', 'topic_url'])

djpubsubhubbub/views.py

 from django.utils.datastructures import MultiValueDictKeyError
 
 from djpubsubhubbub.models import Subscription, DEFAULT_LEASE_SECONDS
-from djpubsubhubbub.signals import verified, updated
+from djpubsubhubbub.signals import verified, updated, subscription_needs_update
 
 
 @csrf_exempt
                 needs_update = True
 
             if needs_update:
-                expiration_time = subscription.lease_expires - datetime.now()
-                seconds = (expiration_time.days * 86400) + \
-                                                expiration_time.seconds
-                Subscription.objects.do_action(
-                    self_url,
-                    hub_url,
-                    callback=request.build_absolute_uri(),
-                    lease_seconds=seconds,
+                subscription_needs_update.send(
+                    sender=subscription,
+                    hub_url=hub_url,
+                    topic_url=self_url,
                 )
 
             updated.send(sender=subscription, update=parsed)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.