Skip to content

Commit

Permalink
Fixed crippling bug in sub api
Browse files Browse the repository at this point in the history
  • Loading branch information
Fenrirthviti committed Aug 19, 2016
1 parent 0b442e0 commit e4a7bbc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
15 changes: 3 additions & 12 deletions api/subscription.php
Expand Up @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion index.php
Expand Up @@ -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)) {
Expand Down

0 comments on commit e4a7bbc

Please sign in to comment.