From 2174ea11ececa262e62fc141d8655120a6daff93 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 2 Apr 2021 07:33:36 -0700 Subject: [PATCH 1/4] Makes user to_activity serializer args consistent --- bookwyrm/models/user.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 5ef0934c9..f951ee45a 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -182,10 +182,10 @@ class User(OrderedCollectionPageMixin, AbstractUser): **kwargs ) - def to_activity(self): + def to_activity(self, **kwargs): """override default AP serializer to add context object idk if this is the best way to go about this""" - activity_object = super().to_activity() + activity_object = super().to_activity(**kwargs) activity_object["@context"] = [ "https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1", @@ -293,10 +293,10 @@ class KeyPair(ActivitypubMixin, BookWyrmModel): self.private_key, self.public_key = create_key_pair() return super().save(*args, **kwargs) - def to_activity(self): + def to_activity(self, **kwargs): """override default AP serializer to add context object idk if this is the best way to go about this""" - activity_object = super().to_activity() + activity_object = super().to_activity(**kwargs) del activity_object["@context"] del activity_object["type"] return activity_object From 45d229d712f36704d39a7a1af5b1f19523466d10 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 2 Apr 2021 07:35:56 -0700 Subject: [PATCH 2/4] Makes outbox an optional field on the user table --- bookwyrm/activitypub/person.py | 2 +- .../migrations/0061_auto_20210402_1435.py | 24 +++++++++++++++++++ bookwyrm/models/user.py | 4 ++-- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 bookwyrm/migrations/0061_auto_20210402_1435.py diff --git a/bookwyrm/activitypub/person.py b/bookwyrm/activitypub/person.py index dafd19107..ed2ae80b2 100644 --- a/bookwyrm/activitypub/person.py +++ b/bookwyrm/activitypub/person.py @@ -21,9 +21,9 @@ class Person(ActivityObject): preferredUsername: str inbox: str - outbox: str followers: str publicKey: PublicKey + outbox: str = None endpoints: Dict = None name: str = None summary: str = None diff --git a/bookwyrm/migrations/0061_auto_20210402_1435.py b/bookwyrm/migrations/0061_auto_20210402_1435.py new file mode 100644 index 000000000..a6899aa35 --- /dev/null +++ b/bookwyrm/migrations/0061_auto_20210402_1435.py @@ -0,0 +1,24 @@ +# Generated by Django 3.1.6 on 2021-04-02 14:35 + +import bookwyrm.models.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0060_siteinvite_invitees"), + ] + + operations = [ + migrations.AlterField( + model_name="user", + name="outbox", + field=bookwyrm.models.fields.RemoteIdField( + max_length=255, + null=True, + unique=True, + validators=[bookwyrm.models.fields.validate_remote_id], + ), + ), + ] diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index f951ee45a..33dedc9ef 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -50,7 +50,7 @@ class User(OrderedCollectionPageMixin, AbstractUser): null=True, blank=True, ) - outbox = fields.RemoteIdField(unique=True) + outbox = fields.RemoteIdField(unique=True, null=True) summary = fields.HtmlField(null=True, blank=True) local = models.BooleanField(default=False) bookwyrm_user = fields.BooleanField(default=True) @@ -360,7 +360,7 @@ def set_remote_server(user_id): actor_parts = urlparse(user.remote_id) user.federated_server = get_or_create_remote_server(actor_parts.netloc) user.save(broadcast=False) - if user.bookwyrm_user: + if user.bookwyrm_user and user.outbox: get_remote_reviews.delay(user.outbox) From 9c8ce5f77d052f03c684b65545701c6d4b492fe6 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 2 Apr 2021 07:38:37 -0700 Subject: [PATCH 3/4] Makes followers an optional AP field --- bookwyrm/activitypub/person.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookwyrm/activitypub/person.py b/bookwyrm/activitypub/person.py index ed2ae80b2..4ab9f08e6 100644 --- a/bookwyrm/activitypub/person.py +++ b/bookwyrm/activitypub/person.py @@ -21,8 +21,8 @@ class Person(ActivityObject): preferredUsername: str inbox: str - followers: str publicKey: PublicKey + followers: str = None outbox: str = None endpoints: Dict = None name: str = None From bb9e49c8fa5f60a1a82b2b28268c1db908a180bf Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 2 Apr 2021 09:54:32 -0700 Subject: [PATCH 4/4] Show disabled placeholders in pagination --- bookwyrm/templates/snippets/pagination.html | 24 +++++++-------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/bookwyrm/templates/snippets/pagination.html b/bookwyrm/templates/snippets/pagination.html index 17418e8c7..252be29e3 100644 --- a/bookwyrm/templates/snippets/pagination.html +++ b/bookwyrm/templates/snippets/pagination.html @@ -1,20 +1,12 @@ {% load i18n %}