+ * @throws HTTPException\NotFoundException
+ * @throws HTTPException\UnauthorizedException
+ * @throws \ImagickException
+ *
+ * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#accept-follow
+ * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#reject-follow
+ */
+ public static function post(array $parameters = [])
+ {
+ parent::post($parameters);
+
+ $introduction = DI::intro()->selectFirst(['id' => $parameters['id'], 'uid' => self::$current_user_id]);
+
+ $contactId = $introduction->{'contact-id'};
+
+ switch ($parameters['action']) {
+ case 'authorize':
+ $introduction->confirm();
+
+ $relationship = DI::mstdnRelationship()->createFromContactId($contactId);
+ break;
+ case 'ignore':
+ $introduction->ignore();
+
+ $relationship = DI::mstdnRelationship()->createDefaultFromContactId($contactId);
+ break;
+ case 'reject':
+ $introduction->discard();
+
+ $relationship = DI::mstdnRelationship()->createDefaultFromContactId($contactId);
+ break;
+ default:
+ throw new HTTPException\BadRequestException('Unexpected action parameter, expecting "authorize", "ignore" or "reject"');
+ }
+
+ System::jsonExit($relationship);
+ }
+
+ /**
+ * @param array $parameters
+ * @throws HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ * @see https://docs.joinmastodon.org/methods/accounts/follow_requests#pending-follows