Repository navigation
Description
Part of #302. Prerequisite for #42, #307 and #176.
What problem does this address?
includes/interface-notification.php is never loaded by the bootstrap. It requires get_sender() / get_recipients() returning Sender and Recipient_Collection, types that don't exist anywhere, and nothing implements it. Its recipients-as-a-property shape also contradicts the queue design, where recipients are a fan-out concern.
The notification repository interface takes no user_id anywhere (find_by_id, find_by_date_range, find_latest, add). It can't answer "get the current user's notifications" (the main query the MVP needs) or "is this row mine" (which authorization depends on). add( Notification $n ): int also can't express fanning one message out to many users.
What is your proposed solution?
- Delete
includes/interface-notification.phpand type the repository againstModel\*. - Retarget the repository interface to be user-scoped:
public function find_by_id( int $message_id, int $user_id ): ?array; // array{notification: Model\Notification, message: Model\Message}
public function find_by_user( int $user_id, array $args = array() ): array;
public function count_by_user( int $user_id, array $args = array() ): int; // for X-WP-Total
public function add( Model\Message $m, string $channel_name, array $user_ids, string $context = 'adminbar' ); // int|WP_Error
public function dismiss( int $message_id, int $user_id ): bool;
public function mark_displayed( int $message_id, int $user_id ): bool;
public function remove( int $message_id, int $user_id ): bool;
public function purge_orphans(): int;- Keep
find_by_date_range/find_latestandAbstract_Notification_Repository, adding$user_id. - Supported
$argsforfind_by_user:status,channel_name,context,after(used by polling),before,include_expired(default false),order,orderby,per_page,offset. - REST
{id}is the message ID scoped to the current user, not a surrogate queue ID.
This issue covers the interface only; #42 implements it.
Activity