mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Create the targets in the target collection instead of on the user
This commit is contained in:
@@ -6,6 +6,7 @@ use Appwrite\Migration\Migration;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Helpers\ID;
|
||||
|
||||
class V20 extends Migration
|
||||
{
|
||||
@@ -120,21 +121,25 @@ class V20 extends Migration
|
||||
break;
|
||||
case 'users':
|
||||
if ($document->getAttribute('email', '') !== '') {
|
||||
$document->setAttribute('targets', [
|
||||
$target = new Document([
|
||||
'$id' => ID::unique(),
|
||||
'userId' => $document->getId(),
|
||||
'userInternalId' => $document->getInternalId(),
|
||||
'providerType' => MESSAGE_TYPE_EMAIL,
|
||||
'identifier' => $document->getAttribute('email'),
|
||||
]);
|
||||
$this->projectDB->createDocument('targets', $target);
|
||||
}
|
||||
|
||||
if ($document->getAttribute('phone', '') !== '') {
|
||||
$document->setAttribute('targets', [
|
||||
$target = new Document([
|
||||
'$id' => ID::unique(),
|
||||
'userId' => $document->getId(),
|
||||
'userInternalId' => $document->getInternalId(),
|
||||
'providerType' => MESSAGE_TYPE_SMS,
|
||||
'identifier' => $document->getAttribute('phone'),
|
||||
]);
|
||||
$this->projectDB->createDocument('targets', $target);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user