2024-06-27 12:10:38 +00:00
|
|
|
<?php
|
2024-10-09 12:44:17 +00:00
|
|
|
/**
|
|
|
|
* Notification file.
|
|
|
|
*
|
|
|
|
* @package Activitypub
|
|
|
|
*/
|
2024-06-27 12:10:38 +00:00
|
|
|
|
|
|
|
namespace Activitypub;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification class.
|
|
|
|
*/
|
|
|
|
class Notification {
|
|
|
|
/**
|
|
|
|
* The type of the notification.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The actor URL.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $actor;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Activity object.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $object;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The WordPress User-Id.
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
public $target;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Notification constructor.
|
|
|
|
*
|
2024-10-09 12:44:17 +00:00
|
|
|
* @param string $type The type of the notification.
|
|
|
|
* @param string $actor The actor URL.
|
|
|
|
* @param array $activity The Activity object.
|
|
|
|
* @param int $target The WordPress User-Id.
|
2024-06-27 12:10:38 +00:00
|
|
|
*/
|
2024-10-09 12:44:17 +00:00
|
|
|
public function __construct( $type, $actor, $activity, $target ) {
|
|
|
|
$this->type = $type;
|
|
|
|
$this->actor = $actor;
|
|
|
|
$this->object = $activity;
|
2024-06-27 12:10:38 +00:00
|
|
|
$this->target = $target;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send the notification.
|
|
|
|
*/
|
|
|
|
public function send() {
|
2024-10-09 12:44:17 +00:00
|
|
|
$type = \strtolower( $this->type );
|
|
|
|
|
2024-06-27 12:10:38 +00:00
|
|
|
do_action( 'activitypub_notification', $this );
|
2024-10-09 12:44:17 +00:00
|
|
|
do_action( "activitypub_notification_{$type}", $this );
|
2024-06-27 12:10:38 +00:00
|
|
|
}
|
|
|
|
}
|