komujohn / google-chat-notifier
Symfony Google Chat Notifier Bridge
Installs: 38
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 5
Type:symfony-bridge
Requires
- php: >=7.2.5
- symfony/http-client: ^4.3|^5.0
- symfony/notifier: ~5.2.2
This package is not auto-updated.
Last update: 2024-05-06 20:35:36 UTC
README
Provides Google Chat integration for Symfony Notifier. Allowing the thread key to be setup at the notification
DSN example
GOOGLE_CHAT_DSN=googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?thread_key=THREAD_KEY
where:
ACCESS_KEY
is your Google Chat access keyACCESS_TOKEN
is your Google Chat access tokenSPACE
is the Google Chat spaceTHREAD_KEY
is the Google Chat message thread to group messages into a single thread (optional)
Code Example
<?php
namespace App\Service;
use Symfony\Component\Notifier\Bridge\GoogleChat\ThreadNotification;
use Symfony\Component\Notifier\Notification\Notification;
use Symfony\Component\Notifier\NotifierInterface;
use Symfony\Component\Notifier\Recipient\NoRecipient;
class NotificationHelper {
private NotifierInterface $notifier;
public function __construct( NotifierInterface $notifier ) {
$this->notifier = $notifier;
}
public function sendNotification($subject,$message,$thread_key='general5'){
$notification = (new ThreadNotification())
->subject($subject)
->content($message)
->thread($thread_key)
->importance(Notification::IMPORTANCE_HIGH);
$this->notifier->send($notification, new NoRecipient());
}
}