@@ -123,41 +123,28 @@ public function process_action() {
123123 return ;
124124 }
125125
126- $ profile = \sanitize_text_field ( \wp_unslash ( $ _REQUEST ['activitypub-profile ' ] ) );
127- $ profile = \trim ( $ profile , '@ ' );
128-
129- if ( \filter_var ( $ profile , FILTER_VALIDATE_EMAIL ) ) {
130- $ remote_actor = Webfinger::resolve ( $ profile );
131- if ( ! \is_wp_error ( $ remote_actor ) ) {
132- $ original = $ profile ;
133- $ profile = object_to_uri ( $ remote_actor );
134- }
135- } elseif ( empty ( \wp_parse_url ( $ profile , PHP_URL_SCHEME ) ) ) {
136- // Add scheme if missing.
137- $ profile = \esc_url_raw ( 'https:// ' . \ltrim ( $ profile , '/ ' ) );
138- }
139-
140- // Check if user has blocked the account.
141- if ( \in_array ( $ profile , Moderation::get_user_blocks ( $ this ->user_id )['actors ' ], true ) ) {
126+ $ original = \sanitize_text_field ( \wp_unslash ( $ _REQUEST ['activitypub-profile ' ] ) );
127+ $ profile = Actors::normalize_identifier ( $ original );
128+ if ( ! $ profile ) {
142129 /* translators: %s: Account profile that could not be followed */
143- \add_settings_error ( 'activitypub ' , 'followed ' , \sprintf ( \__ ( 'Unable to follow account “%s”. The account is blocked . ' , 'activitypub ' ), \esc_html ( $ profile ) ) );
144- $ redirect_to = \add_query_arg ( 'resource ' , $ original ?? $ profile , $ redirect_to );
130+ \add_settings_error ( 'activitypub ' , 'followed ' , \sprintf ( \__ ( 'Unable to follow account “%s”. Please verify the account exists and try again . ' , 'activitypub ' ), \esc_html ( $ profile ) ) );
131+ $ redirect_to = \add_query_arg ( 'resource ' , $ original , $ redirect_to );
145132 break ;
146133 }
147134
148- // Check if site has blocked the account .
149- if ( \in_array ( $ profile , Moderation:: get_site_blocks ()[ ' actors ' ], true ) ) {
135+ // Check if actor is blocked.
136+ if ( Moderation:: is_actor_blocked ( $ profile , $ this -> user_id ) ) {
150137 /* translators: %s: Account profile that could not be followed */
151- \add_settings_error ( 'activitypub ' , 'followed ' , \sprintf ( \__ ( 'Unable to follow account “%s”. The account is blocked site-wide . ' , 'activitypub ' ), \esc_html ( $ profile ) ) );
152- $ redirect_to = \add_query_arg ( 'resource ' , $ original ?? $ profile , $ redirect_to );
138+ \add_settings_error ( 'activitypub ' , 'followed ' , \sprintf ( \__ ( 'Unable to follow account “%s”. The account is blocked. ' , 'activitypub ' ), \esc_html ( $ profile ) ) );
139+ $ redirect_to = \add_query_arg ( 'resource ' , $ original , $ redirect_to );
153140 break ;
154141 }
155142
156143 $ result = follow ( $ profile , $ this ->user_id );
157144 if ( \is_wp_error ( $ result ) ) {
158145 /* translators: %s: Account profile that could not be followed */
159146 \add_settings_error ( 'activitypub ' , 'followed ' , \sprintf ( \__ ( 'Unable to follow account “%s”. Please verify the account exists and try again. ' , 'activitypub ' ), \esc_html ( $ profile ) ) );
160- $ redirect_to = \add_query_arg ( 'resource ' , $ original ?? $ profile , $ redirect_to );
147+ $ redirect_to = \add_query_arg ( 'resource ' , $ original , $ redirect_to );
161148 } else {
162149 \add_settings_error ( 'activitypub ' , 'followed ' , \__ ( 'Account followed. ' , 'activitypub ' ), 'success ' );
163150 }
0 commit comments