mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
Fixes deletion
This commit is contained in:
parent
08c1553e71
commit
b393df8cab
3 changed files with 16 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
''' note serializer and children thereof '''
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, List
|
||||
from django.apps import apps
|
||||
|
||||
from .base_activity import ActivityObject, Link
|
||||
from .image import Image
|
||||
|
@ -10,6 +11,11 @@ class Tombstone(ActivityObject):
|
|||
''' the placeholder for a deleted status '''
|
||||
type: str = 'Tombstone'
|
||||
|
||||
def to_model(self, *args, **kwargs):
|
||||
''' this should never really get serialized, just searched for '''
|
||||
model = apps.get_model('bookwyrm.Status')
|
||||
return model.find_existing_by_remote_id(self.id)
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
class Note(ActivityObject):
|
||||
|
|
|
@ -84,6 +84,12 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
related_status=self,
|
||||
)
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
''' "delete" a status '''
|
||||
self.deleted = True
|
||||
self.deleted_date = timezone.now()
|
||||
self.save()
|
||||
|
||||
@property
|
||||
def recipients(self):
|
||||
''' tagged users who definitely need to get this status in broadcast '''
|
||||
|
|
|
@ -422,6 +422,8 @@ class Inbox(TestCase):
|
|||
self.assertFalse(self.status.deleted)
|
||||
activity = {
|
||||
'type': 'Delete',
|
||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"cc": ["https://example.com/user/mouse/followers"],
|
||||
'id': '%s/activity' % self.status.remote_id,
|
||||
'actor': self.remote_user.remote_id,
|
||||
'object': {'id': self.status.remote_id, 'type': 'Tombstone'},
|
||||
|
@ -451,6 +453,8 @@ class Inbox(TestCase):
|
|||
self.assertEqual(models.Notification.objects.count(), 2)
|
||||
activity = {
|
||||
'type': 'Delete',
|
||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"cc": ["https://example.com/user/mouse/followers"],
|
||||
'id': '%s/activity' % self.status.remote_id,
|
||||
'actor': self.remote_user.remote_id,
|
||||
'object': {'id': self.status.remote_id, 'type': 'Tombstone'},
|
||||
|
|
Loading…
Reference in a new issue