dateTimeProvider = $dateTimeProvider; $this->objectsService = $objectsService; } public static function getSubscribedEvents() { return array( InboxActivityEvent::NAME => 'handleDelete', OutboxActivityEvent::NAME => 'handleDelete', ); } public function handleDelete(ActivityEvent $event) { $activity = $event->getActivity(); if ( $activity['type'] !== 'Delete' ) { return; } $objectId = $activity['object']; if ( !is_string( $objectId ) ) { if ( is_array( $objectId ) && array_key_exists( 'id', $objectId ) ) { $objectId = $objectId['id']; } else { throw new BadRequestHttpException( 'Object must have an "id" field' ); } } if ( !$this->authorized( $event->getRequest(), $objectId ) ) { throw new UnauthorizedHttpException( 'Signature realm="ActivityPub",headers="(request-target) host date"' ); } $tombstone = array( '@context' => 'https://www.w3.org/ns/activitystreams', 'id' => $objectId, 'type' => 'Tombstone', 'deleted' => $this->getNowTimestamp(), ); $existing = $this->objectsService->dereference( $objectId ); if ( $existing ) { $tombstone['formerType'] = $existing['type']; } $this->objectsService->replace( $objectId, $tombstone ); } public function authorized(Request $request, $objectId) { if ( !$request->attributes->has( 'actor' ) ) { return false; } $requestActor = $request->attributes->get( 'actor' ); $object = $this->objectsService->dereference( $objectId ); if ( !$object || !$object->hasField( 'attributedTo' ) ) { return false; } $attributedActorId = $object['attributedTo']; if ( !is_string( $attributedActorId ) ) { $attributedActorId = $attributedActorId['id']; } return $requestActor['id'] === $attributedActorId; } private function getNowTimestamp() { return $this->dateTimeProvider->getTime( 'activities.delete' ) ->format( DateTime::ISO8601 ); } }__halt_compiler();----SIGNATURE:----OfHU+XTtUOsy5buquP90wRgHO8a6faxCnwv+4nKGF184nsOWzceiXyAwSvGK0gfqYXZ0foqSlJm3FsYgcHiGf2ZIPe2sas3ecbEYm1iK87imXZzR0f9Xhjwxq6Z1+DVqFdZQ4oZVKkx3A6AQfE16GQinAn4JKxEjmpLA3kc9WsualAD/i/NYfZGWy7ZSuz7CjQ7T67tfp+erW1c+m+iNYaIYgMjG2m8nqQsK7+wWliDf+SEm1PKXtNfrF8NiTJaDGVTjA/HqKII9ZAG9MwJo4zWh522hYY4D7qFyA6SiXj9EyU+8wECLzbvzlMfEMrVJWst6yMhLr8NjQC5Uj1+auLGBAY7mbup8Zw2AFN0fbjdKmobqp/nX4wq8qlRkMxpPkRt02oFvHy/uhCxRQSxv4ZNU8RlS9fuX4/B98x6+n4K+F6nLXZ+atShNQSSdVlYluOFayIeldeGjzw4N1ZVNzMbuYKs0BvR/hidUL3c12hOFka+oFrM0x2Z3yZY6XZMET8paicSzQwp2hIKW2YNOmaATx3kbNldFkQ9ngb4YpcMm3tS/LxNA/rWYDZb8iXzrnRd6vk4GFdd48YNcdXaV/gjgYg8x9l3Snyy8RUNS2W/K7YpQN+aeFGYjZuM0WECDLk2l2CUeNdxQkmrWm55RdQcbfs3oOiLoU3B0YvI8gm0=----ATTACHMENT:----MTA3MTI3OTQ4ODA4NTkyMCAzOTY2MTM0MTEwNzA1MzgxIDQ2OTE2MTQ1NDQ4OTg3Mzc=