Inbox proper response code for follow request

This commit is contained in:
Diogo Cordeiro 2018-07-31 20:55:24 +01:00
parent 933a228072
commit b7ac51a967
2 changed files with 3 additions and 2 deletions

View File

@ -871,8 +871,9 @@ class ActivityPubReturn
* @param array $res
* @return void
*/
public static function answer($res)
public static function answer($res, $code = 200)
{
http_response_code($code);
header('Content-Type: application/activity+json');
echo json_encode($res, JSON_UNESCAPED_SLASHES | (isset($_GET["pretty"]) ? JSON_PRETTY_PRINT : null));
exit;

View File

@ -45,7 +45,7 @@ try {
try {
if (!Subscription::exists($actor_profile, $object_profile)) {
Subscription::start($actor_profile, $object_profile);
ActivityPubReturn::answer(Activitypub_accept::accept_to_array(Activitypub_follow::follow_to_array($data->actor, $data->object)));
ActivityPubReturn::answer(Activitypub_accept::accept_to_array(Activitypub_follow::follow_to_array($data->actor, $data->object)), 202);
} else {
ActivityPubReturn::error("Already following.", 409);
}