diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index fcc4eccde..57244484a 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -300,6 +300,7 @@ class Link(ActivityObject): name: str = None mediaType: str = None id: str = None + attributedTo: str = None type: str = "Link" def serialize(self, **kwargs): diff --git a/bookwyrm/migrations/0126_filelink_link_linkdomain.py b/bookwyrm/migrations/0126_filelink_link_linkdomain.py index 98d71cc26..7e5186b6d 100644 --- a/bookwyrm/migrations/0126_filelink_link_linkdomain.py +++ b/bookwyrm/migrations/0126_filelink_link_linkdomain.py @@ -1,7 +1,8 @@ -# Generated by Django 3.2.10 on 2022-01-09 22:10 +# Generated by Django 3.2.10 on 2022-01-10 21:20 import bookwyrm.models.activitypub_mixin import bookwyrm.models.fields +from django.conf import settings from django.db import migrations, models import django.db.models.deletion @@ -49,6 +50,15 @@ class Migration(migrations.Migration): ), ), ("name", models.CharField(max_length=100)), + ( + "reported_by", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to=settings.AUTH_USER_MODEL, + ), + ), ], options={ "abstract": False, @@ -77,6 +87,14 @@ class Migration(migrations.Migration): ), ), ("url", bookwyrm.models.fields.URLField(max_length=255)), + ( + "added_by", + bookwyrm.models.fields.ForeignKey( + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to=settings.AUTH_USER_MODEL, + ), + ), ( "domain", models.ForeignKey( diff --git a/bookwyrm/models/link.py b/bookwyrm/models/link.py index 6e02c8d39..22241dddf 100644 --- a/bookwyrm/models/link.py +++ b/bookwyrm/models/link.py @@ -22,6 +22,9 @@ class Link(ActivitypubMixin, BookWyrmModel): blank=True, related_name="links", ) + added_by = fields.ForeignKey( + "User", on_delete=models.SET_NULL, null=True, activitypub_field="attributedTo" + ) activity_serializer = activitypub.Link reverse_unfurl = True @@ -66,6 +69,9 @@ class LinkDomain(BookWyrmModel): domain = models.CharField(max_length=255, unique=True) status = models.CharField(max_length=50, choices=StatusChoices, default="pending") name = models.CharField(max_length=100) + reported_by = models.ForeignKey( + "User", blank=True, null=True, on_delete=models.SET_NULL + ) def raise_not_editable(self, viewer): if viewer.has_perm("moderate_post"):