fix: tolerate malformed telegram callbacks, constrain channel id
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
@@ -49,6 +49,8 @@ class ChannelsApiTest extends TestCase
|
||||
$this->getJson('/me', ['X-Remote-User' => 'other']);
|
||||
$foreign = Channel::create(['user_id' => User::where('login', 'other')->sole()->id, 'type' => ChannelType::Webhook, 'config' => ['deliver_url' => 'u', 'presence_url' => 'p'], 'enabled' => true]);
|
||||
$this->deleteJson('/me/channels/'.$foreign->id, [], $this->as)->assertNotFound();
|
||||
|
||||
$this->deleteJson('/me/channels/abc', [], $this->as)->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_telegram_link_code(): void
|
||||
|
||||
@@ -96,4 +96,12 @@ class TelegramWebhookTest extends TestCase
|
||||
{
|
||||
$this->postJson('/hooks/telegram', ['edited_message' => ['chat' => ['id' => 1]]], $this->secret())->assertNoContent();
|
||||
}
|
||||
|
||||
public function test_malformed_callback_is_ignored(): void
|
||||
{
|
||||
$this->postJson('/hooks/telegram', ['callback_query' => ['data' => 'ack:nope']], $this->secret())->assertNoContent();
|
||||
|
||||
$this->postJson('/hooks/telegram', ['callback_query' => ['id' => 'x', 'data' => 'garbage']], $this->secret())->assertNoContent();
|
||||
Http::assertSent(fn (Request $r) => str_ends_with($r->url(), '/answerCallbackQuery') && $r['text'] === 'Уже неактуально');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user