Skip to content

Commit

Permalink
Add support for delaying messages
Browse files Browse the repository at this point in the history
  • Loading branch information
VerifiedJoseph committed Dec 14, 2021
1 parent bb5e6ea commit 8974a7b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Ntfy/Ntfy.php
Expand Up @@ -62,14 +62,16 @@ function __construct(Server $server)
* @param string $title Message title
* @param int $priority Message priority
* @param string $tags Message tags
* @param string|int $delay Delay sending message for or until a time.
*
* @return stdClass
*
* @see https://ntfy.sh/docs/publish/ Sending messages
* @see https://ntfy.sh/docs/publish/#message-priority Message priority levels
* @see https://ntfy.sh/docs/publish/#tags-emojis Message tags & emojis
* @see https://ntfy.sh/docs/publish/#scheduled-delivery Scheduled (delayed) delivery of messages
*/
public function send(string $topic, string $message, $title = '', int $priority = 3, string $tags = ''): stdClass
public function send(string $topic, string $message, $title = '', int $priority = 3, string $tags = '', string|int $delay = ''): stdClass
{
$headers = array();
$headers['Priority'] = $priority;
Expand All @@ -82,6 +84,10 @@ public function send(string $topic, string $message, $title = '', int $priority
$headers['Tags'] = $tags;
}

if (empty($delay) === false) {
$headers['Delay'] = $delay;
}

$response = $this->guzzle->post($topic, $message, $headers);
$message = Json::decode($response->getBody());

Expand Down

0 comments on commit 8974a7b

Please sign in to comment.