diff --git a/api/subscription.php b/api/subscription.php index 6ce8acd..8fff623 100644 --- a/api/subscription.php +++ b/api/subscription.php @@ -34,18 +34,9 @@ public function remove() public function _list() { // verify we're checking an actual channel - // ** TODO ** - // - Make this assign channel based on API key so users can only see their own sub status - // - Make this more robust for a sub management page - if (empty($this->params[0])) { - $params = [$this->key]; - $account = 'api_key'; - } - else { - $params = [filter_var($this->params[0], FILTER_SANITIZE_STRING)]; - $account = 'display_name'; - } - $sql = "SELECT " . $this->db->user_table . ".email, " . $this->db->sub_table . ".host_account, " . $this->db->sub_table . ".subscriber FROM " . $this->db->user_table . " JOIN " . $this->db->sub_table . " ON " . $this->db->sub_table . ".host_account = " . $this->db->user_table . ".email OR " . $this->db->sub_table . ".subscriber = " . $this->db->user_table . ".email WHERE " . $account . " = $1"; + // ** TODO - Make this more robust for a sub management page + $params = [$this->key]; + $sql = "SELECT " . $this->db->user_table . ".email, " . $this->db->sub_table . ".host_account, " . $this->db->sub_table . ".subscriber FROM " . $this->db->user_table . " JOIN " . $this->db->sub_table . " ON " . $this->db->sub_table . ".host_account = " . $this->db->user_table . ".email OR " . $this->db->sub_table . ".subscriber = " . $this->db->user_table . ".email WHERE api_key = $1"; $result = pg_query_params($this->db->link, $sql, $params); $subscribed = []; $subscribers = []; diff --git a/index.php b/index.php index 1a1c3d6..79edd4d 100644 --- a/index.php +++ b/index.php @@ -56,7 +56,7 @@ function bytesConvert($bytes, $decimals = 2) { $streamkey = $uriVars[1]; $subemail = $user->updateStreamkey($streamkey, 'email'); // Set up data for checking subscription status - $sub = new subscription($accountinfo['api_key'], [$email]); + $sub = new subscription($accountinfo['api_key'], $streamkey); $list = $sub->_list(); $subarray = json_decode($list); if (in_array($subemail, $subarray->subscribed)) {