Use activity type mixin

This commit is contained in:
Mouse Reeve 2021-02-04 14:36:57 -08:00
parent 7381536ad6
commit 2ef777f87e
4 changed files with 9 additions and 9 deletions

View file

@ -446,9 +446,8 @@ class CollectionItemMixin(ActivitypubMixin):
).serialize()
class ActivitybMixin(ActivitypubMixin):
class ActivityMixin(ActivitypubMixin):
''' add this mixin for models that are AP serializable '''
def save(self, *args, **kwargs):
''' broadcast activity '''
super().save(*args, **kwargs)

View file

@ -3,11 +3,11 @@ from django.db import models
from django.utils import timezone
from bookwyrm import activitypub
from .activitypub_mixin import ActivitypubMixin
from .activitypub_mixin import ActivityMixin
from .base_model import BookWyrmModel
from . import fields
class Favorite(ActivitypubMixin, BookWyrmModel):
class Favorite(ActivityMixin, BookWyrmModel):
''' fav'ing a post '''
user = fields.ForeignKey(
'User', on_delete=models.PROTECT, activitypub_field='actor')

View file

@ -4,12 +4,12 @@ from django.db.models import Q
from django.dispatch import receiver
from bookwyrm import activitypub
from .activitypub_mixin import ActivitypubMixin
from .activitypub_mixin import ActivityMixin
from .base_model import BookWyrmModel
from . import fields
class UserRelationship(ActivitypubMixin, BookWyrmModel):
class UserRelationship(ActivityMixin, BookWyrmModel):
''' many-to-many through table for followers '''
user_subject = fields.ForeignKey(
'User',

View file

@ -9,10 +9,11 @@ from django.utils import timezone
from model_utils.managers import InheritanceManager
from bookwyrm import activitypub
from .activitypub_mixin import ActivitypubMixin, OrderedCollectionPageMixin
from .activitypub_mixin import ActivitypubMixin, ActivityMixin
from .activitypub_mixin import OrderedCollectionPageMixin
from .base_model import BookWyrmModel
from . import fields
from .fields import image_serializer
from . import fields
class Status(OrderedCollectionPageMixin, BookWyrmModel):
''' any post, like a reply to a review, etc '''
@ -223,7 +224,7 @@ class Review(Status):
pure_type = 'Article'
class Boost(Status):
class Boost(ActivityMixin, Status):
''' boost'ing a post '''
boosted_status = fields.ForeignKey(
'Status',