'ocs' => [
['name' => 'Api#get', 'url' => '/api/v{version}/get/{fileId}', 'verb' => 'GET', 'requirements' => $requirements],
['name' => 'Api#set', 'url' => '/api/v{version}/set/{fileId}', 'verb' => 'PUT', 'requirements' => $requirements],
+ ['name' => 'Api#remove', 'url' => '/api/v{version}/remove/{fileId}', 'verb' => 'DELETE', 'requirements' => $requirements],
],
];
];
return new JSONResponse($reminderData, Http::STATUS_OK);
} catch (DoesNotExistException $e) {
- // Return null when no reminder is found
- $reminderData = [
- 'dueDate' => null,
- ];
- return new JSONResponse($reminderData, Http::STATUS_OK);
+ return new JSONResponse([], Http::STATUS_NOT_FOUND);
} catch (Throwable $th) {
$this->logger->error($th->getMessage(), ['exception' => $th]);
return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
}
}
+
+ /**
+ * Remove a reminder
+ */
+ public function remove(int $fileId): JSONResponse {
+ $user = $this->userSession->getUser();
+ if ($user === null) {
+ return new JSONResponse([], Http::STATUS_UNAUTHORIZED);
+ }
+
+ try {
+ $this->reminderService->remove($user, $fileId);
+ return new JSONResponse([], Http::STATUS_OK);
+ } catch (DoesNotExistException $e) {
+ return new JSONResponse([], Http::STATUS_NOT_FOUND);
+ } catch (Throwable $th) {
+ $this->logger->error($th->getMessage(), ['exception' => $th]);
+ return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
+ }
+ }
}
}
}
+ /**
+ * @throws DoesNotExistException
+ */
+ public function remove(IUser $user, int $fileId): void {
+ $reminder = $this->reminderMapper->findDueForUser($user, $fileId);
+ $this->reminderMapper->delete($reminder);
+ }
+
/**
* @throws DoesNotExistException
* @throws UserNotFoundException