See #689: now serve AP representations for uploads, tracks, albums and artists

This commit is contained in:
Eliot Berriot 2019-02-28 12:32:09 +01:00
parent 8e4320d14a
commit d243d6a2f5
5 changed files with 118 additions and 7 deletions

View file

@ -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)