Skip to content

Commit

Permalink
bug #45290 [Notifier] fix Microsoft Teams webhook url (christophkoenig)
Browse files Browse the repository at this point in the history
This PR was merged into the 5.4 branch.

Discussion
----------

[Notifier] fix Microsoft Teams webhook url

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Incoming webhooks for Microsoft Teams require a new webhook URL format as described in [this post](https://office365itpros.com/2021/02/03/new-format-webhook-url/) which references Office 365 Notification MC234048.

The old format is no longer supported since April 11, 2021 so I replaced it completely.

Commits
-------

9f7909b [Notifier] fix Microsoft Teams webhook url
  • Loading branch information
fabpot committed Feb 2, 2022
2 parents d7da823 + 9f7909b commit b400f80
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public function getRecipientId(): ?string
*/
public function recipient(string $path): self
{
if (!preg_match('/^\/webhook\//', $path)) {
throw new InvalidArgumentException(sprintf('"%s" require recipient id format to be "/webhook/{uuid}@{uuid}/IncomingWebhook/{id}/{uuid}", "%s" given.', __CLASS__, $path));
if (!preg_match('/^\/webhookb2\//', $path)) {
throw new InvalidArgumentException(sprintf('"%s" require recipient id format to be "/webhookb2/{uuid}@{uuid}/IncomingWebhook/{id}/{uuid}", "%s" given.', __CLASS__, $path));
}

$this->options['recipient_id'] = $path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MICROSOFT_TEAMS_DSN=microsoftteams://default/PATH
```

where:
- `PATH` has the following format: `webhook/{uuid}@{uuid}/IncomingWebhook/{id}/{uuid}`
- `PATH` has the following format: `webhookb2/{uuid}@{uuid}/IncomingWebhook/{id}/{uuid}`

Resources
---------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testFromNotification()
public function testGetRecipientIdReturnsRecipientWhenSetViaConstructor()
{
$options = new MicrosoftTeamsOptions([
'recipient_id' => $recipient = '/webhook/foo',
'recipient_id' => $recipient = '/webhookb2/foo',
]);

$this->assertSame($recipient, $options->getRecipientId());
Expand All @@ -39,7 +39,7 @@ public function testGetRecipientIdReturnsRecipientWhenSetViaConstructor()
public function testGetRecipientIdReturnsRecipientWhenSetSetter()
{
$options = (new MicrosoftTeamsOptions())
->recipient($recipient = '/webhook/foo');
->recipient($recipient = '/webhookb2/foo');

$this->assertSame($recipient, $options->getRecipientId());
}
Expand All @@ -58,7 +58,7 @@ public function testRecipientMethodThrowsIfValueDoesNotMatchRegex()
$recipient = 'foo';

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(sprintf('"%s" require recipient id format to be "/webhook/{uuid}@{uuid}/IncomingWebhook/{id}/{uuid}", "%s" given.', MicrosoftTeamsOptions::class, $recipient));
$this->expectExceptionMessage(sprintf('"%s" require recipient id format to be "/webhookb2/{uuid}@{uuid}/IncomingWebhook/{id}/{uuid}", "%s" given.', MicrosoftTeamsOptions::class, $recipient));

$options->recipient($recipient);
}
Expand Down

0 comments on commit b400f80

Please sign in to comment.