. // }}} namespace Plugin\ActivityPub\Controller; use App\Core\Controller; use App\Core\DB\DB; use function App\Core\I18n\_m; use App\Util\Exception\ClientException; use Plugin\ActivityPub\ActivityPub; use Plugin\ActivityPub\Util\Model\AS2ToEntity\AS2ToEntity; use Plugin\ActivityPub\Util\Response\TypeResponse; use Plugin\ActivityPub\Util\Type; use Plugin\ActivityPub\Util\Type\Util; class Inbox extends Controller { /** * Inbox handler */ public function handle(?int $gsactor_id = null): TypeResponse { if (!\is_null($gsactor_id)) { $user = DB::find('local_user', ['id' => $gsactor_id]); if (\is_null($user)) { throw new ClientException(_m('No such actor.'), 404); } } // TODO: Check if Actor can post // // Get content // $payload = Util::decodeJson( // (string) $this->request->getContent(), // ); // // // Cast as an ActivityStreams type // $type = Type::create($payload); $type = Type::fromJson((string) $this->request->getContent()); // TODO: Check if Actor has authority over payload // Store Activity $ap_act = AS2ToEntity::store(activity: $type->toArray(), source: 'ActivityPub'); DB::flush(); dd($ap_act, $act = $ap_act->getActivity(), $act->getActor(), $act->getObject()); return new TypeResponse($type, status: 202); } }