laravel-notification-channels / webhook

Webhook notifications channel for Laravel
https://laravel-notification-channels.com
MIT License
170 stars 61 forks source link

query() error? #33

Closed lachlanhickey closed 4 years ago

lachlanhickey commented 4 years ago

Any reason why I can't use query params?

Symfony\\Component\\Debug\\Exception\\FatalThrowableError: Call to undefined method NotificationChannels\\Webhook\\WebhookMessage::query()

atymic commented 4 years ago

Can you post your code please?

lachlanhickey commented 4 years ago

return WebhookMessage::create() ->data(['body' => 'hello']) ->query( [ 'param1' => 'hello', ]) ->header('Content-Type', 'application/json') ->header('Authorization', 'Basic '. $authorization);

Sorry i think I'm having a bad day. It will be blatantly obvious to you, no doubt.

atymic commented 4 years ago

Looks correct to me, can you post the stack trace for the error please?

lachlanhickey commented 4 years ago

Does this help?

`[2019-12-30 09:23:20] local.ERROR: Call to undefined method NotificationChannels\Webhook\WebhookMessage::query() {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to undefined method NotificationChannels\Webhook\WebhookMessage::query() at /var/www/ss-ops/dev/app/Notifications/SendSMS.php:78) [stacktrace]

0 /var/www/ss-ops/dev/vendor/laravel-notification-channels/webhook/src/WebhookChannel.php(37): App\Notifications\SendSMS->toWebhook(Object(Illuminate\Notifications\AnonymousNotifiable))

1 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(144): NotificationChannels\Webhook\WebhookChannel->send(Object(Illuminate\Notifications\AnonymousNotifiable), Object(App\Notifications\SendSMS))

2 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(103): Illuminate\Notifications\NotificationSender->sendToNotifiable(Object(Illuminate\Notifications\AnonymousNotifiable), '637233f7-376f-4...', Object(App\Notifications\SendSMS), 'NotificationCha...')

3 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php(19): Illuminate\Notifications\NotificationSender->Illuminate\Notifications\{closure}()

4 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Notifications/NotificationSender.php(105): Illuminate\Notifications\NotificationSender->withLocale(NULL, Object(Closure))

5 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(54): Illuminate\Notifications\NotificationSender->sendNow(Array, Object(App\Notifications\SendSMS), Array)

6 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Notifications/SendQueuedNotifications.php(73): Illuminate\Notifications\ChannelManager->sendNow(Object(Illuminate\Notifications\AnonymousNotifiable), Object(App\Notifications\SendSMS), Array)

7 [internal function]: Illuminate\Notifications\SendQueuedNotifications->handle(Object(Illuminate\Notifications\ChannelManager))

8 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)

9 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

10 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))

11 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)

12 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)

13 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Illuminate\Notifications\SendQueuedNotifications))

14 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Notifications\SendQueuedNotifications))

15 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))

16 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(Illuminate\Notifications\SendQueuedNotifications), false)

17 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(88): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)

18 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(337): Illuminate\Queue\Jobs\Job->fire()

19 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(283): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))

20 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))

21 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\Queue\Worker->daemon('redis', 'notifications', Object(Illuminate\Queue\WorkerOptions))

22 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'notifications')

23 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()

24 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)

25 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

26 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))

27 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)

28 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)

29 /var/www/ss-ops/dev/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

30 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

31 /var/www/ss-ops/dev/vendor/symfony/console/Application.php(921): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

32 /var/www/ss-ops/dev/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

33 /var/www/ss-ops/dev/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

34 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Console/Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

35 /var/www/ss-ops/dev/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(133): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

36 /var/www/ss-ops/dev/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

37 {main}

"} `

atymic commented 4 years ago

That method definitely exists: https://github.com/laravel-notification-channels/webhook/blob/master/src/WebhookMessage.php#L67

What version are you running?

lachlanhickey commented 4 years ago

Using the latest version

atymic commented 4 years ago

I've double checked and it's working correctly for me. Is it possible you need to restart your queue to use the latest version? What PHP version are you running?

lachlanhickey commented 4 years ago

The queue is restarted with every code change. PHP 7.3, running on nginx.

lachlanhickey commented 4 years ago

Any more thoughts on what might cause this? I cannot figure this error out. hmm

atymic commented 4 years ago

I can't see any other possible issue that you are running an old version of the package.

https://github.com/laravel-notification-channels/webhook/blob/master/tests/MessageTest.php#L37-L41

There's even a test for the method.

Can you post your composer.lock

lachlanhickey commented 4 years ago

Ok, I see that my version is wrong.

However, I'm pulling from composer require laravel-notification-channels/webhook

How do composer packages get their latest version from packageist?

I have updated composer, dumped autoload, deleted the composer.lock, checked the version of the package in composer.json and the files are still the old version in my vendor folder.

Deleted the folder, redownloaded, still the same.

atymic commented 4 years ago

What PHP and laravel version are you running?

lachlanhickey commented 4 years ago
atymic commented 4 years ago

What's in your composer.json?

lachlanhickey commented 4 years ago

{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "repositories":[ {"type":"composer","url":"https://repo.koolreport.com"} ], "require": { "php": "^7.1.3", "anlutro/bulk-sms": "^2.1", "awobaz/compoships": "1.*", "aws/aws-sdk-php": "^3.128", "barryvdh/laravel-snappy": "^0.4.3", "codedge/laravel-fpdf": "^1.5", "creativeorange/gravatar": "~1.0", "doctrine/dbal": "^2.7", "fideloper/proxy": "^4.0", "gladcodes/keygen": "^1.1", "h4cc/wkhtmltoimage-amd64": "0.12.x", "h4cc/wkhtmltopdf-amd64": "0.12.x", "itsjavi/bootstrap-colorpicker": "^3.0", "koolreport/blade": "*", "koolreport/export": "*", "koolreport/pro": "*", "kyslik/laravel-filterable": "2.0.*", "laravel-notification-channels/pushover": "^2.1", "laravel-notification-channels/webhook": "^1.3", "laravel/framework": "5.8.*", "laravel/passport": "^6.0", "laravel/tinker": "^1.0", "maatwebsite/excel": "^3.1", "matthewbdaly/laravel-azure-storage": "^1.3", "nexmo/client": "^2.0", "nikkanetiya/laravel-color-palette": "^1.3", "predis/predis": "^1.1", "spatie/laravel-permission": "^2.12", "spatie/laravel-webhook-client": "^2.3", "tzsk/sms": "^3.0", "yajra/laravel-datatables-oracle": "9.*" }, "require-dev": { "barryvdh/laravel-debugbar": "^3.2", "filp/whoops": "^2.0", "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", "nunomaduro/collision": "^2.0", "phpunit/phpunit": "^7.0" }, "autoload": { "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\\": "app/" } }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "extra": { "laravel": { "dont-discover": [ ] } }, "scripts": { "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate" ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover" ] }, "config": { "preferred-install": "dist", "sort-packages": true, "optimize-autoloader": true }, "minimum-stability": "dev", "prefer-stable": true }

lachlanhickey commented 4 years ago

I just ran composer require laravel-notification-channels/webhook in another application, same issue. Wrong version..

So I have no idea what I'm doing wrong right now.

atymic commented 4 years ago

Oh my, I understand the issue now. It's actually my fault, the new release wasn't tagged :(

Sorry, tag will be live shortly, not sure how I missed that!

lachlanhickey commented 4 years ago

Phew, so I'm not mad, then? hehe

Appreciate your support.

atymic commented 4 years ago

Tagged as 1.4.0, will be live on packagist shortly. Sorry again 🙈 https://github.com/laravel-notification-channels/webhook/tree/1.4.0