Skip to content

Commit e70a698

Browse files
committed
fix: add timestamps and cache invalidation for push target migration
1 parent 688b7b6 commit e70a698

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Migration/Destinations/Appwrite.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,8 +1745,13 @@ protected function importUserTargets(string $userId, array $targets): void
17451745
case 'push':
17461746
$userDoc ??= $this->dbForProject->getDocument('users', $userId);
17471747

1748+
$createdAt = $this->normalizeDateTime($target['$createdAt'] ?? null);
1749+
$updatedAt = $this->normalizeDateTime($target['$updatedAt'] ?? null, $createdAt);
1750+
17481751
$this->dbForProject->createDocument('targets', new UtopiaDocument([
17491752
'$id' => $target['$id'],
1753+
'$createdAt' => $createdAt,
1754+
'$updatedAt' => $updatedAt,
17501755
'$permissions' => [
17511756
Permission::read(Role::user($userId)),
17521757
Permission::update(Role::user($userId)),
@@ -1901,9 +1906,16 @@ protected function createProvider(Provider $resource): void
19011906
Query::isNull('providerInternalId'),
19021907
]);
19031908

1909+
$userIds = [];
1910+
19041911
foreach ($targets as $target) {
19051912
$target->setAttribute('providerInternalId', $provider->getSequence());
19061913
$this->dbForProject->updateDocument('targets', $target->getId(), $target);
1914+
$userIds[$target->getAttribute('userId')] = true;
1915+
}
1916+
1917+
foreach (array_keys($userIds) as $userId) {
1918+
$this->dbForProject->purgeCachedDocument('users', $userId);
19071919
}
19081920
}
19091921

0 commit comments

Comments
 (0)