mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 18:29:28 +02:00
See #689: now serve AP representations for uploads, tracks, albums and artists
This commit is contained in:
parent
8e4320d14a
commit
d243d6a2f5
5 changed files with 118 additions and 7 deletions
|
@ -3,6 +3,7 @@ import uuid
|
|||
from django.contrib.postgres.fields import JSONField
|
||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.conf import settings
|
||||
from django.db import models, transaction
|
||||
from django.utils import timezone
|
||||
from django.urls import reverse
|
||||
|
@ -10,6 +11,18 @@ from django.urls import reverse
|
|||
from funkwhale_api.federation import utils as federation_utils
|
||||
|
||||
|
||||
class LocalFromFidQuerySet:
|
||||
def local(self, include=True):
|
||||
host = settings.FEDERATION_HOSTNAME
|
||||
query = models.Q(fid__startswith="http://{}/".format(host)) | models.Q(
|
||||
fid__startswith="https://{}/".format(host)
|
||||
)
|
||||
if include:
|
||||
return self.filter(query)
|
||||
else:
|
||||
return self.filter(~query)
|
||||
|
||||
|
||||
class MutationQuerySet(models.QuerySet):
|
||||
def get_for_target(self, target):
|
||||
content_type = ContentType.objects.get_for_model(target)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue