Merge branch '1.5.x_review_changes' of https://github.com/appwrite/appwrite into event-label-messaging
This commit is contained in:
commit
61d46bee5c
5 changed files with 27 additions and 24 deletions
|
@ -2180,9 +2180,9 @@ App::patch('/v1/messaging/messages/email/:messageId')
|
|||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_MESSAGE)
|
||||
->param('messageId', '', new UID(), 'Message ID.')
|
||||
->param('topics', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs.', true)
|
||||
->param('users', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of User IDs.', true)
|
||||
->param('targets', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Targets IDs.', true)
|
||||
->param('topics', null, new ArrayList(new Text(Database::LENGTH_KEY)), 'List of Topic IDs.', true)
|
||||
->param('users', null, new ArrayList(new Text(Database::LENGTH_KEY)), 'List of User IDs.', true)
|
||||
->param('targets', null, new ArrayList(new Text(Database::LENGTH_KEY)), 'List of Targets IDs.', true)
|
||||
->param('subject', '', new Text(998), 'Email Subject.', true)
|
||||
->param('description', '', new Text(256), 'Description for Message.', true)
|
||||
->param('content', '', new Text(64230), 'Email Content.', true)
|
||||
|
@ -2194,7 +2194,7 @@ App::patch('/v1/messaging/messages/email/:messageId')
|
|||
->inject('project')
|
||||
->inject('queueForMessaging')
|
||||
->inject('response')
|
||||
->action(function (string $messageId, array $topics, array $users, array $targets, string $subject, string $description, string $content, string $status, bool $html, ?string $deliveryTime, Event $queueForEvents, Database $dbForProject, Document $project, Messaging $queueForMessaging, Response $response) {
|
||||
->action(function (string $messageId, ?array $topics, ?array $users, ?array $targets, string $subject, string $description, string $content, string $status, bool $html, ?string $deliveryTime, Event $queueForEvents, Database $dbForProject, Document $project, Messaging $queueForMessaging, Response $response) {
|
||||
$message = $dbForProject->getDocument('messages', $messageId);
|
||||
|
||||
if ($message->isEmpty()) {
|
||||
|
@ -2209,15 +2209,15 @@ App::patch('/v1/messaging/messages/email/:messageId')
|
|||
throw new Exception(Exception::MESSAGE_ALREADY_SCHEDULED);
|
||||
}
|
||||
|
||||
if (\count($topics) > 0) {
|
||||
if (!\is_null($topics)) {
|
||||
$message->setAttribute('topics', $topics);
|
||||
}
|
||||
|
||||
if (\count($users) > 0) {
|
||||
if (!\is_null($users)) {
|
||||
$message->setAttribute('users', $users);
|
||||
}
|
||||
|
||||
if (\count($targets) > 0) {
|
||||
if (!\is_null($targets)) {
|
||||
$message->setAttribute('targets', $targets);
|
||||
}
|
||||
|
||||
|
@ -2282,9 +2282,9 @@ App::patch('/v1/messaging/messages/sms/:messageId')
|
|||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_MESSAGE)
|
||||
->param('messageId', '', new UID(), 'Message ID.')
|
||||
->param('topics', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs.', true)
|
||||
->param('users', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of User IDs.', true)
|
||||
->param('targets', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Targets IDs.', true)
|
||||
->param('topics', null, new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs.', true)
|
||||
->param('users', null, new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of User IDs.', true)
|
||||
->param('targets', null, new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Targets IDs.', true)
|
||||
->param('description', '', new Text(256), 'Description for Message.', true)
|
||||
->param('content', '', new Text(64230), 'Email Content.', true)
|
||||
->param('status', '', new WhiteList(['draft', 'processing']), 'Message Status. Value must be either draft or processing.', true)
|
||||
|
@ -2294,7 +2294,7 @@ App::patch('/v1/messaging/messages/sms/:messageId')
|
|||
->inject('project')
|
||||
->inject('queueForMessaging')
|
||||
->inject('response')
|
||||
->action(function (string $messageId, array $topics, array $users, array $targets, string $description, string $content, string $status, ?string $deliveryTime, Event $queueForEvents, Database $dbForProject, Document $project, Messaging $queueForMessaging, Response $response) {
|
||||
->action(function (string $messageId, ?array $topics, ?array $users, ?array $targets, string $description, string $content, string $status, ?string $deliveryTime, Event $queueForEvents, Database $dbForProject, Document $project, Messaging $queueForMessaging, Response $response) {
|
||||
$message = $dbForProject->getDocument('messages', $messageId);
|
||||
|
||||
if ($message->isEmpty()) {
|
||||
|
@ -2309,15 +2309,15 @@ App::patch('/v1/messaging/messages/sms/:messageId')
|
|||
throw new Exception(Exception::MESSAGE_ALREADY_SCHEDULED);
|
||||
}
|
||||
|
||||
if (\count($topics) > 0) {
|
||||
if (!\is_null($topics)) {
|
||||
$message->setAttribute('topics', $topics);
|
||||
}
|
||||
|
||||
if (\count($users) > 0) {
|
||||
if (!\is_null($users)) {
|
||||
$message->setAttribute('users', $users);
|
||||
}
|
||||
|
||||
if (\count($targets) > 0) {
|
||||
if (!\is_null($targets)) {
|
||||
$message->setAttribute('targets', $targets);
|
||||
}
|
||||
|
||||
|
@ -2374,9 +2374,9 @@ App::patch('/v1/messaging/messages/push/:messageId')
|
|||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_MESSAGE)
|
||||
->param('messageId', '', new UID(), 'Message ID.')
|
||||
->param('topics', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs.', true)
|
||||
->param('users', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of User IDs.', true)
|
||||
->param('targets', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Targets IDs.', true)
|
||||
->param('topics', null, new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs.', true)
|
||||
->param('users', null, new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of User IDs.', true)
|
||||
->param('targets', null, new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Targets IDs.', true)
|
||||
->param('description', '', new Text(256), 'Description for Message.', true)
|
||||
->param('title', '', new Text(256), 'Title for push notification.', true)
|
||||
->param('body', '', new Text(64230), 'Body for push notification.', true)
|
||||
|
@ -2393,7 +2393,7 @@ App::patch('/v1/messaging/messages/push/:messageId')
|
|||
->inject('project')
|
||||
->inject('queueForMessaging')
|
||||
->inject('response')
|
||||
->action(function (string $messageId, array $topics, array $users, array $targets, string $description, string $title, string $body, ?array $data, string $action, string $icon, string $sound, string $color, string $tag, string $badge, string $status, ?string $deliveryTime, Event $queueForEvents, Database $dbForProject, Document $project, Messaging $queueForMessaging, Response $response) {
|
||||
->action(function (string $messageId, ?array $topics, ?array $users, ?array $targets, string $description, string $title, string $body, ?array $data, string $action, string $icon, string $sound, string $color, string $tag, string $badge, string $status, ?string $deliveryTime, Event $queueForEvents, Database $dbForProject, Document $project, Messaging $queueForMessaging, Response $response) {
|
||||
$message = $dbForProject->getDocument('messages', $messageId);
|
||||
|
||||
if ($message->isEmpty()) {
|
||||
|
@ -2408,15 +2408,15 @@ App::patch('/v1/messaging/messages/push/:messageId')
|
|||
throw new Exception(Exception::MESSAGE_ALREADY_SCHEDULED);
|
||||
}
|
||||
|
||||
if (\count($topics) > 0) {
|
||||
if (!\is_null($topics)) {
|
||||
$message->setAttribute('topics', $topics);
|
||||
}
|
||||
|
||||
if (\count($users) > 0) {
|
||||
if (!\is_null($users)) {
|
||||
$message->setAttribute('users', $users);
|
||||
}
|
||||
|
||||
if (\count($targets) > 0) {
|
||||
if (!\is_null($targets)) {
|
||||
$message->setAttribute('targets', $targets);
|
||||
}
|
||||
|
||||
|
|
2
composer.lock
generated
2
composer.lock
generated
|
@ -5822,5 +5822,5 @@
|
|||
"platform-overrides": {
|
||||
"php": "8.0"
|
||||
},
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
|
|
@ -570,6 +570,7 @@ services:
|
|||
environment:
|
||||
- _APP_ENV
|
||||
- _APP_WORKER_PER_CORE
|
||||
- _APP_OPENSSL_KEY_V1
|
||||
- _APP_REDIS_HOST
|
||||
- _APP_REDIS_PORT
|
||||
- _APP_REDIS_USER
|
||||
|
|
|
@ -113,7 +113,7 @@ class Messaging extends Action
|
|||
*/
|
||||
$results = batch(\array_map(function ($providerId) use ($providers, $message, $dbForProject) {
|
||||
return function () use ($providerId, $providers, $message, $dbForProject) {
|
||||
$provider = Authorization::skip(fn () => $dbForProject->getDocument('providers', $providerId));
|
||||
$provider = $dbForProject->getDocument('providers', $providerId);
|
||||
$identifiers = $providers[$providerId];
|
||||
$adapter = match ($provider->getAttribute('type')) {
|
||||
'sms' => $this->sms($provider),
|
||||
|
|
|
@ -1018,6 +1018,8 @@ class AccountCustomClientTest extends Scope
|
|||
public function testPhoneVerification(array $data): array
|
||||
{
|
||||
$session = $data['session'] ?? '';
|
||||
$smsDSN = new DSN(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN'));
|
||||
$from = $smsDSN->getParam('from');
|
||||
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
|
@ -1028,7 +1030,7 @@ class AccountCustomClientTest extends Scope
|
|||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
||||
|
||||
]), ['from' => App::getEnv('_APP_MESSAGE_SMS_PROVIDER_MSG91_FROM')]);
|
||||
]), ['from' => $from]);
|
||||
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
|
|
Loading…
Reference in a new issue