Encode strings before hashing
[mygpo.git] / mygpo / pubsub / models.py
blob36eb6203425073f3b93ffd056481847ff442ad82
3 from django.db import models
5 from mygpo.podcasts.models import Podcast
6 from mygpo.core.models import UpdateInfoModel
9 class SubscriptionError(Exception):
10 pass
13 class HubSubscription(UpdateInfoModel):
14 """ A client-side PubSubHubbub subscription
16 https://code.google.com/p/pubsubhubbub/ """
18 SUBSCRIBE = 'subscribe'
19 UNSUBSCRIBE = 'unsubscribe'
21 MODE_CHOICES = (
22 (SUBSCRIBE, 'subscribe'),
23 (UNSUBSCRIBE, 'unsubscribe'),
26 # podcast to which the subscription belongs
27 podcast = models.ForeignKey(Podcast, on_delete=models.PROTECT)
29 # the topic of the subscription, ie the URL that was subscribed at the hub
30 topic_url = models.CharField(max_length=2048, unique=True)
32 # the URL of the hub
33 hub_url = models.CharField(max_length=1000)
35 # a token to verify the authenticity of the hub
36 verify_token = models.CharField(max_length=32)
38 # the last mode that was requested, either subscribe or unsubscribe
39 mode = models.CharField(
40 choices=MODE_CHOICES,
41 max_length=max(map(len, [mode for mode, name in MODE_CHOICES])),
42 blank=True,
45 # indicates whether the last mode change has already been verified
46 verified = models.BooleanField(default=False)