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