Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Changelog
All notable changes to this project will be documented in this file.
## [Unreleased]
### Fixed
- Public users could not add confidential comments

### Added
- OpenAPI spec

Expand Down
5 changes: 3 additions & 2 deletions lib/Controller/CommentApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ public function list(int $pollId): DataResponse {
* 200: Comment added
* @param int $pollId Poll id
* @param string $comment Comment text to add
* @param bool $confidential Whether the comment is only visible to the poll owner and the author
* @return DataResponse<Http::STATUS_OK, array{comment: PollsComment}, array{}>
*/
#[CORS]
#[NoAdminRequired]
#[NoCSRFRequired]
#[ApiRoute(verb: 'POST', url: '/api/v1.0/poll/{pollId}/comment')]
public function add(int $pollId, string $comment): DataResponse {
return $this->response(fn () => ['comment' => $this->commentService->add($comment, $pollId)->jsonSerialize()]);
public function add(int $pollId, string $comment, bool $confidential = false): DataResponse {
return $this->response(fn () => ['comment' => $this->commentService->add($comment, $pollId, $confidential)->jsonSerialize()]);
}

/**
Expand Down
1 change: 1 addition & 0 deletions lib/Controller/CommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function list(int $pollId): JSONResponse {
* Write a new comment to the db and returns the new comment as array
* @param int $pollId Poll id
* @param string $message Comment text to add
* @param bool $confidential Whether the comment is only visible to the poll owner and the author
*/
#[NoAdminRequired]
#[FrontpageRoute(verb: 'POST', url: '/poll/{pollId}/comment')]
Expand Down
5 changes: 3 additions & 2 deletions lib/Controller/PublicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,15 @@ public function getComments(): JSONResponse {
/**
* Write a new comment to the db and returns the new comment as array
* @param string $message Comment text to add
* @param bool $confidential Whether the comment is only visible to the poll owner and the author
*/
#[PublicPage]
#[ShareTokenRequired]
#[OpenAPI(OpenAPI::SCOPE_IGNORE)]
#[FrontpageRoute(verb: 'POST', url: '/s/{token}/comment')]
public function addComment(string $message): JSONResponse {
public function addComment(string $message, bool $confidential = false): JSONResponse {
return $this->response(fn () => [
'comment' => $this->commentService->add($message, $this->userSession->getShare()->getPollIdOrFail())
'comment' => $this->commentService->add($message, $this->userSession->getShare()->getPollIdOrFail(), $confidential)
]);
}

Expand Down
5 changes: 5 additions & 0 deletions openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,11 @@
"comment": {
"type": "string",
"description": "Comment text to add"
},
"confidential": {
"type": "boolean",
"default": false,
"description": "Whether the comment is only visible to the poll owner and the author"
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,11 @@
"comment": {
"type": "string",
"description": "Comment text to add"
},
"confidential": {
"type": "boolean",
"default": false,
"description": "Whether the comment is only visible to the poll owner and the author"
}
}
}
Expand Down
Loading