Add providerType
to Message
This commit is contained in:
parent
82c86c0ae2
commit
4b58d08fd8
5 changed files with 57 additions and 58 deletions
|
@ -1505,6 +1505,17 @@ $commonCollections = [
|
|||
'$id' => ID::custom('messages'),
|
||||
'name' => 'Messages',
|
||||
'attributes' => [
|
||||
[
|
||||
'$id' => ID::custom('providerType'),
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
'signed' => true,
|
||||
'required' => true,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('description'),
|
||||
'type' => Database::VAR_STRING,
|
||||
|
|
|
@ -2240,6 +2240,7 @@ App::post('/v1/messaging/messages/email')
|
|||
|
||||
$message = $dbForProject->createDocument('messages', new Document([
|
||||
'$id' => $messageId,
|
||||
'providerType' => MESSAGE_TYPE_EMAIL,
|
||||
'topics' => $topics,
|
||||
'users' => $users,
|
||||
'targets' => $targets,
|
||||
|
@ -2303,6 +2304,7 @@ App::post('/v1/messaging/messages/sms')
|
|||
|
||||
$message = $dbForProject->createDocument('messages', new Document([
|
||||
'$id' => $messageId,
|
||||
'providerType' => MESSAGE_TYPE_SMS,
|
||||
'topics' => $topics,
|
||||
'users' => $users,
|
||||
'targets' => $targets,
|
||||
|
@ -2370,41 +2372,19 @@ App::post('/v1/messaging/messages/push')
|
|||
throw new Exception(Exception::MESSAGE_MISSING_TARGET);
|
||||
}
|
||||
|
||||
$pushData = [
|
||||
'title' => $title,
|
||||
'body' => $body,
|
||||
];
|
||||
$pushData = [];
|
||||
|
||||
if (!is_null($data)) {
|
||||
$pushData['data'] = $data;
|
||||
}
|
||||
$keys = ['title', 'body', 'data', 'action', 'icon', 'sound', 'color', 'tag', 'badge'];
|
||||
|
||||
if ($action) {
|
||||
$pushData['action'] = $action;
|
||||
}
|
||||
|
||||
if ($icon) {
|
||||
$pushData['icon'] = $icon;
|
||||
}
|
||||
|
||||
if ($sound) {
|
||||
$pushData['sound'] = $sound;
|
||||
}
|
||||
|
||||
if ($color) {
|
||||
$pushData['color'] = $color;
|
||||
}
|
||||
|
||||
if ($tag) {
|
||||
$pushData['tag'] = $tag;
|
||||
}
|
||||
|
||||
if ($badge) {
|
||||
$pushData['badge'] = $badge;
|
||||
foreach ($keys as $key) {
|
||||
if (!empty($$key)) {
|
||||
$pushData[$key] = $$key;
|
||||
}
|
||||
}
|
||||
|
||||
$message = $dbForProject->createDocument('messages', new Document([
|
||||
'$id' => $messageId,
|
||||
'providerType' => MESSAGE_TYPE_PUSH,
|
||||
'topics' => $topics,
|
||||
'users' => $users,
|
||||
'targets' => $targets,
|
||||
|
|
|
@ -11,7 +11,7 @@ class Messaging extends Event
|
|||
protected ?string $messageId = null;
|
||||
protected ?Document $message = null;
|
||||
protected ?array $recipients = null;
|
||||
protected ?string $deliveryTime = null;
|
||||
protected ?string $scheduledAt = null;
|
||||
protected ?string $providerType = null;
|
||||
|
||||
|
||||
|
@ -117,14 +117,14 @@ class Messaging extends Event
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets Delivery time for the messaging event.
|
||||
* Sets Scheduled delivery time for the messaging event.
|
||||
*
|
||||
* @param string $deliveryTime
|
||||
* @param string $scheduledAt
|
||||
* @return self
|
||||
*/
|
||||
public function setDeliveryTime(string $deliveryTime): self
|
||||
public function setScheduledAt(string $scheduledAt): self
|
||||
{
|
||||
$this->deliveryTime = $deliveryTime;
|
||||
$this->scheduledAt = $scheduledAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -134,9 +134,9 @@ class Messaging extends Event
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDeliveryTime(): string
|
||||
public function getScheduledAt(): string
|
||||
{
|
||||
return $this->deliveryTime;
|
||||
return $this->scheduledAt;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -29,6 +29,12 @@ class Message extends Any
|
|||
'default' => '',
|
||||
'example' => self::TYPE_DATETIME_EXAMPLE,
|
||||
])
|
||||
->addRule('providerType', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Message provider type.',
|
||||
'default' => '',
|
||||
'example' => MESSAGE_TYPE_EMAIL,
|
||||
])
|
||||
->addRule('topics', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Topic IDs set as recipients.',
|
||||
|
@ -50,7 +56,7 @@ class Message extends Any
|
|||
'array' => true,
|
||||
'example' => ['5e5ea5c16897e'],
|
||||
])
|
||||
->addRule('deliveryTime', [
|
||||
->addRule('scheduledAt', [
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => 'The scheduled time for message.',
|
||||
'required' => false,
|
||||
|
|
|
@ -2098,13 +2098,13 @@ trait Base
|
|||
}
|
||||
}';
|
||||
case self::$CREATE_EMAIL:
|
||||
return 'mutation createEmail($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $subject: String!, $content: String!, $status: String, $description: String, $html: Boolean, $deliveryTime: String) {
|
||||
messagingCreateEmail(messageId: $messageId, topics: $topics, users: $users, targets: $targets, subject: $subject, content: $content, status: $status, description: $description, html: $html, deliveryTime: $deliveryTime) {
|
||||
return 'mutation createEmail($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $subject: String!, $content: String!, $status: String, $description: String, $html: Boolean, $scheduledAt: String) {
|
||||
messagingCreateEmail(messageId: $messageId, topics: $topics, users: $users, targets: $targets, subject: $subject, content: $content, status: $status, description: $description, html: $html, scheduledAt: $scheduledAt) {
|
||||
_id
|
||||
topics
|
||||
users
|
||||
targets
|
||||
deliveryTime
|
||||
scheduledAt
|
||||
deliveredAt
|
||||
deliveryErrors
|
||||
deliveredTotal
|
||||
|
@ -2113,13 +2113,13 @@ trait Base
|
|||
}
|
||||
}';
|
||||
case self::$CREATE_SMS:
|
||||
return 'mutation createSMS($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $content: String!, $status: String, $description: String, $deliveryTime: String) {
|
||||
messagingCreateSMS(messageId: $messageId, topics: $topics, users: $users, targets: $targets, content: $content, status: $status, description: $description, deliveryTime: $deliveryTime) {
|
||||
return 'mutation createSMS($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $content: String!, $status: String, $description: String, $scheduledAt: String) {
|
||||
messagingCreateSMS(messageId: $messageId, topics: $topics, users: $users, targets: $targets, content: $content, status: $status, description: $description, scheduledAt: $scheduledAt) {
|
||||
_id
|
||||
topics
|
||||
users
|
||||
targets
|
||||
deliveryTime
|
||||
scheduledAt
|
||||
deliveredAt
|
||||
deliveryErrors
|
||||
deliveredTotal
|
||||
|
@ -2128,13 +2128,13 @@ trait Base
|
|||
}
|
||||
}';
|
||||
case self::$CREATE_PUSH_NOTIFICATION:
|
||||
return 'mutation createPushNotification($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $title: String!, $body: String!, $data: Json, $action: String, $icon: String, $sound: String, $color: String, $tag: String, $badge: String, $status: String, $description: String, $deliveryTime: String) {
|
||||
messagingCreatePushNotification(messageId: $messageId, topics: $topics, users: $users, targets: $targets, title: $title, body: $body, data: $data, action: $action, icon: $icon, sound: $sound, color: $color, tag: $tag, badge: $badge, status: $status, description: $description, deliveryTime: $deliveryTime) {
|
||||
return 'mutation createPushNotification($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $title: String!, $body: String!, $data: Json, $action: String, $icon: String, $sound: String, $color: String, $tag: String, $badge: String, $status: String, $description: String, $scheduledAt: String) {
|
||||
messagingCreatePushNotification(messageId: $messageId, topics: $topics, users: $users, targets: $targets, title: $title, body: $body, data: $data, action: $action, icon: $icon, sound: $sound, color: $color, tag: $tag, badge: $badge, status: $status, description: $description, scheduledAt: $scheduledAt) {
|
||||
_id
|
||||
topics
|
||||
users
|
||||
targets
|
||||
deliveryTime
|
||||
scheduledAt
|
||||
deliveredAt
|
||||
deliveryErrors
|
||||
deliveredTotal
|
||||
|
@ -2148,10 +2148,11 @@ trait Base
|
|||
total
|
||||
messages {
|
||||
_id
|
||||
providerType
|
||||
topics
|
||||
users
|
||||
targets
|
||||
deliveryTime
|
||||
scheduledAt
|
||||
deliveredAt
|
||||
deliveryErrors
|
||||
deliveredTotal
|
||||
|
@ -2164,10 +2165,11 @@ trait Base
|
|||
return 'query getMessage($messageId: String!) {
|
||||
messagingGetMessage(messageId: $messageId) {
|
||||
_id
|
||||
providerType
|
||||
topics
|
||||
users
|
||||
targets
|
||||
deliveryTime
|
||||
scheduledAt
|
||||
deliveredAt
|
||||
deliveryErrors
|
||||
deliveredTotal
|
||||
|
@ -2176,13 +2178,13 @@ trait Base
|
|||
}
|
||||
}';
|
||||
case self::$UPDATE_EMAIL:
|
||||
return 'mutation updateEmail($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $subject: String, $content: String, $status: String, $description: String, $html: Boolean, $deliveryTime: String) {
|
||||
messagingUpdateEmail(messageId: $messageId, topics: $topics, users: $users, targets: $targets, subject: $subject, content: $content, status: $status, description: $description, html: $html, deliveryTime: $deliveryTime) {
|
||||
return 'mutation updateEmail($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $subject: String, $content: String, $status: String, $description: String, $html: Boolean, $scheduledAt: String) {
|
||||
messagingUpdateEmail(messageId: $messageId, topics: $topics, users: $users, targets: $targets, subject: $subject, content: $content, status: $status, description: $description, html: $html, scheduledAt: $scheduledAt) {
|
||||
_id
|
||||
topics
|
||||
users
|
||||
targets
|
||||
deliveryTime
|
||||
scheduledAt
|
||||
deliveredAt
|
||||
deliveryErrors
|
||||
deliveredTotal
|
||||
|
@ -2191,13 +2193,13 @@ trait Base
|
|||
}
|
||||
}';
|
||||
case self::$UPDATE_SMS:
|
||||
return 'mutation updateSMS($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $content: String, $status: String, $description: String, $deliveryTime: String) {
|
||||
messagingUpdateSMS(messageId: $messageId, topics: $topics, users: $users, targets: $targets, content: $content, status: $status, description: $description, deliveryTime: $deliveryTime) {
|
||||
return 'mutation updateSMS($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $content: String, $status: String, $description: String, $scheduledAt: String) {
|
||||
messagingUpdateSMS(messageId: $messageId, topics: $topics, users: $users, targets: $targets, content: $content, status: $status, description: $description, scheduledAt: $scheduledAt) {
|
||||
_id
|
||||
topics
|
||||
users
|
||||
targets
|
||||
deliveryTime
|
||||
scheduledAt
|
||||
deliveredAt
|
||||
deliveryErrors
|
||||
deliveredTotal
|
||||
|
@ -2206,13 +2208,13 @@ trait Base
|
|||
}
|
||||
}';
|
||||
case self::$UPDATE_PUSH_NOTIFICATION:
|
||||
return 'mutation updatePushNotification($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $title: String, $body: String, $data: Json, $action: String, $icon: String, $sound: String, $color: String, $tag: String, $badge: String, $status: String, $description: String, $deliveryTime: String) {
|
||||
messagingUpdatePushNotification(messageId: $messageId, topics: $topics, users: $users, targets: $targets, title: $title, body: $body, data: $data, action: $action, icon: $icon, sound: $sound, color: $color, tag: $tag, badge: $badge, status: $status, description: $description, deliveryTime: $deliveryTime) {
|
||||
return 'mutation updatePushNotification($messageId: String!, $topics: [String!], $users: [String!], $targets: [String!], $title: String, $body: String, $data: Json, $action: String, $icon: String, $sound: String, $color: String, $tag: String, $badge: String, $status: String, $description: String, $scheduledAt: String) {
|
||||
messagingUpdatePushNotification(messageId: $messageId, topics: $topics, users: $users, targets: $targets, title: $title, body: $body, data: $data, action: $action, icon: $icon, sound: $sound, color: $color, tag: $tag, badge: $badge, status: $status, description: $description, scheduledAt: $scheduledAt) {
|
||||
_id
|
||||
topics
|
||||
users
|
||||
targets
|
||||
deliveryTime
|
||||
scheduledAt
|
||||
deliveredAt
|
||||
deliveryErrors
|
||||
deliveredTotal
|
||||
|
@ -2472,7 +2474,7 @@ trait Base
|
|||
protected string $stdout = '';
|
||||
protected string $stderr = '';
|
||||
|
||||
protected function packageCode($folder)
|
||||
protected function packageCode($folder): void
|
||||
{
|
||||
Console::execute('cd ' . realpath(__DIR__ . "/../../../resources/functions") . "/$folder && tar --exclude code.tar.gz -czf code.tar.gz .", '', $this->stdout, $this->stderr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue