Skip to content

Commit 3b2f229

Browse files
authored
Following: Improve follow error handling (#1978)
1 parent 2ab439f commit 3b2f229

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

includes/table/class-following.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function process_action() {
111111
}
112112
break;
113113
case 'follow':
114-
$redirect_to = \remove_query_arg( array( 's' ), $redirect_to );
114+
$redirect_to = \remove_query_arg( array( 'resource', 's' ), $redirect_to );
115115

116116
if ( ! isset( $_REQUEST['activitypub-profile'], $_REQUEST['_wpnonce'] ) ) {
117117
return;
@@ -125,7 +125,9 @@ public function process_action() {
125125
$profile = \sanitize_text_field( \wp_unslash( $_REQUEST['activitypub-profile'] ) );
126126
$result = follow( $profile, $this->user_id );
127127
if ( \is_wp_error( $result ) ) {
128-
\add_settings_error( 'activitypub', 'followed', $result->get_error_message() );
128+
/* translators: %s: Account profile that could not be followed */
129+
\add_settings_error( 'activitypub', 'followed', \sprintf( \__( 'Unable to follow account “%s”. Please verify the account exists and try again.', 'activitypub' ), \esc_html( $profile ) ) );
130+
$redirect_to = \add_query_arg( 'resource', $profile, $redirect_to );
129131
} else {
130132
\add_settings_error( 'activitypub', 'followed', \__( 'Account followed.', 'activitypub' ), 'success' );
131133
}

templates/following-list.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
<li><p><?php echo wp_kses_post( __( 'Profile link: <code>https://example.com/@username</code>', 'activitypub' ) ); ?></p></li>
6464
</ul>
6565

66-
<p><?php echo esc_html__( '(Make sure the user you&rsquo;re following is part of the fediverse and supports ActivityPub)', 'activitypub' ); ?></p>
66+
<p><?php echo esc_html__( '(Make sure the user you&#8217;re following is part of the fediverse and supports ActivityPub)', 'activitypub' ); ?></p>
6767
</div>
6868
</div>
6969
</div>
@@ -78,11 +78,10 @@
7878
</form>
7979
<div class="edit-term-notes">
8080
<strong><?php esc_html_e( 'About Followings', 'activitypub' ); ?></strong>
81-
<p class="description"><?php esc_html_e( 'When you follow another author, a follow request is sent on your behalf. If you see &#8220;Pending,&#8221; it means your follow request hasn&#8217;t been accepted yetso you aren&#8217;t following that author until they approve your request. This is a normal part of the ActivityPub protocol and helps ensure that authors have control over who follows them.', 'activitypub' ); ?></p>
81+
<p class="description"><?php esc_html_e( 'When you follow another author, a follow request is sent on your behalf. If you see &#8220;Pending&#8221;, it means your follow request hasn&#8217;t been accepted yet&#8212;so you aren&#8217;t following that author until they approve your request. This is a normal part of the ActivityPub protocol and helps ensure that authors have control over who follows them.', 'activitypub' ); ?></p>
8282
</div>
8383
</div>
8484
</div>
8585
</div>
8686
</div>
8787
</div>
88-

0 commit comments

Comments
 (0)