Provides Google Chat integration for Symfony Notifier. Allowing the thread key to be setup at the notification
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)
<?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());
}
}