Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exteand deletes worker #8274

Open
wants to merge 16 commits into
base: 1.5.x
Choose a base branch
from
Prev Previous commit
Delete user update
  • Loading branch information
shimonewman committed Jun 18, 2024
commit 1d7c38512c9869fada92126cb0cebca5038d94c6
5 changes: 4 additions & 1 deletion src/Appwrite/Platform/Workers/Deletes.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,19 +587,22 @@ protected function deleteUser(callable $getProjectDB, Document $document, Docum
], $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);
Expand Down
Loading