mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 02:49:15 +02:00
See #170: RSS feeds for channels
This commit is contained in:
parent
a04b0b706b
commit
9c22a72ed1
18 changed files with 923 additions and 6 deletions
|
@ -1,14 +1,22 @@
|
|||
import uuid
|
||||
|
||||
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
||||
from funkwhale_api.federation import keys
|
||||
from funkwhale_api.federation import models as federation_models
|
||||
from funkwhale_api.federation import utils as federation_utils
|
||||
from funkwhale_api.users import models as user_models
|
||||
|
||||
|
||||
def empty_dict():
|
||||
return {}
|
||||
|
||||
|
||||
class Channel(models.Model):
|
||||
uuid = models.UUIDField(default=uuid.uuid4, unique=True)
|
||||
artist = models.OneToOneField(
|
||||
|
@ -29,6 +37,19 @@ class Channel(models.Model):
|
|||
)
|
||||
creation_date = models.DateTimeField(default=timezone.now)
|
||||
|
||||
# metadata to enhance rss feed
|
||||
metadata = JSONField(
|
||||
default=empty_dict, max_length=50000, encoder=DjangoJSONEncoder, blank=True
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return federation_utils.full_url("/channels/{}".format(self.uuid))
|
||||
|
||||
def get_rss_url(self):
|
||||
return federation_utils.full_url(
|
||||
reverse("api:v1:channels-rss", kwargs={"uuid": self.uuid})
|
||||
)
|
||||
|
||||
|
||||
def generate_actor(username, **kwargs):
|
||||
actor_data = user_models.get_actor_data(username, **kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue