PluginProbe
ActivityPub / 8.0.2
ActivityPub v8.0.2
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/handler/class-move.php +21 -14 8.3.08.0.2 View file →
@@ -25,8 +25,9 @@
25 25 * Initialize the class, registering WordPress hooks.
26 26 */
27 27 public static function init() {
28 28 \add_action( 'activitypub_inbox_move', array( self::class, 'handle_move' ), 10, 2 );
29 + \add_filter( 'activitypub_get_outbox_activity', array( self::class, 'outbox_activity' ) );
29 30 }
30 31
31 32 /**
32 33 * Handle Move requests.
@@ -100,8 +101,24 @@
100 101 \do_action( 'activitypub_handled_move', $activity, (array) $user_ids, $success, $result );
101 102 }
102 103
103 104 /**
105 + * Convert the object and origin to the correct format.
106 + *
107 + * @param \Activitypub\Activity\Activity $activity The Activity object.
108 + * @return \Activitypub\Activity\Activity The filtered Activity object.
109 + */
110 + public static function outbox_activity( $activity ) {
111 + if ( 'Move' === $activity->get_type() ) {
112 + $activity->set_object( object_to_uri( $activity->get_object() ) );
113 + $activity->set_origin( $activity->get_actor() );
114 + $activity->set_target( $activity->get_object() );
115 + }
116 +
117 + return $activity;
118 + }
119 +
120 + /**
104 121 * Extract the target from the activity.
105 122 *
106 123 * The ActivityStreams spec define the `target` attribute as the
107 124 * destination of the activity, but Mastodon uses the `object`
@@ -169,25 +186,15 @@
169 186 if ( $target_object['id'] === $origin_object['id'] ) {
170 187 return false;
171 188 }
172 189
173 - // Normalize alsoKnownAs to an array (some JSON-LD payloads may use a string).
174 - $also_known_as = (array) ( $target_object['alsoKnownAs'] ?? array() );
175 - if ( empty( $also_known_as ) ) {
190 + // Check if the target has an alsoKnownAs property.
191 + if ( empty( $target_object['also_known_as'] ) ) {
176 192 return false;
177 193 }
178 194
179 - // Collect all possible origin identifiers (id, url, webfinger).
180 - $origin_ids = array_filter(
181 - array(
182 - $origin_object['id'] ?? null,
183 - $origin_object['url'] ?? null,
184 - $origin_object['webfinger'] ?? null,
185 - )
186 - );
187 -
188 - // Check if any origin identifier is in the alsoKnownAs property of the target.
189 - if ( ! array_intersect( $origin_ids, $also_known_as ) ) {
195 + // Check if the origin is in the alsoKnownAs property of the target.
196 + if ( ! in_array( $origin_object['id'], $target_object['also_known_as'], true ) ) {
190 197 return false;
191 198 }
192 199
193 200 // Check if the origin has a movedTo property.