diff --git a/src/FederationServer/Classes/Enums/Method.php b/src/FederationServer/Classes/Enums/Method.php index c9b5e4d..364600c 100644 --- a/src/FederationServer/Classes/Enums/Method.php +++ b/src/FederationServer/Classes/Enums/Method.php @@ -7,6 +7,7 @@ use FederationServer\Methods\Attachments\DownloadAttachment; use FederationServer\Methods\Attachments\UploadAttachment; use FederationServer\Methods\Audit\ListAuditLogs; + use FederationServer\Methods\Audit\ViewAuditEntry; use FederationServer\Methods\Operators\CreateOperator; use FederationServer\Methods\Operators\DeleteOperator; use FederationServer\Methods\Operators\EnableOperator; @@ -20,6 +21,7 @@ enum Method { case LIST_AUDIT_LOGS; + case VIEW_AUDIT_ENTRY; case LIST_OPERATORS; case CREATE_OPERATOR; @@ -48,6 +50,9 @@ case self::LIST_AUDIT_LOGS: ListAuditLogs::handleRequest(); break; + case self::VIEW_AUDIT_ENTRY: + ViewAuditEntry::handleRequest(); + break; case self::LIST_OPERATORS: ListOperators::handleRequest(); @@ -101,6 +106,7 @@ return match (true) { $path === '/' && $requestMethod === 'GET' => Method::LIST_AUDIT_LOGS, + preg_match('#^/audit/([a-fA-F0-9\-]{36,})$#', $path) && $requestMethod === 'GET' => Method::VIEW_AUDIT_ENTRY, preg_match('#^/attachments/([a-fA-F0-9\-]{36,})$#', $path) && $requestMethod === 'GET' => Method::DOWNLOAD_ATTACHMENT, preg_match('#^/attachments/([a-fA-F0-9\-]{36,})$#', $path) && $requestMethod === 'DELETE' => Method::DELETE_ATTACHMENT, diff --git a/src/FederationServer/Methods/Audit/ViewAuditEntry.php b/src/FederationServer/Methods/Audit/ViewAuditEntry.php new file mode 100644 index 0000000..800d16b --- /dev/null +++ b/src/FederationServer/Methods/Audit/ViewAuditEntry.php @@ -0,0 +1,63 @@ +getOperator() !== null) + { + $operatorRecord = OperatorManager::getOperator($logRecord->getOperator()); + } + + if($logRecord->getEntity() !== null) + { + $entityRecord = EntitiesManager::getEntityByUuid($logRecord->getEntity()); + } + + $result = new PublicAuditRecord($logRecord, $operatorRecord, $entityRecord); + } + catch (DatabaseOperationException $e) + { + throw new RequestException('Internal Server Error: Unable to retrieve audit log', 500, $e); + } + + self::successResponse($result->toArray()); + } + } +