Skip to content

Commit

Permalink
Merge pull request #7490 from appwrite/fix-target-deletes-not-triggered
Browse files Browse the repository at this point in the history
Trigger deletes worker when target is deleted
  • Loading branch information
abnegate committed Jan 25, 2024
2 parents d481031 + 52a9b31 commit dc1dad9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/controllers/api/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -1689,10 +1689,10 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e
->param('userId', '', new UID(), 'User ID.')
->param('targetId', '', new UID(), 'Target ID.')
->inject('queueForEvents')
->inject('queueForDeletes')
->inject('response')
->inject('dbForProject')
->action(function (string $userId, string $targetId, Event $queueForEvents, Response $response, Database $dbForProject) {

->action(function (string $userId, string $targetId, Event $queueForEvents, Delete $queueForDeletes, Response $response, Database $dbForProject) {
$user = $dbForProject->getDocument('users', $userId);

if ($user->isEmpty()) {
Expand All @@ -1712,6 +1712,10 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e
$dbForProject->deleteDocument('targets', $target->getId());
$dbForProject->deleteCachedDocument('users', $user->getId());

$queueForDeletes
->setType(DELETE_TYPE_TARGET)
->setDocument($target);

$queueForEvents
->setParam('userId', $user->getId())
->setParam('targetId', $target->getId());
Expand Down

0 comments on commit dc1dad9

Please sign in to comment.