PluginProbe
ActivityPub / 7.7.0
ActivityPub v7.7.0
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-create.php +6 -32 9.2.07.7.0 View file →
@@ -7,10 +7,9 @@
7 7
8 8 namespace Activitypub\Handler;
9 9
10 10 use Activitypub\Collection\Interactions;
11 -use Activitypub\Collection\Remote_Posts;
12 -use Activitypub\Tombstone;
11 +use Activitypub\Collection\Posts;
13 12
14 13 use function Activitypub\get_activity_visibility;
15 14 use function Activitypub\is_activity_reply;
16 15 use function Activitypub\is_quote_activity;
@@ -26,9 +25,8 @@
26 25 */
27 26 public static function init() {
28 27 \add_action( 'activitypub_handled_inbox_create', array( self::class, 'handle_create' ), 10, 3 );
29 28 \add_filter( 'activitypub_validate_object', array( self::class, 'validate_object' ), 10, 3 );
30 - \add_action( 'post_activitypub_add_to_outbox', array( self::class, 'maybe_unbury' ), 10, 2 );
31 29 }
32 30
33 31 /**
34 32 * Handles "Create" requests.
@@ -42,10 +40,12 @@
42 40 if ( ACTIVITYPUB_CONTENT_VISIBILITY_PRIVATE === get_activity_visibility( $activity ) ) {
43 41 $result = false;
44 42 } elseif ( is_activity_reply( $activity ) || is_quote_activity( $activity ) ) { // Check for replies and quotes.
45 43 $result = self::create_interaction( $activity, $user_ids, $activity_object );
46 - } else { // Handle non-interaction objects.
44 + } elseif ( \get_option( 'activitypub_create_posts', false ) ) { // Handle non-interaction objects.
47 45 $result = self::create_post( $activity, $user_ids, $activity_object );
46 + } else {
47 + $result = false;
48 48 }
49 49
50 50 if ( false === $result ) {
51 51 return;
@@ -105,14 +105,10 @@
105 105 *
106 106 * @return \WP_Post|\WP_Error|false The post on success, WP_Error on failure, false if already exists.
107 107 */
108 108 public static function create_post( $activity, $user_ids, $activity_object = null ) {
109 - if ( ! \get_option( 'activitypub_create_posts', false ) ) {
110 - return false;
111 - }
109 + $existing_post = Posts::get_by_guid( $activity['object']['id'] );
112 110
113 - $existing_post = Remote_Posts::get_by_guid( $activity['object']['id'] );
114 -
115 111 // If post exists, call update action.
116 112 if ( $existing_post instanceof \WP_Post ) {
117 113 Update::handle_update( $activity, (array) $user_ids, $activity_object );
118 114
@@ -118,9 +114,9 @@
118 114
119 115 return false;
120 116 }
121 117
122 - return Remote_Posts::add( $activity, $user_ids );
118 + return Posts::add( $activity, $user_ids );
123 119 }
124 120
125 121 /**
126 122 * Validate the object.
@@ -150,28 +146,6 @@
150 146 return false;
151 147 }
152 148
153 149 return $valid;
154 - }
155 -
156 - /**
157 - * Remove a URL from the tombstone registry when a Create or Update activity is sent.
158 - *
159 - * This handles the case where a post was soft-deleted (visibility changed to local/private)
160 - * and then later changed back to public. The Create/Update activity indicates the post is being
161 - * re-federated, so we remove it from the tombstone registry.
162 - *
163 - * @param int $outbox_id The ID of the outbox activity.
164 - * @param \Activitypub\Activity\Activity $activity The Activity object.
165 - */
166 - public static function maybe_unbury( $outbox_id, $activity ) {
167 - if ( ! \in_array( $activity->get_type(), array( 'Create', 'Update' ), true ) ) {
168 - return;
169 - }
170 -
171 - $object = $activity->get_object();
172 -
173 - if ( $object ) {
174 - Tombstone::remove( $object->get_id(), $object->get_url() );
175 - }
176 150 }
177 151 }