1
0
Fork 0
mirror of synced 2024-10-03 19:53:33 +13:00

Merge branch 'feat-add-messaging-collections-in-config' of https://github.com/appwrite/appwrite into feat-add-messaging-response-models

This commit is contained in:
Prateek Banga 2023-09-11 20:30:30 +05:30
commit 899c962061
2 changed files with 111 additions and 20 deletions

View file

@ -1437,22 +1437,61 @@ $commonCollections = [
'default' => null, 'default' => null,
'array' => false, 'array' => false,
'filters' => ['json', 'encrypt'], 'filters' => ['json', 'encrypt'],
] ],
[
'$id' => ID::custom('search'),
'type' => Database::VAR_STRING,
'format' => '',
'size' => 65535,
'signed' => true,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
], ],
'indexes' => [ 'indexes' => [
[ [
'$id' => ID::custom('_key_provider'), '$id' => ID::custom('_key_provider'),
'type' => Database::INDEX_KEY, 'type' => Database::INDEX_KEY,
'attributes' => ['provider'], 'attributes' => ['provider'],
'lengths' => [128], 'lengths' => [],
'orders' => [Database::ORDER_ASC], 'orders' => [Database::ORDER_ASC],
], ],
[ [
'$id' => ID::custom('_key_name'), '$id' => ID::custom('_key_name'),
'type' => Database::INDEX_FULLTEXT, 'type' => Database::INDEX_FULLTEXT,
'attributes' => ['name'], 'attributes' => ['name'],
'lengths' => [128], 'lengths' => [],
'orders' => [Database::ORDER_ASC], 'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_type'),
'type' => Database::INDEX_KEY,
'attributes' => ['type'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_default'),
'type' => Database::INDEX_KEY,
'attributes' => ['default'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_default_type'),
'type' => Database::INDEX_KEY,
'attributes' => ['default, type'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_search'),
'type' => Database::INDEX_FULLTEXT,
'attributes' => ['search'],
'lengths' => [],
'orders' => [],
] ]
], ],
], ],
@ -1488,7 +1527,7 @@ $commonCollections = [
'$id' => ID::custom('data'), '$id' => ID::custom('data'),
'type' => Database::VAR_STRING, 'type' => Database::VAR_STRING,
'format' => '', 'format' => '',
'size' => 16384, 'size' => 65535,
'signed' => true, 'signed' => true,
'required' => true, 'required' => true,
'default' => null, 'default' => null,
@ -1499,7 +1538,7 @@ $commonCollections = [
'$id' => ID::custom('to'), '$id' => ID::custom('to'),
'type' => Database::VAR_STRING, 'type' => Database::VAR_STRING,
'format' => '', 'format' => '',
'size' => 16834, 'size' => 65535,
'signed' => true, 'signed' => true,
'required' => true, 'required' => true,
'default' => null, 'default' => null,
@ -1518,14 +1557,14 @@ $commonCollections = [
'filters' => ['datetime'], 'filters' => ['datetime'],
], ],
[ [
'$id' => ID::custom('deliveryError'), '$id' => ID::custom('deliveryErrors'),
'type' => Database::VAR_STRING, 'type' => Database::VAR_STRING,
'format' => '', 'format' => '',
'size' => 2048, 'size' => 65535,
'signed' => true, 'signed' => true,
'required' => false, 'required' => false,
'default' => null, 'default' => null,
'array' => false, 'array' => true,
'filters' => [], 'filters' => [],
], ],
[ [
@ -1567,14 +1606,14 @@ $commonCollections = [
'$id' => ID::custom('_key_providerId'), '$id' => ID::custom('_key_providerId'),
'type' => Database::INDEX_KEY, 'type' => Database::INDEX_KEY,
'attributes' => ['providerId'], 'attributes' => ['providerId'],
'lengths' => [128], 'lengths' => [],
'orders' => [Database::ORDER_ASC], 'orders' => [Database::ORDER_ASC],
], ],
[ [
'$id' => ID::custom('_key_providerInternalId'), '$id' => ID::custom('_key_providerInternalId'),
'type' => Database::INDEX_KEY, 'type' => Database::INDEX_KEY,
'attributes' => ['providerInternalId'], 'attributes' => ['providerInternalId'],
'lengths' => [128], 'lengths' => [],
'orders' => [Database::ORDER_ASC], 'orders' => [Database::ORDER_ASC],
], ],
[ [
@ -1646,21 +1685,32 @@ $commonCollections = [
'default' => null, 'default' => null,
'array' => false, 'array' => false,
'filters' => ['subQueryTopicTargets'], 'filters' => ['subQueryTopicTargets'],
] ],
[
'$id' => ID::custom('search'),
'type' => Database::VAR_STRING,
'format' => '',
'size' => 16384,
'signed' => true,
'required' => false,
'default' => null,
'array' => false,
'filters' => [],
],
], ],
'indexes' => [ 'indexes' => [
[ [
'$id' => ID::custom('_key_providerId'), '$id' => ID::custom('_key_providerId'),
'type' => Database::INDEX_KEY, 'type' => Database::INDEX_KEY,
'attributes' => ['providerId'], 'attributes' => ['providerId'],
'lengths' => [128], 'lengths' => [],
'orders' => [Database::ORDER_ASC], 'orders' => [Database::ORDER_ASC],
], ],
[ [
'$id' => ID::custom('_key_providerInternalId'), '$id' => ID::custom('_key_providerInternalId'),
'type' => Database::INDEX_KEY, 'type' => Database::INDEX_KEY,
'attributes' => ['providerInternalId'], 'attributes' => ['providerInternalId'],
'lengths' => [128], 'lengths' => [],
'orders' => [Database::ORDER_ASC], 'orders' => [Database::ORDER_ASC],
], ],
[ [
@ -1671,12 +1721,12 @@ $commonCollections = [
'orders' => [], 'orders' => [],
], ],
[ [
'$id' => ID::custom('_key_description'), '$id' => ID::custom('_key_search'),
'type' => Database::INDEX_FULLTEXT, 'type' => Database::INDEX_FULLTEXT,
'attributes' => ['description'], 'attributes' => ['name'],
'lengths' => [], 'lengths' => [],
'orders' => [], 'orders' => [Database::ORDER_ASC],
], ]
], ],
], ],
@ -1826,7 +1876,7 @@ $commonCollections = [
'$id' => ID::custom('identifier'), '$id' => ID::custom('identifier'),
'type' => Database::VAR_STRING, 'type' => Database::VAR_STRING,
'format' => '', 'format' => '',
'size' => Database::LENGTH_KEY, 'size' => 2048,
'signed' => true, 'signed' => true,
'required' => true, 'required' => true,
'default' => null, 'default' => null,
@ -1839,14 +1889,14 @@ $commonCollections = [
'$id' => ID::custom('_key_userId'), '$id' => ID::custom('_key_userId'),
'type' => Database::INDEX_KEY, 'type' => Database::INDEX_KEY,
'attributes' => ['userId'], 'attributes' => ['userId'],
'lengths' => [128], 'lengths' => [],
'orders' => [Database::ORDER_ASC], 'orders' => [Database::ORDER_ASC],
], ],
[ [
'$id' => ID::custom('_key_userInternalId'), '$id' => ID::custom('_key_userInternalId'),
'type' => Database::INDEX_KEY, 'type' => Database::INDEX_KEY,
'attributes' => ['userInternalId'], 'attributes' => ['userInternalId'],
'lengths' => [128], 'lengths' => [],
'orders' => [Database::ORDER_ASC], 'orders' => [Database::ORDER_ASC],
], ],
[ [

View file

@ -544,6 +544,47 @@ Database::addFilter(
])); ]));
} }
); );
Database::addFilter(
'subQueryProviderType',
function (mixed $value) {
return null;
},
function (mixed $value, Document $document, Database $database) {
$provider = Authorization::skip(fn () => $database
->getDocument(
'providers',
$document->getAttribute('providerId'),
[Query::select(['type'])]
));
if ($provider) {
return $provider->getAttribute('type');
}
return null;
}
);
Database::addFilter(
'subQueryTopicTargets',
function (mixed $value) {
return null;
},
function (mixed $value, Document $document, Database $database) {
$targetIds = Authorization::skip(fn () => \array_map(
fn ($document) => $document->getAttribute('targetId'),
$database
->find('subscribers', [
Query::equal('topicInternalId', [$document->getInternalId()]),
Query::limit(APP_LIMIT_SUBQUERY),
])
));
if (\count($targetIds) > 0) {
return $database->find('targets', [Query::equal('$id', $targetIds)]);
}
return [];
}
);
/** /**
* DB Formats * DB Formats
*/ */