Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Laravel Octane #11

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/NutgramServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use Nutgram\Laravel\RunningMode\LaravelWebhook;
use Psr\Log\LoggerInterface;
use SergiX44\Nutgram\Configuration;
use SergiX44\Nutgram\Nutgram;
use SergiX44\Nutgram\RunningMode\Polling;
use SergiX44\Nutgram\RunningMode\Webhook;
use SergiX44\Nutgram\Telegram\Types\Media\File;
use SergiX44\Nutgram\Testing\FakeNutgram;

Expand Down Expand Up @@ -55,10 +55,10 @@ public function register()
if ($app->runningInConsole()) {
$bot->setRunningMode(Polling::class);
} else {
$webhook = Webhook::class;
$webhook = LaravelWebhook::class;
if (config('nutgram.safe_mode', false)) {
// take into account the trust proxy Laravel configuration
$webhook = new Webhook(fn () => $app->make('request')?->ip());
$webhook = new LaravelWebhook(fn () => $app->make('request')?->ip());
}

$bot->setRunningMode($webhook);
Expand Down
13 changes: 13 additions & 0 deletions src/RunningMode/LaravelWebhook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Nutgram\Laravel\RunningMode;

use SergiX44\Nutgram\RunningMode\Webhook;

class LaravelWebhook extends Webhook
{
protected function input(): ?string
{
return request()?->getContent();
}
}