{"action":"opened","issue":{"url":"https://api.github.com/repos/web-push-libs/web-push-php/issues/164","repository_url":"https://api.github.com/repos/web-push-libs/web-push-php","labels_url":"https://api.github.com/repos/web-push-libs/web-push-php/issues/164/labels{/name}","comments_url":"https://api.github.com/repos/web-push-libs/web-push-php/issues/164/comments","events_url":"https://api.github.com/repos/web-push-libs/web-push-php/issues/164/events","html_url":"https://github.com/web-push-libs/web-push-php/issues/164","id":322627819,"number":164,"title":"flush() returns true at any outcome","user":{"login":"cocacard","id":39132955,"avatar_url":"https://avatars3.githubusercontent.com/u/39132955?v=4","gravatar_id":"","url":"https://api.github.com/users/cocacard","html_url":"https://github.com/cocacard","followers_url":"https://api.github.com/users/cocacard/followers","following_url":"https://api.github.com/users/cocacard/following{/other_user}","gists_url":"https://api.github.com/users/cocacard/gists{/gist_id}","starred_url":"https://api.github.com/users/cocacard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cocacard/subscriptions","organizations_url":"https://api.github.com/users/cocacard/orgs","repos_url":"https://api.github.com/users/cocacard/repos","events_url":"https://api.github.com/users/cocacard/events{/privacy}","received_events_url":"https://api.github.com/users/cocacard/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-13T21:14:45Z","updated_at":"2018-05-13T21:14:45Z","closed_at":null,"author_association":"NONE","body":"Dear Developer. I'm writing for the second time.\r\nMy problem is that the `flush` function does not work correctly for me.\r\nMy Code \r\n<pre>\r\nrequire __DIR__ . '/vendor/autoload.php';\r\nuse Minishlink\\WebPush\\WebPush;\r\nuse Minishlink\\WebPush\\Subscription;\r\n\r\n$auth = array(\r\n    'GCM' => 'AIzaSyBFqb...',\r\n    'VAPID' => array(\r\n        'subject' => 'creditbigru@gmail.com',\r\n        'publicKey' => 'BDazBL_QAnZViJ8-0ee...',\r\n        'privateKey' => 'yxYqbcZGxMTW...',\r\n    ),\r\n);\r\n\r\n$defaultOptions = array(\r\n    //'TTL' => 2419000, // defaults to 4 weeks\r\n    'urgency' => 'high',\r\n);\r\n\r\n$notifContent = array(\r\n      'title' => 'Денис, хорошие новости!',\r\n      'rest' => array(\r\n          'body' => 'test',\r\n          'icon' => '/icon-512x512.png',\r\n          'badge' => '/badge-128x128.png',\r\n          'image' => '/unsplash-farzad-nazifi-1600x1100.jpg',\r\n          'tag' => 'example-notification',\r\n          'vibrate' => [200, 100, 200, 100, 200, 100, 200],\r\n          'data' => 'https://google.com',\r\n          'actions' => array(\r\n              array(\r\n                  'title' => 'Action 1',\r\n                  'action' => 'action-1',\r\n                  'icon' => '/action-download-book-128x128.png'\r\n              ),\r\n              array(\r\n                  'title' => 'Action 1',\r\n                  'action' => 'action-1',\r\n                  'icon' => '/action-download-book-128x128.png'\r\n              )\r\n          )\r\n      )\r\n);\r\n\r\n$notifications = [\r\n    [\r\n        'subscription' => Subscription::create([\r\n            'endpoint' => \"https://fcm.googleapis.com/fcm/send/cWh-j6KunsE:APA91bF0cSk8...\",\r\n            'publicKey' => \"BP9KyICy2fKYRqk7LJ5e4WBh...\",\r\n            'authToken' => \"oKjggoMfgvun...\",\r\n            'contentEncoding' => 'aes128gcm',\r\n        ]),\r\n        'payload' => json_encode($notifContent),\r\n    ],\r\n];\r\n\r\n//$webPush = new WebPush($auth);\r\n$webPush = new WebPush($auth, $defaultOptions);\r\n$webPush->setDefaultOptions($defaultOptions);\r\n\r\nforeach ($notifications as $notification) {\r\n    $webPush->sendNotification(\r\n        $notification['subscription'],\r\n        $notification['payload']\r\n    );\r\n}\r\nprint_r($webPush->flush());\r\n</pre>\r\n\r\nreturn `1` or `true` at any outcome even if the subscription is not correct\r\n\r\nI decided to dig in the code and found an interesting thing in the \r\n`src/WebPush.php -> function flush()` when I do `return  $results` instead of  `return $completeSuccess? true: $return`\r\nI get the code with the `state = fulfilled`. But this should not be the case since I specified incorrect subscription data and the `state`should be `rejected` right?\r\n\r\nCode after executing flush() with `return  $results` and incorrect subscription\r\n\r\n<pre>\r\nArray\r\n(\r\n    [0] => Array\r\n        (\r\n            [state] => fulfilled\r\n            [value] => GuzzleHttp\\Psr7\\Response Object\r\n                (\r\n                    [reasonPhrase:GuzzleHttp\\Psr7\\Response:private] => Created\r\n                    [statusCode:GuzzleHttp\\Psr7\\Response:private] => 201\r\n                    [headers:GuzzleHttp\\Psr7\\Response:private] => Array\r\n                        (\r\n                            [Location] => Array\r\n                                (\r\n                                    [0] => https://fcm.googleapis.com/0:...\r\n                                )\r\n\r\n                            [X-Content-Type-Options] => Array\r\n                                (\r\n                                    [0] => nosniff\r\n                                )\r\n\r\n                            [X-Frame-Options] => Array\r\n                                (\r\n                                    [0] => SAMEORIGIN\r\n                                )\r\n\r\n                            [X-Xss-Protection] => Array\r\n                                (\r\n                                    [0] => 1; mode=block\r\n                                )\r\n\r\n                            [Date] => Array\r\n                                (\r\n                                    [0] => Sun, 13 May 2018 21:10:01 GMT\r\n                                )\r\n\r\n                            [Content-Length] => Array\r\n                                (\r\n                                    [0] => 0\r\n                                )\r\n\r\n                            [Content-Type] => Array\r\n                                (\r\n                                    [0] => text/html; charset=UTF-8\r\n                                )\r\n\r\n                            [Alt-Svc] => Array\r\n                                (\r\n                                    [0] => hq=\":443\"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=\":443\"; ma=2592000; v=\"43,42,41,39,35\"\r\n                                )\r\n\r\n                        )\r\n\r\n                    [headerNames:GuzzleHttp\\Psr7\\Response:private] => Array\r\n                        (\r\n                            [location] => Location\r\n                            [x-content-type-options] => X-Content-Type-Options\r\n                            [x-frame-options] => X-Frame-Options\r\n                            [x-xss-protection] => X-Xss-Protection\r\n                            [date] => Date\r\n                            [content-length] => Content-Length\r\n                            [content-type] => Content-Type\r\n                            [alt-svc] => Alt-Svc\r\n                        )\r\n\r\n                    [protocol:GuzzleHttp\\Psr7\\Response:private] => 1.1\r\n                    [stream:GuzzleHttp\\Psr7\\Response:private] => GuzzleHttp\\Psr7\\Stream Object\r\n                        (\r\n                            [stream:GuzzleHttp\\Psr7\\Stream:private] => Resource id #78\r\n                            [size:GuzzleHttp\\Psr7\\Stream:private] => \r\n                            [seekable:GuzzleHttp\\Psr7\\Stream:private] => 1\r\n                            [readable:GuzzleHttp\\Psr7\\Stream:private] => 1\r\n                            [writable:GuzzleHttp\\Psr7\\Stream:private] => 1\r\n                            [uri:GuzzleHttp\\Psr7\\Stream:private] => php://temp\r\n                            [customMetadata:GuzzleHttp\\Psr7\\Stream:private] => Array\r\n                                (\r\n                                )\r\n\r\n                        )\r\n\r\n                )\r\n\r\n        )\r\n\r\n)\r\n</pre>\r\n\r\nI apologize in advance for my bad English and for my perseverance =)\r\nI hope for your understanding and help.\r\nThanks."}}
{"actor":{"display_login":"cocacard"}}