use blog actor
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Failing after 49s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Failing after 54s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m18s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m6s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m5s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 1m8s
PHPUnit / PHPUnit – PHP 8.4 (pull_request) Successful in 1m10s

This commit is contained in:
André Menrath 2024-12-15 13:42:57 +01:00
parent 37043e7a7b
commit cd451131fa
8 changed files with 36 additions and 17 deletions

View file

@ -374,7 +374,7 @@ class Event_Sources {
$activity->set_object( $to ); $activity->set_object( $to );
$activity->set_id( $application->get_id() . '#follow-' . \preg_replace( '~^https?://~', '', $to ) ); $activity->set_id( $application->get_id() . '#follow-' . \preg_replace( '~^https?://~', '', $to ) );
$activity = $activity->to_json(); $activity = $activity->to_json();
\Activitypub\safe_remote_post( $inbox, $activity, \Activitypub\Collection\Actors::APPLICATION_USER_ID ); \Activitypub\safe_remote_post( $inbox, $activity, \Activitypub\Collection\Actors::BLOG_USER_ID );
} }
/** /**
@ -436,7 +436,7 @@ class Event_Sources {
); );
$activity->set_id( $actor . '#unfollow-' . \preg_replace( '~^https?://~', '', $to ) ); $activity->set_id( $actor . '#unfollow-' . \preg_replace( '~^https?://~', '', $to ) );
$activity = $activity->to_json(); $activity = $activity->to_json();
\Activitypub\safe_remote_post( $inbox, $activity, \Activitypub\Collection\Actors::APPLICATION_USER_ID ); \Activitypub\safe_remote_post( $inbox, $activity, \Activitypub\Collection\Actors::BLOG_USER_ID );
} }
/** /**

View file

@ -8,7 +8,6 @@
namespace Event_Bridge_For_ActivityPub\ActivityPub\Handler; namespace Event_Bridge_For_ActivityPub\ActivityPub\Handler;
use Activitypub\Notification;
use Activitypub\Collection\Actors; use Activitypub\Collection\Actors;
/** /**
@ -43,7 +42,7 @@ class Accept {
} }
// We only expect `Accept` activities being answers to follow requests by the application actor. // We only expect `Accept` activities being answers to follow requests by the application actor.
if ( Actors::APPLICATION_USER_ID !== $object->get__id() ) { if ( Actors::BLOG_USER_ID !== $object->get__id() ) {
return; return;
} }
} }

View file

@ -45,7 +45,7 @@ class Create {
*/ */
public static function handle_create( $activity, $user_id ) { public static function handle_create( $activity, $user_id ) {
// We only process activities that are target to the application user. // We only process activities that are target to the application user.
if ( Actors::APPLICATION_USER_ID !== $user_id ) { if ( Actors::BLOG_USER_ID !== $user_id ) {
return; return;
} }

View file

@ -34,7 +34,7 @@ class Delete {
*/ */
public static function handle_delete( $activity, $user_id ) { public static function handle_delete( $activity, $user_id ) {
// We only process activities that are target to the application user. // We only process activities that are target to the application user.
if ( Actors::APPLICATION_USER_ID !== $user_id ) { if ( Actors::BLOG_USER_ID !== $user_id ) {
return; return;
} }

View file

@ -7,9 +7,7 @@
namespace Event_Bridge_For_ActivityPub\ActivityPub\Handler; namespace Event_Bridge_For_ActivityPub\ActivityPub\Handler;
use Activitypub\Notification;
use Activitypub\Collection\Actors; use Activitypub\Collection\Actors;
use Activitypub\Http;
use Event_Bridge_For_ActivityPub\Setup; use Event_Bridge_For_ActivityPub\Setup;
use function Activitypub\is_activity_public; use function Activitypub\is_activity_public;
@ -38,7 +36,7 @@ class Update {
*/ */
public static function handle_update( $activity, $user_id ) { public static function handle_update( $activity, $user_id ) {
// We only process activities that are target the application user. // We only process activities that are target the application user.
if ( Actors::APPLICATION_USER_ID !== $user_id ) { if ( Actors::BLOG_USER_ID !== $user_id ) {
return; return;
} }

View file

@ -16,7 +16,6 @@ use DateTime;
use Exception; use Exception;
use WP_Error; use WP_Error;
use function Activitypub\object_to_uri;
use function Activitypub\sanitize_url; use function Activitypub\sanitize_url;
// Exit if accessed directly. // Exit if accessed directly.
@ -406,9 +405,9 @@ class GatherPress {
$venue_information = array(); $venue_information = array();
$address = $this->address_to_string(); $address_string = isset( $location['address'] ) ? $this->address_to_string( $location['address'] ) : '';
$venue_information['fullAddress'] = $address; $venue_information['fullAddress'] = $address_string;
$venue_information['phone_number'] = ''; $venue_information['phone_number'] = '';
$venue_information['website'] = ''; $venue_information['website'] = '';
$venue_information['permalink'] = ''; $venue_information['permalink'] = '';

View file

@ -9,12 +9,9 @@
namespace Event_Bridge_For_ActivityPub; namespace Event_Bridge_For_ActivityPub;
use Activitypub\Activity\Extended_Object\Event; use Activitypub\Model\Blog;
use Activitypub\Collection\Actors;
use Event_Bridge_For_ActivityPub\ActivityPub\Collection\Event_Sources as Event_Sources_Collection; use Event_Bridge_For_ActivityPub\ActivityPub\Collection\Event_Sources as Event_Sources_Collection;
use Event_Bridge_For_ActivityPub\Activitypub\Transformer\GatherPress as TransformerGatherPress;
use Event_Bridge_For_ActivityPub\Activitypub\Transmogrifier\GatherPress; use Event_Bridge_For_ActivityPub\Activitypub\Transmogrifier\GatherPress;
use Event_Bridge_For_ActivityPub\Integrations\GatherPress as IntegrationsGatherPress;
use function Activitypub\get_remote_metadata_by_actor; use function Activitypub\get_remote_metadata_by_actor;
use function Activitypub\is_activitypub_request; use function Activitypub\is_activitypub_request;
@ -159,4 +156,27 @@ class Event_Sources {
wp_delete_post( $post_id, true ); wp_delete_post( $post_id, true );
} }
} }
/**
* Add the Blog Authors to the following list of the Blog Actor
* if Blog not in single mode.
*
* @param array $follow_list The array of following urls.
* @param \Activitypub\Model\User $user The user object.
*
* @return array The array of following urls.
*/
public static function add_event_sources_to_following_collection( $follow_list, $user ) {
if ( ! $user instanceof Blog ) {
return $follow_list;
}
$event_sources = Event_Sources_Collection::get_event_sources_ids();
if ( ! is_array( $event_sources ) ) {
return $follow_list;
}
return array_merge( $follow_list, $event_sources );
}
} }

View file

@ -24,6 +24,8 @@ use Event_Bridge_For_ActivityPub\Admin\Settings_Page;
use Event_Bridge_For_ActivityPub\Admin\User_Interface; use Event_Bridge_For_ActivityPub\Admin\User_Interface;
use Event_Bridge_For_ActivityPub\Integrations\Event_Plugin; use Event_Bridge_For_ActivityPub\Integrations\Event_Plugin;
use function Activitypub\is_user_type_disabled;
require_once ABSPATH . 'wp-admin/includes/plugin.php'; require_once ABSPATH . 'wp-admin/includes/plugin.php';
/** /**
@ -238,7 +240,7 @@ class Setup {
return; return;
} }
if ( get_option( 'event_bridge_for_activitypub_event_sources_active' ) ) { if ( ! is_user_type_disabled( 'blog' ) && get_option( 'event_bridge_for_activitypub_event_sources_active' ) ) {
add_action( 'init', array( Event_Sources_Collection::class, 'init' ) ); add_action( 'init', array( Event_Sources_Collection::class, 'init' ) );
add_action( 'activitypub_register_handlers', array( Handler::class, 'register_handlers' ) ); add_action( 'activitypub_register_handlers', array( Handler::class, 'register_handlers' ) );
add_action( 'admin_init', array( User_Interface::class, 'init' ) ); add_action( 'admin_init', array( User_Interface::class, 'init' ) );
@ -249,6 +251,7 @@ class Setup {
} }
add_action( 'event_bridge_for_activitypub_event_sources_clear_cache', array( Event_Sources::class, 'clear_cache' ) ); add_action( 'event_bridge_for_activitypub_event_sources_clear_cache', array( Event_Sources::class, 'clear_cache' ) );
add_filter( 'activitypub_rest_following', array( Event_Sources::class, 'add_event_sources_to_following_collection' ), 10, 2 );
add_filter( add_filter(
'gatherpress_force_online_event_link', 'gatherpress_force_online_event_link',
function ( $force_online_event_link ) { function ( $force_online_event_link ) {