[InstagramBridge] Fix broken compatibility for media_type parameter

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."

-- 8770c87389 (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
This commit is contained in:
logmanoriginal 2018-05-29 12:32:18 +02:00
parent 8ac8e08abf
commit 064ba456e8

View file

@ -11,8 +11,16 @@ class InstagramBridge extends BridgeAbstract {
'u' => array( 'u' => array(
'name' => 'username', 'name' => 'username',
'required' => true 'required' => true
)
), ),
'media_type_u' => array( array(
'h' => array(
'name' => 'hashtag',
'required' => true
)
),
'global' => array(
'media_type' => array(
'name' => 'Media type', 'name' => 'Media type',
'type' => 'list', 'type' => 'list',
'required' => false, 'required' => false,
@ -24,28 +32,16 @@ class InstagramBridge extends BridgeAbstract {
), ),
'defaultValue' => 'all' 'defaultValue' => 'all'
) )
),
array(
'h' => array(
'name' => 'hashtag',
'required' => true
),
'media_type_h' => array(
'name' => 'Media type',
'type' => 'list',
'required' => false,
'values' => array(
'Both' => 'all',
'Video' => 'video',
'Picture' => 'picture'
),
'defaultValue' => 'all'
)
) )
); );
public function collectData(){ 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()); $data = $this->getInstagramJSON($this->getURI());
if(!is_null($this->getInput('u'))) { if(!is_null($this->getInput('u'))) {
@ -58,7 +54,7 @@ class InstagramBridge extends BridgeAbstract {
$media = $media->node; $media = $media->node;
if(!is_null($this->getInput('u'))) { if(!is_null($this->getInput('u'))) {
switch($this->getInput('media_type_u')) { switch($this->getInput('media_type')) {
case 'all': break; case 'all': break;
case 'video': case 'video':
if($media->__typename != 'GraphVideo') continue 2; if($media->__typename != 'GraphVideo') continue 2;
@ -72,7 +68,7 @@ class InstagramBridge extends BridgeAbstract {
default: break; default: break;
} }
} else { } else {
if($this->getInput('media_type_h') == 'video' && !$media->is_video) continue; if($this->getInput('media_type') == 'video' && !$media->is_video) continue;
} }
$item = array(); $item = array();