﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	focuses
65639	Comments: Notify mentioned users and thread followers for Notes @mentions	adamsilverstein		"Split out of #65622, which now covers only the kses allowance that lets note @mention markup survive sanitization. This ticket covers the '''notification layer''' for Notes @mentions.

When a collaborator is @mentioned in a note, or is following a note thread, they should be emailed so they hear about it. The Gutenberg Notes @mention completer stores each mention as a link carrying a `user-N` class token, e.g. `<a class=""wp-note-mention user-5"" href=""…"">@Name</a>`.

'''Proposed behavior'''

On `rest_insert_comment` for `note` comments (alongside the existing post-author notification), a new `wp_notify_note_mentions()`:

1. '''Parses mentions''' out of the saved content via `wp_get_note_mentioned_user_ids()`. Only anchors carrying both the `wp-note-mention` class and a `user-N` class token are treated as mentions, so ordinary links cannot be used to address notifications.
2. '''Notifies''' each mentioned user plus any existing followers of the thread with a short email linking back to the post (`wp_send_note_notification()`).
3. '''Subscribes''' the note author and everyone they mention to the thread. Followers are stored as one `_wp_note_followers` meta row per user on the thread's top-level note, so concurrent replies cannot clobber each other, and the meta is registered for REST (editable by users who can `edit_comment` the note) so a follower-management UI can build on it.

'''Audience rules'''

 * The post author is excluded; `wp_new_comment_via_rest_notify_postauthor()` already notifies them of every note.
 * The note's own author is never notified about their own note.
 * Recipients are limited to users who can `edit_comment` the note, matching `WP_REST_Comments_Controller::check_read_permission()` for notes, so emails cannot leak note content to users who cannot see the note in the editor.
 * Everything honors the existing `wp_notes_notify` option.

New filters: `wp_note_notification_recipients`, `wp_note_notification_subject`, `wp_note_notification_text`.

'''Patch'''

Pull request: https://github.com/WordPress/wordpress-develop/pull/12548

Ports the notification layer from Gutenberg PR https://github.com/WordPress/gutenberg/pull/79606 (still open upstream; this should not land until it merges). The kses half is in #65622 / https://github.com/WordPress/wordpress-develop/pull/12503.

=== Related ===

 * #65622 - Notes @mention kses allowance (the other half of this work)
 * Gutenberg #79606 - upstream source PR (open)
 * Gutenberg #79604, #80221 - upstream kses PRs (merged)
"	defect (bug)	new	normal	Awaiting Review	Comments		normal		has-patch has-unit-tests		
