Skip to content

Commit

Permalink
fix : deleted user when email share registers
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza Mahjoubi <hamzamahjoubi221@gmail.com>
  • Loading branch information
hamza221 committed Aug 14, 2024
1 parent ecbf73f commit 89a20a1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Service/ShareService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCA\Polls\Db\Share;
use OCA\Polls\Db\ShareMapper;
use OCA\Polls\Db\UserMapper;
use OCA\Polls\Db\VoteMapper;
use OCA\Polls\Event\ShareChangedDisplayNameEvent;
use OCA\Polls\Event\ShareChangedEmailEvent;
use OCA\Polls\Event\ShareChangedLabelEvent;
Expand Down Expand Up @@ -57,6 +58,7 @@ public function __construct(
private NotificationService $notificationService,
private PollMapper $pollMapper,
private UserMapper $userMapper,
private VoteMapper $voteMapper,
private UserSession $userSession,
) {
$this->shares = [];
Expand Down Expand Up @@ -304,6 +306,10 @@ public function register(
$this->share->getType() === Share::TYPE_EMAIL
|| $this->share->getType() === Share::TYPE_CONTACT
) {
if($this->share->getType() === Share::TYPE_EMAIL) {
$this->voteMapper->renameUserId($this->share->getUserId(), $userId);
}

// Convert email and contact shares to external share, if user registers
$this->share->setType(Share::TYPE_EXTERNAL);
$this->share->setUserId($userId);
Expand Down

0 comments on commit 89a20a1

Please sign in to comment.