mirror of
https://github.com/friendica/friendica
synced 2025-04-22 08:30:10 +00:00
Add POST follow request Mastodon API endpoint
This commit is contained in:
parent
1625330e70
commit
2d47952921
3 changed files with 44 additions and 4 deletions
|
@ -7,6 +7,7 @@ use Friendica\App\BaseURL;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Introduction;
|
||||
use Friendica\Module\Base\Api;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
|
@ -24,6 +25,37 @@ class FollowRequests extends Api
|
|||
}
|
||||
}
|
||||
|
||||
public static function post(array $parameters = [])
|
||||
{
|
||||
parent::post($parameters);
|
||||
|
||||
/** @var Introduction $Intro */
|
||||
$Intro = self::getClass(Introduction::class);
|
||||
$Intro->fetch(['id' => $parameters['id'], 'uid' => self::$current_user_id]);
|
||||
|
||||
$contactId = $Intro->{'contact-id'};
|
||||
|
||||
$relationship = new Mastodon\Relationship();
|
||||
$relationship->id = $contactId;
|
||||
|
||||
switch ($parameters['action']) {
|
||||
case 'authorize':
|
||||
$Intro->confirm();
|
||||
$relationship = Mastodon\Relationship::createFromContact(Contact::getById($contactId));
|
||||
break;
|
||||
case 'ignore':
|
||||
$Intro->ignore();
|
||||
break;
|
||||
case 'reject':
|
||||
$Intro->discard();
|
||||
break;
|
||||
default:
|
||||
throw new HTTPException\BadRequestException('Unexpected action parameter, expecting "authorize", "ignore" or "reject"');
|
||||
}
|
||||
|
||||
System::jsonExit($relationship);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $parameters
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue