Skip to content

Conversation

pfefferle
Copy link
Member

@pfefferle pfefferle commented Oct 9, 2025

Implements email notifications when a user's post is quoted, including user and blog-level settings, email template, and tests. Updates admin and settings UI to allow enabling/disabling quote notifications. Adds comprehensive PHPUnit tests for the new notification logic.

Screenshot 2025-10-09 at 12 32 44

Proposed changes:

  • Adds email notification functionality for quote events with user and blog-level settings
  • Creates a new email template specifically for quote notifications
  • Implements comprehensive PHPUnit test coverage for the notification logic

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Checkout on a test site
  • Quote a blog-post with a mastodon user
  • Check Mail

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Added email notifications for quoted posts, with user and blog-level settings and a new customizable email template.

Implements email notifications when a user's post is quoted, including user and blog-level settings, email template, and tests. Updates admin and settings UI to allow enabling/disabling quote notifications. Adds comprehensive PHPUnit tests for the new notification logic.
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements email notifications when a user's post is quoted on the Fediverse. The feature adds comprehensive notification settings for both individual users and blog-level configurations, along with a dedicated email template and extensive test coverage.

  • Adds email notification functionality for quote events with user and blog-level settings
  • Creates a new email template specifically for quote notifications
  • Implements comprehensive PHPUnit test coverage for the notification logic

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
includes/class-mailer.php Adds new quote() method for handling quote notification emails with proper user preference checks
templates/emails/new-quote.php New email template for quote notifications with embedded content display
includes/wp-admin/class-user-settings-fields.php Adds quote notification checkbox to user settings interface
includes/wp-admin/class-blog-settings-fields.php Adds quote notification checkbox to blog settings interface
includes/wp-admin/class-settings.php Registers new blog-level quote notification setting
includes/wp-admin/class-admin.php Includes quote notification setting in user options processing
includes/class-activitypub.php Registers quote notification user meta field with proper defaults
tests/phpunit/tests/includes/class-test-mailer.php Comprehensive test coverage for quote notification functionality
tests/phpunit/tests/includes/handler/class-test-quote-request.php Adds preferredUsername field to test actor data

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

pfefferle and others added 2 commits October 9, 2025 11:13
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@pfefferle pfefferle marked this pull request as ready for review October 9, 2025 09:13
@pfefferle pfefferle requested a review from obenland October 9, 2025 09:25
Replaces a line comment with a PHPDoc-style comment for the 'mention' action hook to improve code documentation consistency.
Replaces all @Covers ::quoted annotations with @Covers ::quote in class-test-mailer.php to accurately reflect the method being tested.
pfefferle and others added 5 commits October 9, 2025 15:42
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Updated block comments for clarity and consistency in the mailer class. Simplified the quote URL assignment by using null coalescing, improving code readability.
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
Co-authored-by: Konstantin Obenland <obenland@gmx.de>
@pfefferle pfefferle requested a review from obenland October 9, 2025 15:19
Simplified the wording in the notification email when a post is quoted on the Fediverse. The message is now more direct and concise.
Adds a check to return early if $quoted_url is not set, avoiding further processing and potential errors when quoteUrl is missing in the activity object.
@obenland obenland force-pushed the add/quote-notification branch from 10c9c14 to 0b8fd5e Compare October 10, 2025 20:29
@obenland
Copy link
Member

obenland commented Oct 10, 2025

A couple more thoughts on this:

  • A quote post represents a reblog at the same time, triggering email notifications for the new "comment". We should either not send the reblog notification or… figure something else out that doesn't result in two emails for the same action. (Including Dotcom)
  • The quote-url-only case, where there is no object to embed is still a mystery to me. In that case we don't seem to link to the quoting post either, just display the URL of the post that was quoted? Do we not have the URL of the quote post? (if we do, we should fetch it and embed it 🙂)

- Fetch remote quote object when only URL is available
- Support both 'quote' (FEP-044f) and 'quoteUrl' properties
- Simplify email template to use pre-prepared variables
- Add direct link to quoted post for better user experience
- Improve plaintext alternative message formatting
- Use activitypub_pre_http_get_remote_object filter for mocking
- Template expects quote_object to always be an array from mailer
- All 1116 tests pass successfully
@obenland
Copy link
Member

obenland commented Oct 14, 2025

Mailer::quote() and the quote template should be ready now. I think it's reasonable to expect that we'll always have a post to embed, similar to DM and Mention emails.

The two remaining items of uncertainty for me:

  • We have tests for create activities triggering Quote email notifications and account for Notes with quoteurl properties, but we're not currently wired in to trigger quote email notifications on Create. What should be done there?
  • A quote post represents a reblog at the same time, triggering email notifications for the new "comment". We should either not send the reblog notification or… figure something else out that doesn't result in two emails for the same action. (Including Dotcom)

@pfefferle
Copy link
Member Author

pfefferle commented Oct 15, 2025

@obenland Mastodon does not send an Announce in the case of a Quote, so there is no duplication.

Screenshot 2025-10-15 at 10 58 11

@pfefferle
Copy link
Member Author

We could add Quotes as Comments though. This way we could re-use (update) the comment Mails.

@obenland
Copy link
Member

Mastodon does not send an Announce in the case of a Quote, so there is no duplication.

You don't get reblog comment notifications in your testing?

image

@pfefferle
Copy link
Member Author

No, not even live!

@pfefferle
Copy link
Member Author

@obenland have you clicked repost and quote?

@pfefferle
Copy link
Member Author

pfefferle commented Oct 15, 2025

(because you can do both actions on the same item)

@obenland
Copy link
Member

Not that I know of. It gives me two options and I clicked quote.

@obenland
Copy link
Member

We could add Quotes as Comments though. This way we could re-use (update) the comment Mails.

Yeah not sure I have an opinion on that, tbh, I'd just go with your preference on this.

@pfefferle
Copy link
Member Author

@obenland can you try to reproduce if you receive two mails or not? I tried it several times and can not reproduce it.

@obenland
Copy link
Member

Interesting, I can't reproduce it anymore, no. Checking that off the list.

@obenland
Copy link
Member

We have tests for create activities triggering Quote email notifications and account for Notes with quoteurl properties, but we're not currently wired in to trigger quote email notifications on Create.

What should we do with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants