summaryrefslogtreecommitdiffstats
path: root/users
diff options
context:
space:
mode:
Diffstat (limited to 'users')
-rw-r--r--users/models/identity.py38
-rw-r--r--users/views/admin/settings.py5
2 files changed, 40 insertions, 3 deletions
diff --git a/users/models/identity.py b/users/models/identity.py
index 1239ca1..7898b4a 100644
--- a/users/models/identity.py
+++ b/users/models/identity.py
@@ -169,16 +169,20 @@ class Identity(StatorModel):
@property
def safe_summary(self):
- return sanitize_post(self.summary)
+ from activities.templatetags.emoji_tags import imageify_emojis
+
+ return imageify_emojis(sanitize_post(self.summary), self.domain)
@property
def safe_metadata(self):
+ from activities.templatetags.emoji_tags import imageify_emojis
+
if not self.metadata:
return []
return [
{
"name": data["name"],
- "value": strip_html(data["value"]),
+ "value": imageify_emojis(strip_html(data["value"]), self.domain),
}
for data in self.metadata
]
@@ -240,6 +244,15 @@ class Identity(StatorModel):
def name_or_handle(self):
return self.name or self.handle
+ @cached_property
+ def html_name_or_handle(self):
+ """
+ Return the name_or_handle with any HTML substitutions made
+ """
+ from activities.templatetags.emoji_tags import imageify_emojis
+
+ return imageify_emojis(self.name_or_handle, self.domain)
+
@property
def handle(self):
if self.username is None:
@@ -303,6 +316,17 @@ class Identity(StatorModel):
}
return response
+ def to_ap_tag(self):
+ """
+ Return this Identity as an ActivityPub Tag
+ http://joinmastodon.org/ns#Mention
+ """
+ return {
+ "href": self.actor_uri,
+ "name": "@" + self.handle,
+ "type": "Mention",
+ }
+
### ActivityPub (inbound) ###
@classmethod
@@ -470,7 +494,15 @@ class Identity(StatorModel):
### Mastodon Client API ###
def to_mastodon_json(self):
+ from activities.models import Emoji
+
header_image = self.local_image_url()
+ metadata_value_text = (
+ " ".join([m["value"] for m in self.metadata]) if self.metadata else ""
+ )
+ emojis = Emoji.emojis_from_content(
+ f"{self.name} {self.summary} {metadata_value_text}", self.domain
+ )
return {
"id": self.pk,
"username": self.username,
@@ -491,7 +523,7 @@ class Identity(StatorModel):
if self.metadata
else []
),
- "emojis": [],
+ "emojis": [emoji.to_mastodon_json() for emoji in emojis],
"bot": False,
"group": False,
"discoverable": self.discoverable,
diff --git a/users/views/admin/settings.py b/users/views/admin/settings.py
index a4e0190..b9e2543 100644
--- a/users/views/admin/settings.py
+++ b/users/views/admin/settings.py
@@ -85,6 +85,10 @@ class BasicSettings(AdminSettingsPage):
"title": "Unreviewed Hashtags Are Public",
"help_text": "Public Hashtags may appear in Trending and have a Tags timeline",
},
+ "emoji_unreviewed_are_public": {
+ "title": "Unreviewed Emoji Are Public",
+ "help_text": "Public Emoji may appear as images, instead of shortcodes",
+ },
}
layout = {
@@ -100,6 +104,7 @@ class BasicSettings(AdminSettingsPage):
"post_length",
"content_warning_text",
"hashtag_unreviewed_are_public",
+ "emoji_unreviewed_are_public",
],
"Identities": [
"identity_max_per_user",