| @@ -6,12 +6,10 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace Activitypub\Scheduler; |
| 9 | 9 | |
| 10 | -use Activitypub\Activity\Activity; | |
| 11 | 10 | use Activitypub\Collection\Actors; |
| 12 | 11 | use Activitypub\Collection\Extra_Fields; |
| 13 | -use Activitypub\Collection\Outbox; | |
| 14 | 12 | |
| 15 | 13 | use function Activitypub\add_to_outbox; |
| 16 | 14 | use function Activitypub\is_user_type_disabled; |
| 17 | 15 | |
| @@ -48,20 +46,9 @@ | ||
| 48 | 46 | |
| 49 | 47 | \add_action( 'add_option_activitypub_actor_mode', array( self::class, 'blog_user_update' ) ); |
| 50 | 48 | \add_action( 'update_option_activitypub_actor_mode', array( self::class, 'blog_user_update' ) ); |
| 51 | 49 | |
| 52 | - // The Starter Kit policy is part of every actor profile. | |
| 53 | - \add_action( 'add_option_activitypub_default_feature_policy', array( self::class, 'schedule_all_profile_updates' ) ); | |
| 54 | - \add_action( 'update_option_activitypub_default_feature_policy', array( self::class, 'schedule_all_profile_updates' ) ); | |
| 55 | - | |
| 56 | 50 | \add_action( 'transition_post_status', array( self::class, 'schedule_post_activity' ), 33, 3 ); |
| 57 | - | |
| 58 | - \add_action( 'post_stuck', array( self::class, 'sticky_post_update' ) ); | |
| 59 | - \add_action( 'post_unstuck', array( self::class, 'sticky_post_update' ) ); | |
| 60 | - | |
| 61 | - // User deletion handling. | |
| 62 | - \add_action( 'delete_user', array( self::class, 'schedule_user_delete' ), 10, 3 ); | |
| 63 | - \add_filter( 'post_types_to_delete_with_user', array( self::class, 'post_types_to_delete_with_user' ) ); | |
| 64 | 51 | } |
| 65 | 52 | |
| 66 | 53 | /** |
| 67 | 54 | * Send a profile update when relevant user meta is updated. |
| @@ -87,9 +74,9 @@ | ||
| 87 | 74 | 'display_name', |
| 88 | 75 | 'user_url', |
| 89 | 76 | ); |
| 90 | 77 | |
| 91 | - if ( \in_array( $meta_key, $fields, true ) ) { | |
| 78 | + if ( in_array( $meta_key, $fields, true ) ) { | |
| 92 | 79 | self::schedule_profile_update( $user_id ); |
| 93 | 80 | } |
| 94 | 81 | } |
| 95 | 82 | |
| @@ -136,29 +123,14 @@ | ||
| 136 | 123 | } |
| 137 | 124 | } |
| 138 | 125 | |
| 139 | 126 | /** |
| 140 | - * Send profile updates for all local actors. | |
| 141 | - * | |
| 142 | - * Used when a site-wide setting that is part of every actor profile | |
| 143 | - * changes, like the Starter Kit policy (FEP-7aa9 `canFeature`), so | |
| 144 | - * followers of the blog actor and of every author receive the change. | |
| 145 | - * | |
| 146 | - * @since 9.0.1 | |
| 147 | - */ | |
| 148 | - public static function schedule_all_profile_updates() { | |
| 149 | - foreach ( Actors::get_all_ids() as $user_id ) { | |
| 150 | - self::schedule_profile_update( $user_id ); | |
| 151 | - } | |
| 152 | - } | |
| 153 | - | |
| 154 | - /** | |
| 155 | 127 | * Send a profile update to all followers. Gets hooked into all relevant options/meta etc. |
| 156 | 128 | * |
| 157 | 129 | * @param int $user_id The user ID to update (Could be 0 for Blog-User). |
| 158 | 130 | */ |
| 159 | 131 | public static function schedule_profile_update( $user_id ) { |
| 160 | - if ( \defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { | |
| 132 | + if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { | |
| 161 | 133 | return; |
| 162 | 134 | } |
| 163 | 135 | |
| 164 | 136 | $actor = Actors::get_by_id( $user_id ); |
| @@ -166,58 +138,9 @@ | ||
| 166 | 138 | if ( ! $actor || \is_wp_error( $actor ) ) { |
| 167 | 139 | return; |
| 168 | 140 | } |
| 169 | 141 | |
| 170 | - $actor->set_updated( \gmdate( ACTIVITYPUB_DATE_TIME_RFC3339, \time() ) ); | |
| 142 | + $actor->set_updated( gmdate( ACTIVITYPUB_DATE_TIME_RFC3339, time() ) ); | |
| 171 | 143 | |
| 172 | 144 | add_to_outbox( $actor, 'Update', $user_id ); |
| 173 | - } | |
| 174 | - | |
| 175 | - /** | |
| 176 | - * Send a profile update when a post's sticky status changes. | |
| 177 | - * | |
| 178 | - * @param int $post_id The post ID. | |
| 179 | - */ | |
| 180 | - public static function sticky_post_update( $post_id ) { | |
| 181 | - $post = \get_post( $post_id ); | |
| 182 | - | |
| 183 | - if ( ! $post ) { | |
| 184 | - return; | |
| 185 | - } | |
| 186 | - | |
| 187 | - self::schedule_profile_update( $post->post_author ); | |
| 188 | - } | |
| 189 | - | |
| 190 | - /** | |
| 191 | - * Schedule a Delete activity when a user is deleted. | |
| 192 | - * | |
| 193 | - * @param int $user_id The user ID being deleted. | |
| 194 | - */ | |
| 195 | - public static function schedule_user_delete( $user_id ) { | |
| 196 | - // Get the actor before deletion to ensure we have the data. | |
| 197 | - $actor = Actors::get_by_id( $user_id ); | |
| 198 | - if ( \is_wp_error( $actor ) ) { | |
| 199 | - return; | |
| 200 | - } | |
| 201 | - | |
| 202 | - $activity = new Activity(); | |
| 203 | - $activity->set_actor( $actor->get_id() ); | |
| 204 | - $activity->set_object( $actor->get_id() ); | |
| 205 | - $activity->set_type( 'Delete' ); | |
| 206 | - | |
| 207 | - add_to_outbox( $activity, null, $user_id ); | |
| 208 | - } | |
| 209 | - | |
| 210 | - /** | |
| 211 | - * Remove outbox from post types to delete with user. | |
| 212 | - * | |
| 213 | - * Outbox items should not be deleted with the user, because we | |
| 214 | - * need to federate the `Delete` Activities. | |
| 215 | - * | |
| 216 | - * @param array $post_types The post types to delete with user. | |
| 217 | - * | |
| 218 | - * @return array The post types to delete with user without outbox. | |
| 219 | - */ | |
| 220 | - public static function post_types_to_delete_with_user( $post_types ) { | |
| 221 | - return \array_diff( $post_types, array( Outbox::POST_TYPE ) ); | |
| 222 | 145 | } |
| 223 | 146 | } |