| 1 |
<?php |
| 2 |
/** |
| 3 |
* Notification file. |
| 4 |
* |
| 5 |
* @package Activitypub |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Activitypub; |
| 9 |
|
| 10 |
/** |
| 11 |
* Notification class. |
| 12 |
* |
| 13 |
* @deprecated 7.5.0 Use action hooks like 'activitypub_handled_{type}' instead. |
| 14 |
*/ |
| 15 |
class Notification { |
| 16 |
/** |
| 17 |
* The type of the notification. |
| 18 |
* |
| 19 |
* @var string |
| 20 |
*/ |
| 21 |
public $type; |
| 22 |
|
| 23 |
/** |
| 24 |
* The actor URL. |
| 25 |
* |
| 26 |
* @var string |
| 27 |
*/ |
| 28 |
public $actor; |
| 29 |
|
| 30 |
/** |
| 31 |
* The Activity object. |
| 32 |
* |
| 33 |
* @var array |
| 34 |
*/ |
| 35 |
public $object; |
| 36 |
|
| 37 |
/** |
| 38 |
* The WordPress User-Id. |
| 39 |
* |
| 40 |
* @var int |
| 41 |
*/ |
| 42 |
public $target; |
| 43 |
|
| 44 |
/** |
| 45 |
* Notification constructor. |
| 46 |
* |
| 47 |
* @param string $type The type of the notification. |
| 48 |
* @param string $actor The actor URL. |
| 49 |
* @param array $activity The Activity object. |
| 50 |
* @param int $target The WordPress User-Id. |
| 51 |
*/ |
| 52 |
public function __construct( $type, $actor, $activity, $target ) { |
| 53 |
\_deprecated_class( __CLASS__, '7.5.0', 'Use action hooks like "activitypub_handled_{type}" instead.' ); |
| 54 |
|
| 55 |
$this->type = $type; |
| 56 |
$this->actor = $actor; |
| 57 |
$this->object = $activity; |
| 58 |
$this->target = $target; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Send the notification. |
| 63 |
*/ |
| 64 |
public function send() { |
| 65 |
$type = \strtolower( $this->type ); |
| 66 |
|
| 67 |
/** |
| 68 |
* Action to send ActivityPub notifications. |
| 69 |
* |
| 70 |
* @deprecated 7.5.0 Use "activitypub_handled_{$type}" instead. |
| 71 |
* |
| 72 |
* @param Notification $instance The notification object. |
| 73 |
*/ |
| 74 |
\do_action_deprecated( 'activitypub_notification', array( $this ), '7.5.0', "activitypub_handled_{$type}" ); |
| 75 |
|
| 76 |
/** |
| 77 |
* Type-specific action to send ActivityPub notifications. |
| 78 |
* |
| 79 |
* @deprecated 7.5.0 Use "activitypub_handled_{$type}" instead. |
| 80 |
* |
| 81 |
* @param Notification $instance The notification object. |
| 82 |
*/ |
| 83 |
\do_action_deprecated( "activitypub_notification_{$type}", array( $this ), '7.5.0', "activitypub_handled_{$type}" ); |
| 84 |
} |
| 85 |
} |
| 86 |
|