Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"require-dev": {
"phpunit/phpunit": "9.6.*",
"phpmailer/phpmailer": "6.8.*",
"laravel/pint": "^1.2"
"laravel/pint": "1.13.*"
},
"config": {
"platform": {
Expand Down
30 changes: 15 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions src/Utopia/Messaging/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,21 @@ abstract class Adapter
{
/**
* Get the name of the adapter.
*
* @return string
*/
abstract public function getName(): string;

/**
* Get the type of the adapter.
*
* @return string
*/
abstract public function getType(): string;

/**
* Get the type of the message the adapter can send.
*
* @return string
*/
abstract public function getMessageType(): string;

/**
* Get the maximum number of messages that can be sent in a single request.
*
* @return int
*/
abstract public function getMaxMessagesPerRequest(): int;

Expand All @@ -55,7 +47,7 @@ protected function request(
string $method,
string $url,
array $headers = [],
?string $body = null,
string $body = null,
): string {
$ch = \curl_init();

Expand Down
4 changes: 0 additions & 4 deletions src/Utopia/Messaging/Adapters/Email/Mailgun.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public function __construct(

/**
* Get adapter name.
*
* @return string
*/
public function getName(): string
{
Expand All @@ -30,8 +28,6 @@ public function getName(): string

/**
* Get adapter description.
*
* @return int
*/
public function getMaxMessagesPerRequest(): int
{
Expand Down
6 changes: 0 additions & 6 deletions src/Utopia/Messaging/Adapters/Email/Sendgrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public function __construct(private string $apiKey)

/**
* Get adapter name.
*
* @return string
*/
public function getName(): string
{
Expand All @@ -27,8 +25,6 @@ public function getName(): string

/**
* Get max messages per request.
*
* @return int
*/
public function getMaxMessagesPerRequest(): int
{
Expand All @@ -38,8 +34,6 @@ public function getMaxMessagesPerRequest(): int
/**
* {@inheritdoc}
*
* @param Email $message
* @return string
*
* @throws Exception
*/
Expand Down
29 changes: 11 additions & 18 deletions src/Utopia/Messaging/Adapters/Push/APNS.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,19 @@
class APNS extends PushAdapter
{
/**
* @param string $authKey
* @param string $authKeyId
* @param string $teamId
* @param string $bundleId
* @param string $endpoint
* @return void
*/
public function __construct(
private string $authKey,
private string $authKeyId,
private string $teamId,
private string $bundleId,
private string $endpoint
private string $authKey,
private string $authKeyId,
private string $teamId,
private string $bundleId,
private bool $sandbox = false
) {
}

/**
* Get adapter name.
*
* @return string
*/
public function getName(): string
{
Expand All @@ -37,8 +30,6 @@ public function getName(): string

/**
* Get max messages per request.
*
* @return int
*/
public function getMaxMessagesPerRequest(): int
{
Expand All @@ -48,8 +39,6 @@ public function getMaxMessagesPerRequest(): int
/**
* {@inheritdoc}
*
* @param Push $message
* @return string
*
* @throws Exception
*/
Expand Down Expand Up @@ -98,13 +87,18 @@ private function notify(array $to, array $payload): array
]);

$response = '';
$endpoint = 'https://api.push.apple.com';

if ($this->sandbox) {
$endpoint = 'https://api.development.push.apple.com';
}

$mh = curl_multi_init();
$handles = [];

// Create a handle for each request
foreach ($to as $token) {
curl_setopt($ch, CURLOPT_URL, $this->endpoint.'/3/device/'.$token);
curl_setopt($ch, CURLOPT_URL, $endpoint.'/3/device/'.$token);

$handle = curl_copy_handle($ch);
curl_multi_add_handle($mh, $handle);
Expand Down Expand Up @@ -179,7 +173,6 @@ function ($value) {
/**
* Generate JWT.
*
* @return string
*
* @throws Exception
*/
Expand Down
4 changes: 0 additions & 4 deletions src/Utopia/Messaging/Adapters/Push/FCM.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public function __construct(

/**
* Get adapter name.
*
* @return string
*/
public function getName(): string
{
Expand All @@ -27,8 +25,6 @@ public function getName(): string

/**
* Get max messages per request.
*
* @return int
*/
public function getMaxMessagesPerRequest(): int
{
Expand Down
18 changes: 0 additions & 18 deletions src/Utopia/Messaging/Messages/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,31 @@ public function __construct(
) {
}

/**
* @return array
*/
public function getTo(): array
{
return $this->to;
}

/**
* @return string
*/
public function getSubject(): string
{
return $this->subject;
}

/**
* @return string
*/
public function getContent(): string
{
return $this->content;
}

/**
* @return string|null
*/
public function getFrom(): ?string
{
return $this->from;
}

/**
* @return array|null
*/
public function getAttachments(): ?array
{
return $this->attachments;
}

/**
* @return bool
*/
public function isHtml(): bool
{
return $this->html;
Expand Down
30 changes: 0 additions & 30 deletions src/Utopia/Messaging/Messages/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ public function __construct(
) {
}

/**
* @return array
*/
public function getTo(): array
{
return $this->to;
Expand All @@ -45,73 +42,46 @@ public function getFrom(): ?string
return null;
}

/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
}

/**
* @return string
*/
public function getBody(): string
{
return $this->body;
}

/**
* @return array|null
*/
public function getData(): ?array
{
return $this->data;
}

/**
* @return string|null
*/
public function getAction(): ?string
{
return $this->action;
}

/**
* @return string|null
*/
public function getSound(): ?string
{
return $this->sound;
}

/**
* @return string|null
*/
public function getIcon(): ?string
{
return $this->icon;
}

/**
* @return string|null
*/
public function getColor(): ?string
{
return $this->color;
}

/**
* @return string|null
*/
public function getTag(): ?string
{
return $this->tag;
}

/**
* @return string|null
*/
public function getBadge(): ?string
{
return $this->badge;
Expand Down
Loading