Fixes bug in activitypub serialization of statuses
This commit is contained in:
parent
db898e362b
commit
2e8afb90e6
|
@ -6,6 +6,7 @@ from django.core.validators import MaxValueValidator, MinValueValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from model_utils.managers import InheritanceManager
|
from model_utils.managers import InheritanceManager
|
||||||
|
|
||||||
|
from fedireads import activitypub
|
||||||
from fedireads.utils.models import FedireadsModel
|
from fedireads.utils.models import FedireadsModel
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,6 +49,11 @@ class Status(FedireadsModel):
|
||||||
return '%s/%s/%d' % (base_path, model_name, self.id)
|
return '%s/%s/%d' % (base_path, model_name, self.id)
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def activitypub_serialize(self):
|
||||||
|
return activitypub.get_status(self)
|
||||||
|
|
||||||
|
|
||||||
class Comment(Status):
|
class Comment(Status):
|
||||||
''' like a review but without a rating and transient '''
|
''' like a review but without a rating and transient '''
|
||||||
book = models.ForeignKey('Edition', on_delete=models.PROTECT)
|
book = models.ForeignKey('Edition', on_delete=models.PROTECT)
|
||||||
|
@ -58,6 +64,11 @@ class Comment(Status):
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def activitypub_serialize(self):
|
||||||
|
return activitypub.get_comment(self)
|
||||||
|
|
||||||
|
|
||||||
class Quotation(Status):
|
class Quotation(Status):
|
||||||
''' like a review but without a rating and transient '''
|
''' like a review but without a rating and transient '''
|
||||||
book = models.ForeignKey('Edition', on_delete=models.PROTECT)
|
book = models.ForeignKey('Edition', on_delete=models.PROTECT)
|
||||||
|
@ -69,6 +80,11 @@ class Quotation(Status):
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def activitypub_serialize(self):
|
||||||
|
return activitypub.get_quotation(self)
|
||||||
|
|
||||||
|
|
||||||
class Review(Status):
|
class Review(Status):
|
||||||
''' a book review '''
|
''' a book review '''
|
||||||
name = models.CharField(max_length=255, null=True)
|
name = models.CharField(max_length=255, null=True)
|
||||||
|
@ -86,6 +102,11 @@ class Review(Status):
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def activitypub_serialize(self):
|
||||||
|
return activitypub.get_review(self)
|
||||||
|
|
||||||
|
|
||||||
class Favorite(FedireadsModel):
|
class Favorite(FedireadsModel):
|
||||||
''' fav'ing a post '''
|
''' fav'ing a post '''
|
||||||
user = models.ForeignKey('User', on_delete=models.PROTECT)
|
user = models.ForeignKey('User', on_delete=models.PROTECT)
|
||||||
|
|
|
@ -330,7 +330,7 @@ def status_page(request, username, status_id):
|
||||||
return HttpResponseNotFound()
|
return HttpResponseNotFound()
|
||||||
|
|
||||||
if is_api_request(request):
|
if is_api_request(request):
|
||||||
return JsonResponse(activitypub.get_status(status))
|
return JsonResponse(status.activitypub_serialize)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'status': status,
|
'status': status,
|
||||||
|
|
Loading…
Reference in New Issue