Updates deps
Adds message builders to messaging worker Adds Makefile to .gitignore ;)
This commit is contained in:
parent
55d00d9afa
commit
3e7805afe1
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,3 +13,4 @@ debug/
|
|||
app/sdks
|
||||
dev/yasd_init.php
|
||||
.phpunit.result.cache
|
||||
Makefile
|
||||
|
|
|
@ -97,16 +97,67 @@ class MessagingV1 extends Worker
|
|||
// call function passing needed credentials returns required provider.
|
||||
|
||||
$messageId = $this->args['messageId'];
|
||||
$message =
|
||||
$this
|
||||
->getConsoleDB()
|
||||
->getDocument('messages', $messageId);
|
||||
$messageRecord =
|
||||
$this
|
||||
->getConsoleDB()
|
||||
->getDocument('messages', $messageId);
|
||||
|
||||
// Contrust Message Object according to each provider type.
|
||||
// Send the message using respective adapter
|
||||
$message = match ($providerRecord->getAttribute('type')) {
|
||||
'sms' => $this->buildSMSMessage($messageRecord->getArrayCopy()),
|
||||
'push' => $this->buildPushMessage($messageRecord->getArrayCopy()),
|
||||
'email' => $this->buildEmailMessage($messageRecord->getArrayCopy()),
|
||||
default => null
|
||||
};
|
||||
|
||||
|
||||
$provider->send($message);
|
||||
}
|
||||
|
||||
public function shutdown(): void
|
||||
{
|
||||
}
|
||||
|
||||
private function buildEmailMessage($data): array
|
||||
{
|
||||
$from = $data['from'];
|
||||
$to = $data['to'];
|
||||
$subject = $data['subject'];
|
||||
$body = $data['content'];
|
||||
|
||||
return [
|
||||
'from' => $from,
|
||||
'to' => $to,
|
||||
'subject' => $subject,
|
||||
'body' => $body,
|
||||
];
|
||||
return $message;
|
||||
}
|
||||
|
||||
private function buildSMSMessage($data): array
|
||||
{
|
||||
$from = $data['from'];
|
||||
$to = $data['to'];
|
||||
$body = $data['content'];
|
||||
|
||||
return [
|
||||
'from' => $from,
|
||||
'to' => $to,
|
||||
'body' => $body
|
||||
];
|
||||
}
|
||||
|
||||
private function buildPushMessage($data): array
|
||||
{
|
||||
$to = $data['to'];
|
||||
$title = $data['title'];
|
||||
$body = $data['body'];
|
||||
$data = $data['data'];
|
||||
|
||||
return [
|
||||
'to' => $to,
|
||||
'title' => $title,
|
||||
'body' => $body,
|
||||
'data' => $data
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
13
composer.lock
generated
13
composer.lock
generated
|
@ -1557,19 +1557,20 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "0.42.2",
|
||||
"version": "0.42.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "bc5ceb30c85fb685b0b5704d2f74886d813ebd41"
|
||||
"reference": "ab0e2f8ad46884f69b354cd8ee84a1a75fee26d1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/bc5ceb30c85fb685b0b5704d2f74886d813ebd41",
|
||||
"reference": "bc5ceb30c85fb685b0b5704d2f74886d813ebd41",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/ab0e2f8ad46884f69b354cd8ee84a1a75fee26d1",
|
||||
"reference": "ab0e2f8ad46884f69b354cd8ee84a1a75fee26d1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"ext-pdo": "*",
|
||||
"php": ">=8.0",
|
||||
"utopia-php/cache": "0.8.*",
|
||||
|
@ -1607,9 +1608,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/0.42.2"
|
||||
"source": "https://github.com/utopia-php/database/tree/0.42.3"
|
||||
},
|
||||
"time": "2023-08-17T19:04:37+00:00"
|
||||
"time": "2023-08-22T02:15:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/domains",
|
||||
|
|
Loading…
Reference in a new issue