1 from django
.db
import models
3 from mygpo
.podcasts
.models
import Podcast
4 from mygpo
.core
.models
import UpdateInfoModel
7 class SubscriptionError(Exception):
11 class HubSubscription(UpdateInfoModel
):
12 """A client-side PubSubHubbub subscription
14 https://code.google.com/p/pubsubhubbub/"""
16 SUBSCRIBE
= "subscribe"
17 UNSUBSCRIBE
= "unsubscribe"
19 MODE_CHOICES
= ((SUBSCRIBE
, "subscribe"), (UNSUBSCRIBE
, "unsubscribe"))
21 # podcast to which the subscription belongs
22 podcast
= models
.ForeignKey(Podcast
, on_delete
=models
.PROTECT
)
24 # the topic of the subscription, ie the URL that was subscribed at the hub
25 topic_url
= models
.CharField(max_length
=2048, unique
=True)
28 hub_url
= models
.CharField(max_length
=1000)
30 # a token to verify the authenticity of the hub
31 verify_token
= models
.CharField(max_length
=32)
33 # the last mode that was requested, either subscribe or unsubscribe
34 mode
= models
.CharField(
36 max_length
=max(map(len, [mode
for mode
, name
in MODE_CHOICES
])),
40 # indicates whether the last mode change has already been verified
41 verified
= models
.BooleanField(default
=False)