[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?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
This commit is contained in:
logmanoriginal 2018-05-29 12:32:18 +02:00
parent 8ac8e08abf
commit 064ba456e8
1 changed files with 17 additions and 21 deletions

View File

@ -11,8 +11,16 @@ class InstagramBridge extends BridgeAbstract {
'u' => array(
'name' => 'username',
'required' => true
),
'media_type_u' => array(
)
),
array(
'h' => array(
'name' => 'hashtag',
'required' => true
)
),
'global' => array(
'media_type' => array(
'name' => 'Media type',
'type' => 'list',
'required' => false,
@ -24,28 +32,16 @@ class InstagramBridge extends BridgeAbstract {
),
'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(){
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'))) {
@ -58,7 +54,7 @@ class InstagramBridge extends BridgeAbstract {
$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;
@ -72,7 +68,7 @@ class InstagramBridge extends BridgeAbstract {
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();