summaryrefslogtreecommitdiffstats
path: root/users/models
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-17 19:31:00 -0700
committerAndrew Godwin2022-11-17 17:55:50 -0700
commit2a3690d1c148da5dd799052403ba7290e1fb7de0 (patch)
tree6a1c92cdbea7ee2e307a99dd114610c83b33f82a /users/models
parent291d7e404e12e1d017403242f8ed199046f0904c (diff)
downloadtakahe-2a3690d1c148da5dd799052403ba7290e1fb7de0.tar.gz
takahe-2a3690d1c148da5dd799052403ba7290e1fb7de0.tar.bz2
takahe-2a3690d1c148da5dd799052403ba7290e1fb7de0.zip
Return images and summary in actor
Diffstat (limited to 'users/models')
-rw-r--r--users/models/identity.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/users/models/identity.py b/users/models/identity.py
index d4ab720..21912ac 100644
--- a/users/models/identity.py
+++ b/users/models/identity.py
@@ -8,10 +8,12 @@ from asgiref.sync import async_to_sync, sync_to_async
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from django.db import models
+from django.template.defaultfilters import linebreaks_filter
from django.templatetags.static import static
from django.utils import timezone
-from core.ld import canonicalise
+from core.html import sanitize_post
+from core.ld import canonicalise, media_type_from_filename
from core.uploads import upload_namer
from stator.models import State, StateField, StateGraph, StatorModel
from users.models.domain import Domain
@@ -139,6 +141,10 @@ class Identity(StatorModel):
elif self.image_uri:
return self.image_uri
+ @property
+ def safe_summary(self):
+ return sanitize_post(self.summary)
+
### Alternate constructors/fetchers ###
@classmethod
@@ -223,7 +229,19 @@ class Identity(StatorModel):
if self.name:
response["name"] = self.name
if self.summary:
- response["summary"] = self.summary
+ response["summary"] = str(linebreaks_filter(self.summary))
+ if self.icon:
+ response["icon"] = {
+ "type": "Image",
+ "mediaType": media_type_from_filename(self.icon.name),
+ "url": self.icon.url,
+ }
+ if self.image:
+ response["image"] = {
+ "type": "Image",
+ "mediaType": media_type_from_filename(self.image.name),
+ "url": self.image.url,
+ }
return response
### ActivityPub (inbound) ###