-
Notifications
You must be signed in to change notification settings - Fork 84
Emoji: First pass at support in Interactions #1129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
|
I think before allowing images in comments, we have to think about/implement a proper blocking and moderation tooling (even more if it is about side-loading images): https://www.theverge.com/2023/7/24/23806093/mastodon-csam-study-decentralized-network |
|
I just pushed an update that moves the replacement into a filter that runs after comment_content and the author have been sanitized. That way, only custom emoji images will be added to the content. |
Would sideloading the image onto the site with
Of course, we'd need to be okay adding potentially a lot of new media to a site once that's enabled. I'm not sure that's okay. |
With custom emoji being shared tags, is that not kind of expected? |
76f5d33 to
47a6493
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
@Jiwoon-Kim I appreciate your input and feedback, but comments and issues of this length are not helpful. They generally lack a specific ask or suggestion and are incredibly hard to read. Going forward, please keep comments/issues concise and actionable, like I asked for previously. |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
I do understand, maybe part of your workflow could be to instruct your LLM to use natural language and distill its response to a sentence or two? |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
51eeb14 to
ffbce79
Compare
Replace multiple database queries with single batched query and fast lookup arrays. This eliminates N+1 query problem where each emoji required separate database calls. Changes: - Single get_posts() query instead of one per emoji - Fast O(1) lookup arrays instead of O(n) loops - Consolidated meta query building into single loop - Removed redundant array collections
Move temp file cleanup inside success block to prevent cleanup attempts when no file was created. This ensures temp files are properly cleaned up only when download_url() succeeds.
Adds a 10 second timeout to the download_url call when downloading emoji files to prevent long-running requests.
- Use get_comment_author filter instead of comment_author for proper timing - Improve emoji detection to check for class="emoji" instead of just "emoji" - Use proper HTML entity decoding with ENT_QUOTES | ENT_HTML5 flags - Add test coverage for emoji in comment author names
Break up large replace_custom_emoji method into focused single-responsibility methods: - extract_emoji_data(): Parse emoji from activity tags - get_emoji_attachments(): Handle database queries and build lookup arrays - get_or_create_emoji_attachment(): Decision logic for reuse vs download - download_emoji(): Handle file download and WordPress attachment creation - replace_emoji_in_text(): Handle text replacement with HTML Improvements: - Better separation of concerns following SRP - Improved documentation with detailed parameter types - Cleaner alt text (removes colons from emoji names) - Simplified fallback logic using consistent emoji URLs
Moved custom emoji processing logic from Interactions to a new Activitypub\Emoji class for better separation of concerns and maintainability. Updated Interactions and related tests to use the new Emoji class.
Instead of storing HTML markup in the comment_author field, now stores the shortcode (e.g., ":emoji:") and replaces it on display. This makes the implementation more future-proof: - If the plugin is disabled, shortcodes display gracefully - Emoji images can be updated dynamically - Database stays clean without HTML markup Implementation: - Store ActivityPub emoji tag data in comment meta - Use get_comment_author filter to replace shortcodes with img tags - Use comment_author filter to selectively unescape only emoji images - Maintain WordPress security by only unescaping known emoji markup
|
Todo:
|
|
It’s possible to display custom emojis from remote instances by extending the Smiley feature. |


Fixes #970.
See https://mastodon.social/@obenland/113788023027390776
See https://obietester.blog/2025/01/06/99/#comment-31
Proposed changes:
Other information:
Testing instructions:
:yikes:,:AngeryCat:, etc.