1
0
Fork 0
mirror of synced 2024-09-29 08:51:28 +13:00

Delete user update

This commit is contained in:
shimon 2024-06-18 18:12:29 +03:00
parent 8537e1ce32
commit 1d7c38512c

View file

@ -587,19 +587,22 @@ class Deletes extends Action
], $dbForProject);
$dbForProject->purgeCachedDocument('users', $userId);
var_dump('in delete worker');
// Delete Memberships and decrement team membership counts
$this->deleteByGroup('memberships', [
Query::equal('userInternalId', [$userInternalId])
], $dbForProject, function (Document $document) use ($dbForProject) {
var_dump($document->getAttribute('confirm'));
if ($document->getAttribute('confirm')) { // Count only confirmed members
$teamId = $document->getAttribute('teamId');
$team = $dbForProject->getDocument('teams', $teamId);
if (!$team->isEmpty()) {
$total = $document->getAttribute('total');
var_dump('$total='.$total);
// Delete the team if the user is the last membership
if ($total === 1) {
$this->deleteById($team, $dbForProject);
var_dump('delete team');
return;
}
$dbForProject->decreaseDocumentAttribute('teams', $teamId, 'total', 1, 0);