mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-20 23:26:42 +00:00
Fixes incoming shelve activity
This commit is contained in:
parent
948e938040
commit
da05b99bb8
5 changed files with 28 additions and 6 deletions
|
@ -3,7 +3,7 @@ from dataclasses import dataclass
|
|||
from typing import List
|
||||
|
||||
from .base_activity import ActivityObject, Signature
|
||||
from .book import Book
|
||||
from .book import Edition
|
||||
|
||||
@dataclass(init=False)
|
||||
class Verb(ActivityObject):
|
||||
|
@ -73,7 +73,7 @@ class Add(Verb):
|
|||
@dataclass(init=False)
|
||||
class AddBook(Verb):
|
||||
'''Add activity that's aware of the book obj '''
|
||||
target: Book
|
||||
target: Edition
|
||||
type: str = 'Add'
|
||||
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ def shared_inbox(request):
|
|||
'Announce': handle_boost,
|
||||
'Add': {
|
||||
'Edition': handle_add,
|
||||
'Work': handle_add,
|
||||
},
|
||||
'Undo': {
|
||||
'Follow': handle_unfollow,
|
||||
|
|
|
@ -3,7 +3,7 @@ import re
|
|||
from django.db import models
|
||||
|
||||
from bookwyrm import activitypub
|
||||
from .base_model import BookWyrmModel
|
||||
from .base_model import ActivitypubMixin, BookWyrmModel
|
||||
from .base_model import OrderedCollectionMixin
|
||||
from . import fields
|
||||
|
||||
|
@ -51,7 +51,7 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
|
|||
unique_together = ('user', 'identifier')
|
||||
|
||||
|
||||
class ShelfBook(BookWyrmModel):
|
||||
class ShelfBook(ActivitypubMixin, BookWyrmModel):
|
||||
''' many to many join table for books and shelves '''
|
||||
book = fields.ForeignKey(
|
||||
'Edition', on_delete=models.PROTECT, activitypub_field='object')
|
||||
|
|
|
@ -433,6 +433,28 @@ class Incoming(TestCase):
|
|||
boosted_status=self.status, user=self.remote_user)
|
||||
incoming.handle_unboost(activity)
|
||||
|
||||
|
||||
def test_handle_add_book(self):
|
||||
''' shelving a book '''
|
||||
book = models.Edition.objects.create(
|
||||
title='Test', remote_id='https://bookwyrm.social/book/37292')
|
||||
shelf = models.Shelf.objects.create(
|
||||
user=self.remote_user, name='Test Shelf')
|
||||
shelf.remote_id = 'https://bookwyrm.social/user/mouse/shelf/to-read'
|
||||
shelf.save()
|
||||
|
||||
activity = {
|
||||
"id": "https://bookwyrm.social/shelfbook/6189#add",
|
||||
"type": "Add",
|
||||
"actor": "hhttps://example.com/users/rat",
|
||||
"object": "https://bookwyrm.social/book/37292",
|
||||
"target": "https://bookwyrm.social/user/mouse/shelf/to-read",
|
||||
"@context": "https://www.w3.org/ns/activitystreams"
|
||||
}
|
||||
incoming.handle_add(activity)
|
||||
self.assertEqual(shelf.books.first(), book)
|
||||
|
||||
|
||||
def test_handle_update_user(self):
|
||||
''' update an existing user '''
|
||||
datafile = pathlib.Path(__file__).parent.joinpath(
|
||||
|
|
3
bw-dev
3
bw-dev
|
@ -57,7 +57,8 @@ case "$1" in
|
|||
clean
|
||||
;;
|
||||
makemigrations)
|
||||
execweb python manage.py makemigrations
|
||||
shift 1
|
||||
execweb python manage.py makemigrations "$@"
|
||||
;;
|
||||
migrate)
|
||||
execweb python manage.py rename_app fedireads bookwyrm
|
||||
|
|
Loading…
Reference in a new issue