1
0
Fork 0
mirror of synced 2024-10-02 10:16:27 +13:00

add recipients array check in API instead of worker

This commit is contained in:
Prateek Banga 2023-10-27 13:42:27 +05:30
parent 5a9b1f0c24
commit bc6df4bab7
2 changed files with 6 additions and 11 deletions

View file

@ -1620,7 +1620,7 @@ App::post('/v1/messaging/messages/email')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_MESSAGE) ->label('sdk.response.model', Response::MODEL_MESSAGE)
->param('messageId', '', new CustomId(), 'Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('messageId', '', new CustomId(), 'Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY)), 'List of Topic IDs or List of User IDs or List of Target IDs.') ->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs or List of User IDs or List of Target IDs.')
->param('subject', '', new Text(998), 'Email Subject.') ->param('subject', '', new Text(998), 'Email Subject.')
->param('content', '', new Text(64230), 'Email Content.') ->param('content', '', new Text(64230), 'Email Content.')
->param('description', '', new Text(256), 'Description for message.', true) ->param('description', '', new Text(256), 'Description for message.', true)
@ -1673,7 +1673,7 @@ App::post('/v1/messaging/messages/sms')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_MESSAGE) ->label('sdk.response.model', Response::MODEL_MESSAGE)
->param('messageId', '', new CustomId(), 'Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('messageId', '', new CustomId(), 'Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY)), 'List of Topic IDs or List of User IDs or List of Target IDs.') ->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs or List of User IDs or List of Target IDs.')
->param('content', '', new Text(64230), 'SMS Content.') ->param('content', '', new Text(64230), 'SMS Content.')
->param('description', '', new Text(256), 'Description for Message.', true) ->param('description', '', new Text(256), 'Description for Message.', true)
->param('status', 'processing', new WhiteList(['draft', 'processing']), 'Message Status. Value must be either draft or processing.', true) ->param('status', 'processing', new WhiteList(['draft', 'processing']), 'Message Status. Value must be either draft or processing.', true)
@ -1722,7 +1722,7 @@ App::post('/v1/messaging/messages/push')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_MESSAGE) ->label('sdk.response.model', Response::MODEL_MESSAGE)
->param('messageId', '', new CustomId(), 'Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('messageId', '', new CustomId(), 'Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY)), 'List of Topic IDs or List of User IDs or List of Target IDs.') ->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs or List of User IDs or List of Target IDs.')
->param('title', '', new Text(256), 'Title for push notification.') ->param('title', '', new Text(256), 'Title for push notification.')
->param('body', '', new Text(64230), 'Body for push notification.') ->param('body', '', new Text(64230), 'Body for push notification.')
->param('description', '', new Text(256), 'Description for Message.', true) ->param('description', '', new Text(256), 'Description for Message.', true)
@ -1878,7 +1878,7 @@ App::patch('/v1/messaging/messages/email/:messageId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_MESSAGE) ->label('sdk.response.model', Response::MODEL_MESSAGE)
->param('messageId', '', new UID(), 'Message ID.') ->param('messageId', '', new UID(), 'Message ID.')
->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY)), 'List of Topic IDs or List of User IDs or List of Target IDs.', true) ->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs or List of User IDs or List of Target IDs.', true)
->param('subject', '', new Text(998), 'Email Subject.', true) ->param('subject', '', new Text(998), 'Email Subject.', true)
->param('description', '', new Text(256), 'Description for Message.', true) ->param('description', '', new Text(256), 'Description for Message.', true)
->param('content', '', new Text(64230), 'Email Content.', true) ->param('content', '', new Text(64230), 'Email Content.', true)
@ -1965,7 +1965,7 @@ App::patch('/v1/messaging/messages/sms/:messageId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_MESSAGE) ->label('sdk.response.model', Response::MODEL_MESSAGE)
->param('messageId', '', new UID(), 'Message ID.') ->param('messageId', '', new UID(), 'Message ID.')
->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY)), 'List of Topic IDs or List of User IDs or List of Target IDs.', true) ->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs or List of User IDs or List of Target IDs.', true)
->param('description', '', new Text(256), 'Description for Message.', true) ->param('description', '', new Text(256), 'Description for Message.', true)
->param('content', '', new Text(64230), 'Email Content.', 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) ->param('status', '', new WhiteList(['draft', 'processing']), 'Message Status. Value must be either draft or processing.', true)
@ -2042,7 +2042,7 @@ App::patch('/v1/messaging/messages/push/:messageId')
->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_MESSAGE) ->label('sdk.response.model', Response::MODEL_MESSAGE)
->param('messageId', '', new UID(), 'Message ID.') ->param('messageId', '', new UID(), 'Message ID.')
->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY)), 'List of Topic IDs or List of User IDs or List of Target IDs.', true) ->param('to', [], new ArrayList(new Text(Database::LENGTH_KEY), 1), 'List of Topic IDs or List of User IDs or List of Target IDs.', true)
->param('description', '', new Text(256), 'Description for Message.', true) ->param('description', '', new Text(256), 'Description for Message.', true)
->param('title', '', new Text(256), 'Title for push notification.', true) ->param('title', '', new Text(256), 'Title for push notification.', true)
->param('body', '', new Text(64230), 'Body for push notification.', true) ->param('body', '', new Text(64230), 'Body for push notification.', true)

View file

@ -72,11 +72,6 @@ class Messaging extends Action
{ {
$recipientsId = $message->getAttribute('to', []); $recipientsId = $message->getAttribute('to', []);
if (\count($recipientsId) < 1) {
Console::error('Recipients not found');
return;
}
/** /**
* @var Document[] $recipients * @var Document[] $recipients
*/ */