Merge pull request #793 from gpodder/remove-advertise
[mygpo.git] / mygpo / pubsub / models.py
blobecb688771acf52f69286884fff7e02db48af9c78
1 from django.db import models
3 from mygpo.podcasts.models import Podcast
4 from mygpo.core.models import UpdateInfoModel
7 class SubscriptionError(Exception):
8 pass
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)
27 # the URL of the hub
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(
35 choices=MODE_CHOICES,
36 max_length=max(map(len, [mode for mode, name in MODE_CHOICES])),
37 blank=True,
40 # indicates whether the last mode change has already been verified
41 verified = models.BooleanField(default=False)