Read incoming deletion activities

This commit is contained in:
Mouse Reeve 2020-10-16 17:00:10 -07:00
parent 22410e3f47
commit 7f579ffefa
4 changed files with 36 additions and 1 deletions

View file

@ -57,6 +57,7 @@ def shared_inbox(request):
'Accept': handle_follow_accept,
'Reject': handle_follow_reject,
'Create': handle_create,
'Delete': handle_delete_status,
'Like': handle_favorite,
'Announce': handle_boost,
'Add': {
@ -229,6 +230,20 @@ def handle_create(activity):
)
@app.task
def handle_delete_status(activity):
''' remove a status '''
status_id = activity['object']['id']
try:
status = models.Status.objects.select_subclasses().get(
remote_id=status_id
)
except models.Status.DoesNotExist:
return
status_builder.delete_status(status)
@app.task
def handle_favorite(activity):
''' approval of your good good post '''

View file

@ -0,0 +1,18 @@
# Generated by Django 3.0.7 on 2020-10-16 23:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookwyrm', '0053_auto_20201006_2020'),
]
operations = [
migrations.AlterField(
model_name='status',
name='deleted_date',
field=models.DateTimeField(),
),
]

View file

@ -23,7 +23,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
# the created date can't be this, because of receiving federated posts
published_date = models.DateTimeField(default=timezone.now)
deleted = models.BooleanField(default=False)
deleted_date = models.DateTimeField(default=timezone.now)
deleted_date = models.DateTimeField()
favorites = models.ManyToManyField(
'User',
symmetrical=False,

View file

@ -1,4 +1,5 @@
''' Handle user activity '''
from datetime import datetime
from django.db import IntegrityError
from bookwyrm import models
@ -9,6 +10,7 @@ from bookwyrm.sanitize_html import InputHtmlParser
def delete_status(status):
''' replace the status with a tombstone '''
status.deleted = True
status.deleted_date = datetime.now()
status.save()
def create_rating(user, book, rating):