Explorar el Código

Updated Pusher again

CauseFX hace 6 años
padre
commit
7b3b096bac

+ 1 - 1
api/composer.json

@@ -8,7 +8,7 @@
     "kryptonit3/sonarr": "1.0.6.1",
     "kryptonit3/couchpotato": "^1.0",
     "kryptonit3/sickrage": "^1.0",
-    "pusher/pusher-php-server": "^3.2",
+    "pusher/pusher-php-server": "^4.0",
     "pragmarx/google2fa": "^3.0",
     "layershifter/tld-extract": "^2.0",
     "psr/log": "^1.1",

+ 9 - 9
api/composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "26cfb78bf4065beffc5771810030c05f",
+    "content-hash": "f7a4680bc682c6ee1c29f4c7d6e44c40",
     "packages": [
         {
             "name": "adldap2/adldap2",
@@ -1237,31 +1237,31 @@
         },
         {
             "name": "pusher/pusher-php-server",
-            "version": "v3.3.1",
+            "version": "v4.1.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/pusher/pusher-http-php.git",
-                "reference": "2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0"
+                "reference": "3c05ef64839845b6114396ff8406712cba052750"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0",
-                "reference": "2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0",
+                "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/3c05ef64839845b6114396ff8406712cba052750",
+                "reference": "3c05ef64839845b6114396ff8406712cba052750",
                 "shasum": ""
             },
             "require": {
                 "ext-curl": "*",
                 "paragonie/sodium_compat": "^1.6",
-                "php": "^5.4 || ^7.0",
+                "php": "^7.1",
                 "psr/log": "^1.0"
             },
             "require-dev": {
-                "phpunit/phpunit": "^4.8.35 || ^5.7"
+                "phpunit/phpunit": "^7.2"
             },
             "type": "library",
             "extra": {
                 "branch-alias": {
-                    "dev-master": "3.0-dev"
+                    "dev-master": "3.4-dev"
                 }
             },
             "autoload": {
@@ -1287,7 +1287,7 @@
                 "rest",
                 "trigger"
             ],
-            "time": "2019-01-18T12:10:21+00:00"
+            "time": "2019-12-03T13:29:13+00:00"
         },
         {
             "name": "rmccue/requests",

+ 9 - 9
api/vendor/composer/installed.json

@@ -1276,33 +1276,33 @@
     },
     {
         "name": "pusher/pusher-php-server",
-        "version": "v3.3.1",
-        "version_normalized": "3.3.1.0",
+        "version": "v4.1.1",
+        "version_normalized": "4.1.1.0",
         "source": {
             "type": "git",
             "url": "https://github.com/pusher/pusher-http-php.git",
-            "reference": "2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0"
+            "reference": "3c05ef64839845b6114396ff8406712cba052750"
         },
         "dist": {
             "type": "zip",
-            "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0",
-            "reference": "2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0",
+            "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/3c05ef64839845b6114396ff8406712cba052750",
+            "reference": "3c05ef64839845b6114396ff8406712cba052750",
             "shasum": ""
         },
         "require": {
             "ext-curl": "*",
             "paragonie/sodium_compat": "^1.6",
-            "php": "^5.4 || ^7.0",
+            "php": "^7.1",
             "psr/log": "^1.0"
         },
         "require-dev": {
-            "phpunit/phpunit": "^4.8.35 || ^5.7"
+            "phpunit/phpunit": "^7.2"
         },
-        "time": "2019-01-18T12:10:21+00:00",
+        "time": "2019-12-03T13:29:13+00:00",
         "type": "library",
         "extra": {
             "branch-alias": {
-                "dev-master": "3.0-dev"
+                "dev-master": "3.4-dev"
             }
         },
         "installation-source": "dist",

+ 20 - 0
api/vendor/pusher/pusher-php-server/CHANGELOG.md

@@ -1,3 +1,23 @@
+## 4.1.1 (2019-12-03)
+
+[ADDED] Support for PHP 7.4.
+
+## 4.1.0 (2019-10-28)
+
+[ADDED] `path` configuration option.
+
+## 4.0.0 (2019-06-17)
+
+[REMOVED] Support for PHP 5.x, PHP 7.0 and HHVM.
+
+## 3.4.1 (2019-03-18)
+
+[ADDED] Support for PHP 7.3.
+
+## 3.4.0 (2019-03-11)
+
+[ADDED] `get_users_info` method.
+
 ## 3.3.1 (2019-01-18)
 
 [FIXED] PHP Notice for Undefined `socket_id` in triggerBatch

+ 3 - 3
api/vendor/pusher/pusher-php-server/composer.json

@@ -4,13 +4,13 @@
     "keywords": ["php-pusher-server", "pusher", "rest", "realtime", "real-time", "real time", "messaging", "push", "trigger", "publish", "events"],
     "license": "MIT",
     "require": {
-        "php": "^5.4 || ^7.0",
+        "php": "^7.1",
         "ext-curl": "*",
         "psr/log": "^1.0",
         "paragonie/sodium_compat": "^1.6"
     },
     "require-dev": {
-        "phpunit/phpunit": "^4.8.35 || ^5.7"
+        "phpunit/phpunit": "^7.2"
     },
     "autoload": {
         "psr-4": {
@@ -25,7 +25,7 @@
     },
     "extra": {
         "branch-alias": {
-            "dev-master": "3.0-dev"
+            "dev-master": "3.4-dev"
         }
     },
     "minimum-stability": "dev",

+ 12 - 0
api/vendor/pusher/pusher-php-server/scripts/travis-install.sh

@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+set -e
+
+curl -sSfL -o ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit-7.5.9.phar
+composer install --no-interaction --prefer-source
+
+if [ $INSTALL_LIBSODIUM = true ]; then
+  sudo add-apt-repository ppa:ondrej/php -y
+  sudo apt-get update && sudo apt-get install libsodium-dev -y
+  pecl install libsodium-2.0.11
+fi

+ 42 - 19
api/vendor/pusher/pusher-php-server/src/Pusher.php

@@ -14,7 +14,7 @@ class Pusher implements LoggerAwareInterface
     /**
      * @var string Version
      */
-    public static $VERSION = '3.3.1';
+    public static $VERSION = '4.1.1';
 
     /**
      * @var null|PusherCrypto
@@ -27,6 +27,7 @@ class Pusher implements LoggerAwareInterface
     private $settings = array(
         'scheme'                => 'http',
         'port'                  => 80,
+        'path'                  => '',
         'timeout'               => 30,
         'debug'                 => false,
         'curl_options'          => array(),
@@ -87,10 +88,12 @@ class Pusher implements LoggerAwareInterface
             }
 
             $this->settings['host'] = $host;
+            $this->settings['path'] = '';
 
             $this->log('Legacy $host parameter provided: {scheme} host: {host}', array(
                 'scheme' => $this->settings['scheme'],
                 'host'   => $this->settings['host'],
+                'path'   => $this->settings['path'],
             ));
         }
 
@@ -297,8 +300,8 @@ class Pusher implements LoggerAwareInterface
     /**
      * Utility function used to create the curl object with common settings.
      *
-     * @param string            $domain
-     * @param string            $s_url
+     * @param string            $url_prefix
+     * @param string            $path
      * @param string [optional] $request_method
      * @param array [optional]  $query_params
      *
@@ -306,18 +309,18 @@ class Pusher implements LoggerAwareInterface
      *
      * @return resource
      */
-    private function create_curl($domain, $s_url, $request_method = 'GET', $query_params = array())
+    private function create_curl($url_prefix, $path, $request_method = 'GET', $query_params = array())
     {
         // Create the signed signature...
         $signed_query = self::build_auth_query_string(
             $this->settings['auth_key'],
             $this->settings['secret'],
             $request_method,
-            $s_url,
+            $path,
             $query_params
         );
 
-        $full_url = $domain.$s_url.'?'.$signed_query;
+        $full_url = $url_prefix.$path.'?'.$signed_query;
 
         $this->log('create_curl( {full_url} )', array('full_url' => $full_url));
 
@@ -390,23 +393,23 @@ class Pusher implements LoggerAwareInterface
     }
 
     /**
-     * Build the notification domain.
+     * Build the notification url prefix.
      *
      * @return string
      */
-    private function notification_domain()
+    private function notification_url_prefix()
     {
         return $this->settings['notification_scheme'].'://'.$this->settings['notification_host'];
     }
 
     /**
-     * Build the Channels domain.
+     * Build the Channels url prefix.
      *
      * @return string
      */
-    private function channels_domain()
+    private function channels_url_prefix()
     {
-        return $this->settings['scheme'].'://'.$this->settings['host'].':'.$this->settings['port'];
+        return $this->settings['scheme'].'://'.$this->settings['host'].':'.$this->settings['port'].$this->settings['path'];
     }
 
     /**
@@ -517,7 +520,7 @@ class Pusher implements LoggerAwareInterface
 
         $query_params = array();
 
-        $s_url = $this->settings['base_path'].'/events';
+        $path = $this->settings['base_path'].'/events';
 
         // json_encode might return false on failure
         if (!$data_encoded) {
@@ -539,7 +542,7 @@ class Pusher implements LoggerAwareInterface
 
         $query_params['body_md5'] = md5($post_value);
 
-        $ch = $this->create_curl($this->channels_domain(), $s_url, 'POST', $query_params);
+        $ch = $this->create_curl($this->channels_url_prefix(), $path, 'POST', $query_params);
 
         $this->log('trigger POST: {post_value}', compact('post_value'));
 
@@ -595,9 +598,9 @@ class Pusher implements LoggerAwareInterface
 
         $query_params = array();
         $query_params['body_md5'] = md5($post_value);
-        $s_url = $this->settings['base_path'].'/batch_events';
+        $path = $this->settings['base_path'].'/batch_events';
 
-        $ch = $this->create_curl($this->channels_domain(), $s_url, 'POST', $query_params);
+        $ch = $this->create_curl($this->channels_url_prefix(), $path, 'POST', $query_params);
 
         $this->log('trigger POST: {post_value}', compact('post_value'));
 
@@ -662,6 +665,26 @@ class Pusher implements LoggerAwareInterface
         return false;
     }
 
+    /**
+     * Fetch user ids currently subscribed to a presence channel.
+     *
+     * @param string $channel The name of the channel
+     *
+     * @throws PusherException Throws exception if curl wasn't initialized correctly
+     *
+     * @return array|bool
+     */
+    public function get_users_info($channel)
+    {
+        $response = $this->get('/channels/'.$channel.'/users');
+
+        if ($response['status'] === 200) {
+            return json_decode($response['body']);
+        }
+
+        return false;
+    }
+
     /**
      * GET arbitrary REST API resource using a synchronous http client.
      * All request signing is handled automatically.
@@ -675,9 +698,9 @@ class Pusher implements LoggerAwareInterface
      */
     public function get($path, $params = array())
     {
-        $s_url = $this->settings['base_path'].$path;
+        $path = $this->settings['base_path'].$path;
 
-        $ch = $this->create_curl($this->channels_domain(), $s_url, 'GET', $params);
+        $ch = $this->create_curl($this->channels_url_prefix(), $path, 'GET', $params);
 
         $response = $this->exec_curl($ch);
 
@@ -781,8 +804,8 @@ class Pusher implements LoggerAwareInterface
 
         $query_params['body_md5'] = md5($post_value);
 
-        $notification_path = '/server_api/v1'.$this->settings['base_path'].'/notifications';
-        $ch = $this->create_curl($this->notification_domain(), $notification_path, 'POST', $query_params);
+        $path = '/server_api/v1'.$this->settings['base_path'].'/notifications';
+        $ch = $this->create_curl($this->notification_url_prefix(), $path, 'POST', $query_params);
 
         $this->log('trigger POST (Native notifications): {post_value}', compact('post_value'));