Skip to content

Delete interface-notification.php and make the repository interface user-scoped #612

Closed

Description

@jonathanbossenger

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.php and type the repository against Model\*.
  • 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_latest and Abstract_Notification_Repository, adding $user_id.
  • Supported $args for find_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Scope] Database / PersistenceIssue related to storing data. To WP database or another location.has-prThe issue has a linked PRphpPull requests that update Php code

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions