PHRAS-3399 fix feedback right issue

This commit is contained in:
aynsix
2021-03-18 17:09:14 +03:00
parent a350d49990
commit c8465d5a53
2 changed files with 26 additions and 11 deletions

View File

@@ -302,9 +302,12 @@ class PushController extends Controller
// we always add the author of the validation request (current user) to the participants
//
$found = false;
foreach ($participants as $participant) {
if ($participant['usr_id'] === $this->getAuthenticatedUser()->getId()) {
foreach ($participants as $key => $participant) {
if ($Validation->isInitiator($this->getAuthenticatedUser()) && $participant['usr_id'] == $this->getAuthenticatedUser()->getId()) {
// the initiator always can see others
$participants[$key]['see_others'] = 1;
$found = true;
break;
}
}
@@ -353,9 +356,14 @@ class PushController extends Controller
}
// end of sanity check
// if participant already exists, skip insertion
// if participant already exists, just update right
try {
$Validation->getParticipant($participantUser);
$validationParticipant = $Validation->getParticipant($participantUser);
$validationParticipant->setCanAgree($participant['agree']);
$validationParticipant->setCanSeeOthers($participant['see_others']);
$manager->persist($validationParticipant);
$manager->flush();
continue;
}
catch (NotFoundHttpException $e) {
@@ -460,10 +468,17 @@ class PushController extends Controller
$this->app->trans('Unknown user %usr_id%', ['%usr_id%' => $userIdToRemove])
);
}
$validationParticipant = $Validation->getParticipant($participantUser);
$Validation->removeParticipant($validationParticipant);
$manager->remove($validationParticipant);
// if initiator is removed from the user selection,
// do not remove it to the participant list, just set can_agree to false for it
if ($Validation->isInitiator($participantUser)) {
$validationParticipant->setCanAgree(false);
$manager->persist($validationParticipant);
} else {
$Validation->removeParticipant($validationParticipant);
$manager->remove($validationParticipant);
}
}
}