Skip to content

Commit

Permalink
[InstagramBridge] Fix broken compatibility for media_type parameter
Browse files Browse the repository at this point in the history
The media_type parameter was recently replaced by media_type_u (for
user mode) and media_type_h (for hashtag mode). This was necessary
in order to add the media type 'story' only for the user mode.

"The reason for that is that RSS-Bridge supports multiple parameters
with the same name if and only if they contain the exact same value.
Here, hashtags don't have stories, so it would not be possible to
pass "story" as a parameter. This is a design mistake that I made
when I added support for hashtags."

-- 8770c87?diff=split#r28871502

However as pointed out this change breaks existing feeds as the
parameter name is no longer compatible to previous implementations.

This commit changes the implementation to provide the old media_type
parameter globally and check for invalid options on each request. If
a user uses the 'story' option in history mode the bridge returns a
client error.

references 8770c87
references #694
fixes #696
fixes #699
fixes #701
  • Loading branch information
logmanoriginal committed May 29, 2018
1 parent 8ac8e08 commit 064ba45
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions bridges/InstagramBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,37 @@ class InstagramBridge extends BridgeAbstract {
'u' => array(
'name' => 'username',
'required' => true
),
'media_type_u' => array(
'name' => 'Media type',
'type' => 'list',
'required' => false,
'values' => array(
'All' => 'all',
'Story' => 'story',
'Video' => 'video',
'Picture' => 'picture',
),
'defaultValue' => 'all'
)
),
array(
'h' => array(
'name' => 'hashtag',
'required' => true
),
'media_type_h' => array(
)
),
'global' => array(
'media_type' => array(
'name' => 'Media type',
'type' => 'list',
'required' => false,
'values' => array(
'Both' => 'all',
'All' => 'all',
'Story' => 'story',
'Video' => 'video',
'Picture' => 'picture'
'Picture' => 'picture',
),
'defaultValue' => 'all'
)
)

);

public function collectData(){

if(!is_null($this->getInput('h')) && $this->getInput('media_type') == 'story') {
returnClientError('Stories are not supported for hashtags!');
}

$data = $this->getInstagramJSON($this->getURI());

if(!is_null($this->getInput('u'))) {
Expand All @@ -58,7 +54,7 @@ public function collectData(){
$media = $media->node;

if(!is_null($this->getInput('u'))) {
switch($this->getInput('media_type_u')) {
switch($this->getInput('media_type')) {
case 'all': break;
case 'video':
if($media->__typename != 'GraphVideo') continue 2;
Expand All @@ -72,7 +68,7 @@ public function collectData(){
default: break;
}
} else {
if($this->getInput('media_type_h') == 'video' && !$media->is_video) continue;
if($this->getInput('media_type') == 'video' && !$media->is_video) continue;
}

$item = array();
Expand Down

0 comments on commit 064ba45

Please sign in to comment.