avoid 409 error by same vote answer as already stored
Signed-off-by: dartcafe <github@dartcafe.de>
This commit is contained in:
Родитель
54334fe4e7
Коммит
2c9a0df448
|
@ -72,16 +72,21 @@ class VoteService {
|
|||
$option = $this->optionMapper->find($optionId);
|
||||
$poll = $this->pollMapper->find($option->getPollId());
|
||||
$poll->request(Poll::PERMISSION_VOTE_EDIT);
|
||||
|
||||
if ($setTo === Vote::VOTE_YES) {
|
||||
$this->checkLimits($option);
|
||||
}
|
||||
// delete no votes, if poll setting is set to useNo === 0
|
||||
$deleteVoteInsteadOfNoVote = in_array(trim($setTo), [Vote::VOTE_NO, '']) && !boolval($poll->getUseNo());
|
||||
|
||||
try {
|
||||
$this->vote = $this->voteMapper->findSingleVote($poll->getId(), $option->getPollOptionText(), $this->acl->getCurrentUserId());
|
||||
|
||||
if ($setTo === $this->vote->getVoteAnswer()) {
|
||||
return $this->vote;
|
||||
}
|
||||
|
||||
if ($setTo === Vote::VOTE_YES) {
|
||||
$this->checkLimits($option);
|
||||
}
|
||||
|
||||
// delete no votes, if poll setting is set to useNo === 0
|
||||
$deleteVoteInsteadOfNoVote = in_array(trim($setTo), [Vote::VOTE_NO, '']) && !boolval($poll->getUseNo());
|
||||
|
||||
if ($deleteVoteInsteadOfNoVote) {
|
||||
$this->vote->setVoteAnswer('');
|
||||
$this->voteMapper->delete($this->vote);
|
||||
|
|
Загрузка…
Ссылка в новой задаче