@@ -123,41 +123,28 @@ public function process_action() {
123
123
return ;
124
124
}
125
125
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 ) {
142
129
/* 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 );
145
132
break ;
146
133
}
147
134
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 ) ) {
150
137
/* 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 );
153
140
break ;
154
141
}
155
142
156
143
$ result = follow ( $ profile , $ this ->user_id );
157
144
if ( \is_wp_error ( $ result ) ) {
158
145
/* translators: %s: Account profile that could not be followed */
159
146
\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 );
161
148
} else {
162
149
\add_settings_error ( 'activitypub ' , 'followed ' , \__ ( 'Account followed. ' , 'activitypub ' ), 'success ' );
163
150
}
0 commit comments