mirror of
https://github.com/Automattic/wordpress-activitypub
synced 2024-10-18 12:23:32 +00:00
ef666772ec
* PHPCS: Include all files by default * simplify menu highlighting * Update includes/transformer/class-factory.php Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com> --------- Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>
66 lines
1 KiB
PHP
66 lines
1 KiB
PHP
<?php
|
|
/**
|
|
* Notification file.
|
|
*
|
|
* @package Activitypub
|
|
*/
|
|
|
|
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.
|
|
*
|
|
* @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.
|
|
*/
|
|
public function __construct( $type, $actor, $activity, $target ) {
|
|
$this->type = $type;
|
|
$this->actor = $actor;
|
|
$this->object = $activity;
|
|
$this->target = $target;
|
|
}
|
|
|
|
/**
|
|
* Send the notification.
|
|
*/
|
|
public function send() {
|
|
$type = \strtolower( $this->type );
|
|
|
|
do_action( 'activitypub_notification', $this );
|
|
do_action( "activitypub_notification_{$type}", $this );
|
|
}
|
|
}
|