Skip to content

Commit edad4d8

Browse files
committed
add http error codes
1 parent c8634d9 commit edad4d8

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

includes/class-webfinger.php

+32-7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public static function resolve( $uri ) {
4646
return new WP_Error(
4747
'webfinger_missing_links',
4848
__( 'No valid Link elements found.', 'activitypub' ),
49-
$data
49+
array(
50+
'status' => 400,
51+
'data' => $data,
52+
)
5053
);
5154
}
5255

@@ -65,7 +68,10 @@ public static function resolve( $uri ) {
6568
return new WP_Error(
6669
'webfinger_url_no_activitypub',
6770
__( 'The Site supports WebFinger but not ActivityPub', 'activitypub' ),
68-
$data
71+
array(
72+
'status' => 400,
73+
'data' => $data,
74+
)
6975
);
7076
}
7177

@@ -103,7 +109,10 @@ public static function uri_to_acct( $uri ) {
103109
return new WP_Error(
104110
'webfinger_url_no_acct',
105111
__( 'No acct URI found.', 'activitypub' ),
106-
$data
112+
array(
113+
'status' => 400,
114+
'data' => $data,
115+
)
107116
);
108117
}
109118

@@ -144,7 +153,14 @@ public static function get_identifier_and_host( $url ) {
144153
}
145154

146155
if ( empty( $host ) ) {
147-
return new WP_Error( 'webfinger_invalid_identifier', __( 'Invalid Identifier', 'activitypub' ) );
156+
return new WP_Error(
157+
'webfinger_invalid_identifier',
158+
__( 'Invalid Identifier', 'activitypub' ),
159+
array(
160+
'status' => 400,
161+
'data' => $url,
162+
)
163+
);
148164
}
149165

150166
return array( $identifier, $host );
@@ -187,7 +203,10 @@ public static function get_data( $uri ) {
187203
return new WP_Error(
188204
'webfinger_url_not_accessible',
189205
__( 'The WebFinger Resource is not accessible.', 'activitypub' ),
190-
$webfinger_url
206+
array(
207+
'status' => 400,
208+
'data' => $webfinger_url,
209+
)
191210
);
192211
}
193212

@@ -215,7 +234,10 @@ public static function get_remote_follow_endpoint( $uri ) {
215234
return new WP_Error(
216235
'webfinger_missing_links',
217236
__( 'No valid Link elements found.', 'activitypub' ),
218-
$data
237+
array(
238+
'status' => 400,
239+
'data' => $data,
240+
)
219241
);
220242
}
221243

@@ -228,7 +250,10 @@ public static function get_remote_follow_endpoint( $uri ) {
228250
return new WP_Error(
229251
'webfinger_missing_remote_follow_endpoint',
230252
__( 'No valid Remote-Follow endpoint found.', 'activitypub' ),
231-
$data
253+
array(
254+
'status' => 400,
255+
'data' => $data,
256+
)
232257
);
233258
}
234259

0 commit comments

Comments
 (0)