Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Google Chat notifications not work properly with threads #57323

Copy link
Copy link
Closed
@deoomen

Description

@deoomen
Issue body actions

Symfony version(s) affected

7.0.8

Description

Hey.

I know. Nobody use Google Chat :D
When using Notifier component with Google Chat as notification channel there is a problem when you want to send messages into thread. Currently in transport implementation (GoogleChatTransport.php) the threadKey is added in URL. That options is deprecated (https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/create?hl=en). Also if you want to send message into thread you also must define a messageReplyOption that is missing in current implementation.

So even if you define a threadKey, messages will be always sent to as new thread.

How to reproduce

Fragment of my code:

use Symfony\Component\Notifier\Bridge\GoogleChat\GoogleChatOptions;
use Symfony\Component\Notifier\ChatterInterface;
use Symfony\Component\Notifier\Message\ChatMessage;
use Symfony\Component\Notifier\Notification\Notification;

class SendNotificationToGoogleChat
{
    public function __construct(
        private ChatterInterface $chatter,
    ) {
    }

    public function send(): void
    {
        $subject = 'Topic';
        $content = 'Message';
        $notification = (new Notification($subject, ['chat/google']))->content($content);
        $options = (new GoogleChatOptions(GoogleChatOptions::fromNotification($notification)->toArray()));
        $options->setThreadKey('threadKey');
        $message = ChatMessage::fromNotification($notification)->options($options);

        $this->chatter->send($message);
    }
}

Possible Solution

I see three possible solutions.

  1. Just add &messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD to $url in GoogleChatTransport if threadKey is defined.
  2. Add to GoogleChatOptions property with messageReplyOption that user can define for his own.
  3. Also refactor deprecated code. Removes threadKey from $url and add it in body like documentation says.

Additional Context

I also have ready and tested fix so I can send a PR but didn't sure for which versions in should be. If you help me with this I can add a PR with my changes for review.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.