Repository: bookwyrm-social/bookwyrm

Issue:
Profile picture not displayed on Mastodon
**Describe the bug**

When I open my BookWyrm profile on Mastodon, the profile picture is displayed as the default Mastodon "missing profile pic" elephant. This is a relatively new thing (it used to work just a week or so ago).

**To Reproduce**
Steps to reproduce the behavior:

1. Open `https://example.com/deck/@Merovius@bookwyrm.social` (replacing `example.com` with your Mastodon instance).

**Expected behavior**

My profile picture being visible.

**Screenshots**

![2024-03-02-222944_229x177_scrot](https://github.com/bookwyrm-social/bookwyrm/assets/720787/4cfc0989-db0f-4899-99e4-0407759c8b38)
![2024-03-02-223001_350x193_scrot](https://github.com/bookwyrm-social/bookwyrm/assets/720787/cf392219-93ec-4f5a-898d-2e6898e6e558)

**Instance**

BookWyrm is `bookwyrm.social`, Mastodon is `chaos.social`.

**Additional context**

It seems to me, that the difference is due to the `type` property of the `icon` property being set to `Document`, instead of `Image`. In particular, comparing my Mastodon profile JSON to my BookWyrm profile JSON:

```
mero@vetinari ~$ curl -s -H 'Accept: application/json' https://bookwyrm.social/user/Merovius | jq .icon                                                                                                                                                                                                                                                                    
{
  "type": "Document",
  "url": "https://bookwyrm-social.sfo3.digitaloceanspaces.com/images/avatars/67757e8e-5083-49e0-837e-370ca6305e8a.jpg",
  "name": "avatar for Merovius",
  "@context": "https://www.w3.org/ns/activitystreams"
}
mero@vetinari ~$ curl -s -H 'Accept: application/json' https://chaos.social/@Merovius | jq .icon     
{
  "type": "Image",
  "mediaType": "image/jpeg",
  "url": "https://assets.chaos.social/accounts/avatars/000/000/299/original/76eb3e858bb58757.jpg"
}
```


Discussion:

Resolving patch:
diff --git a/bookwyrm/activitypub/person.py b/bookwyrm/activitypub/person.py
--- a/bookwyrm/activitypub/person.py
+++ b/bookwyrm/activitypub/person.py
@@ -1,5 +1,5 @@
 """ actor serializer """
-from dataclasses import dataclass, field
+from dataclasses import dataclass
 from typing import Dict
 
 from .base_activity import ActivityObject
@@ -35,7 +35,7 @@ class Person(ActivityObject):
     endpoints: Dict = None
     name: str = None
     summary: str = None
-    icon: Image = field(default_factory=lambda: {})
+    icon: Image = None
     bookwyrmUser: bool = False
     manuallyApprovesFollowers: str = False
     discoverable: str = False
diff --git a/bookwyrm/models/fields.py b/bookwyrm/models/fields.py
--- a/bookwyrm/models/fields.py
+++ b/bookwyrm/models/fields.py
@@ -477,7 +477,7 @@ def field_to_activity(self, value, alt=None):
         if not url:
             return None
 
-        return activitypub.Document(url=url, name=alt)
+        return activitypub.Image(url=url, name=alt)
 
     def field_from_activity(self, value, allow_external_connections=True):
         image_slug = value


Test patch:
diff --git a/bookwyrm/tests/models/test_fields.py b/bookwyrm/tests/models/test_fields.py
--- a/bookwyrm/tests/models/test_fields.py
+++ b/bookwyrm/tests/models/test_fields.py
@@ -436,7 +436,7 @@ def test_image_field_to_activity(self, *_):
             )
         )
         self.assertEqual(output.name, "")
-        self.assertEqual(output.type, "Document")
+        self.assertEqual(output.type, "Image")
 
     @responses.activate
     def test_image_field_from_activity(self, *_):