wordpress-activitypub/integration/class-jetpack.php
Matt Wiebe 89a57302c6
Notifications: introduce general class and use it for new follows (#761)
* Notifications: introduce general class and use it for new follows

Also send stuff via Jetpack

---------

Co-authored-by: Matthias Pfefferle <pfefferle@users.noreply.github.com>
2024-05-16 16:03:03 -05:00

24 lines
591 B
PHP

<?php
namespace Activitypub\Integration;
class Jetpack {
public static function init() {
\add_action( 'activitypub_notification', [ self::class, 'send' ] );
}
public static function send( $notification ) {
\Automattic\Jetpack\Connection\Client::wpcom_json_api_request_as_user(
sprintf( '/sites/%d/activitypub/notify', \Jetpack_Options::get_option( 'id' ) ),
'2',
[ 'method' => 'POST' ],
[
'actor' => $notification->actor,
'object' => $notification->object,
'target' => $notification->target,
'type' => $notification->type,
],
'wpcom'
);
}
}