Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit21c4768

Browse files
OskarStarkfabpot
authored andcommitted
[Notifier][Discord] Make webhookId argument required
1 parent9052b2b commit21c4768

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

‎src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class DiscordTransport extends AbstractTransport
3232
private$token;
3333
private$webhookId;
3434

35-
publicfunction__construct(string$token,string$webhookId =null,HttpClientInterface$client =null,EventDispatcherInterface$dispatcher =null)
35+
publicfunction__construct(string$token,string$webhookId,HttpClientInterface$client =null,EventDispatcherInterface$dispatcher =null)
3636
{
3737
$this->token =$token;
3838
$this->webhookId =$webhookId;

‎src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransportFactory.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespaceSymfony\Component\Notifier\Bridge\Discord;
1313

14+
useSymfony\Component\Notifier\Exception\IncompleteDsnException;
1415
useSymfony\Component\Notifier\Exception\UnsupportedSchemeException;
1516
useSymfony\Component\Notifier\Transport\AbstractTransportFactory;
1617
useSymfony\Component\Notifier\Transport\Dsn;
@@ -31,6 +32,11 @@ public function create(Dsn $dsn): TransportInterface
3132
$scheme =$dsn->getScheme();
3233
$token =$this->getUser($dsn);
3334
$webhookId =$dsn->getOption('webhook_id');
35+
36+
if (!$webhookId) {
37+
thrownewIncompleteDsnException('Missing webhook_id.',$dsn->getOriginalDsn());
38+
}
39+
3440
$host ='default' ===$dsn->getHost() ?null :$dsn->getHost();
3541
$port =$dsn->getPort();
3642

‎src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportFactoryTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ public function testCreateWithDsn()
3131
$this->assertSame(sprintf('discord://%s?webhook_id=%s',$host,$webhookId), (string)$transport);
3232
}
3333

34+
publicfunctiontestCreateWithNoWebhookIdThrowsMalformed():void
35+
{
36+
$factory =newDiscordTransportFactory();
37+
38+
$this->expectException(IncompleteDsnException::class);
39+
40+
$factory->create(Dsn::fromString('discord://token@host'));
41+
}
42+
3443
publicfunctiontestCreateWithNoTokenThrowsMalformed()
3544
{
3645
$factory =newDiscordTransportFactory();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp