diff --git a/fedireads/models.py b/fedireads/models.py
index 5720d886f..7feecce68 100644
--- a/fedireads/models.py
+++ b/fedireads/models.py
@@ -111,7 +111,8 @@ class ShelveActivity(Activity):
shelf = models.ForeignKey('Shelf', on_delete=models.PROTECT)
def save(self, *args, **kwargs):
- self.activity_type = 'Add'
+ if not self.activity_type:
+ self.activity_type = 'Add'
self.fedireads_type = 'Shelve'
super().save(*args, **kwargs)
diff --git a/fedireads/outgoing.py b/fedireads/outgoing.py
index 99c775404..ec9b8ea05 100644
--- a/fedireads/outgoing.py
+++ b/fedireads/outgoing.py
@@ -108,6 +108,51 @@ def handle_shelve(user, book, shelf):
broadcast(user, activity, recipients)
+def handle_unshelve(user, book, shelf):
+ ''' a local user is getting a book put on their shelf '''
+ # update the database
+ row = models.ShelfBook.objects.get(book=book, shelf=shelf)
+ row.delete()
+
+ # send out the activitypub action
+ summary = '%s removed %s from %s' % (
+ user.username,
+ book.data['title'],
+ shelf.name
+ )
+
+ uuid = uuid4()
+ activity = {
+ '@context': 'https://www.w3.org/ns/activitystreams',
+ 'id': str(uuid),
+ 'summary': summary,
+ 'type': 'Remove',
+ 'actor': user.actor,
+ 'object': {
+ 'type': 'Document',
+ 'name': book.data['title'],
+ 'url': book.openlibrary_key
+ },
+ 'target': {
+ 'type': 'Collection',
+ 'name': shelf.name,
+ 'id': shelf.activitypub_id
+ }
+ }
+ recipients = get_recipients(user, 'public')
+
+ models.ShelveActivity(
+ uuid=uuid,
+ user=user,
+ content=activity,
+ shelf=shelf,
+ book=book,
+ activity_type='Remove',
+ ).save()
+
+ broadcast(user, activity, recipients)
+
+
def handle_review(user, book, name, content, rating):
''' post a review '''
review_uuid = uuid4()
diff --git a/fedireads/templates/feed.html b/fedireads/templates/feed.html
index 7fdc44e44..51ae43f1c 100644
--- a/fedireads/templates/feed.html
+++ b/fedireads/templates/feed.html
@@ -11,7 +11,10 @@
by {{ book.authors.first.data.name }}
- + {% endfor %} {% endif %} @@ -21,7 +24,10 @@