mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-25 07:03:41 +00:00
buffer/fromgplus: Some more loop prevention
This commit is contained in:
parent
3d8d0e2860
commit
5a7abb3ffd
2 changed files with 30 additions and 11 deletions
|
@ -234,8 +234,6 @@ function buffer_send(&$a,&$b) {
|
||||||
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
|
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
logger("buffer_send: parameter ".print_r($b, true), LOGGER_DATA);
|
|
||||||
|
|
||||||
if(! strstr($b['postopts'],'buffer'))
|
if(! strstr($b['postopts'],'buffer'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -243,8 +241,8 @@ function buffer_send(&$a,&$b) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if post comes from buffer don't send it back
|
// if post comes from buffer don't send it back
|
||||||
if($b['app'] == "Buffer")
|
//if($b['app'] == "Buffer")
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
$client_id = get_config("buffer", "client_id");
|
$client_id = get_config("buffer", "client_id");
|
||||||
$client_secret = get_config("buffer", "client_secret");
|
$client_secret = get_config("buffer", "client_secret");
|
||||||
|
@ -258,38 +256,55 @@ function buffer_send(&$a,&$b) {
|
||||||
|
|
||||||
$profiles = $buffer->go('/profiles');
|
$profiles = $buffer->go('/profiles');
|
||||||
if (is_array($profiles)) {
|
if (is_array($profiles)) {
|
||||||
|
logger("Will send these parameter ".print_r($b, true), LOGGER_DEBUG);
|
||||||
|
|
||||||
foreach ($profiles as $profile) {
|
foreach ($profiles as $profile) {
|
||||||
if (!$profile->default)
|
if (!$profile->default)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
$send = false;
|
||||||
|
|
||||||
switch ($profile->service) {
|
switch ($profile->service) {
|
||||||
case 'appdotnet':
|
case 'appdotnet':
|
||||||
|
$send = ($b["extid"] != NETWORK_APPNET);
|
||||||
$limit = 256;
|
$limit = 256;
|
||||||
$markup = false;
|
$markup = false;
|
||||||
$includedlinks = true;
|
$includedlinks = true;
|
||||||
|
$htmlmode = 6;
|
||||||
break;
|
break;
|
||||||
case 'facebook':
|
case 'facebook':
|
||||||
|
$send = ($b["extid"] != NETWORK_FACEBOOK);
|
||||||
$limit = 0;
|
$limit = 0;
|
||||||
$markup = false;
|
$markup = false;
|
||||||
$includedlinks = false;
|
$includedlinks = false;
|
||||||
|
$htmlmode = 9;
|
||||||
break;
|
break;
|
||||||
case 'google':
|
case 'google':
|
||||||
|
$send = ($b["extid"] != NETWORK_GPLUS);
|
||||||
$limit = 0;
|
$limit = 0;
|
||||||
$markup = true;
|
$markup = true;
|
||||||
$includedlinks = false;
|
$includedlinks = false;
|
||||||
|
$htmlmode = 9;
|
||||||
break;
|
break;
|
||||||
case 'twitter':
|
case 'twitter':
|
||||||
|
$send = ($b["extid"] != NETWORK_TWITTER);
|
||||||
$limit = 140;
|
$limit = 140;
|
||||||
$markup = false;
|
$markup = false;
|
||||||
$includedlinks = true;
|
$includedlinks = true;
|
||||||
|
$htmlmode = 8;
|
||||||
break;
|
break;
|
||||||
case 'linkedin':
|
case 'linkedin':
|
||||||
|
$send = ($b["extid"] != NETWORK_LINKEDIN);
|
||||||
$limit = 700;
|
$limit = 700;
|
||||||
$markup = false;
|
$markup = false;
|
||||||
$includedlinks = true;
|
$includedlinks = true;
|
||||||
|
$htmlmode = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$send)
|
||||||
|
continue;
|
||||||
|
|
||||||
$item = $b;
|
$item = $b;
|
||||||
|
|
||||||
// Markup for Google+
|
// Markup for Google+
|
||||||
|
@ -302,7 +317,7 @@ function buffer_send(&$a,&$b) {
|
||||||
$item["body"] = preg_replace("(\[s\](.*?)\[\/s\])ism",'-$1-',$item["body"]);
|
$item["body"] = preg_replace("(\[s\](.*?)\[\/s\])ism",'-$1-',$item["body"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$post = plaintext($a, $item, $limit, $includedlinks);
|
$post = plaintext($a, $item, $limit, $includedlinks, $htmlmode);
|
||||||
logger("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG);
|
logger("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG);
|
||||||
|
|
||||||
// The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures
|
// The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures
|
||||||
|
@ -334,6 +349,8 @@ function buffer_send(&$a,&$b) {
|
||||||
$post["text"] .= "\n[".$post["title"]."](".$post["url"].")";
|
$post["text"] .= "\n[".$post["title"]."](".$post["url"].")";
|
||||||
} elseif (($profile->service == "appdotnet") AND isset($post["url"]))
|
} elseif (($profile->service == "appdotnet") AND isset($post["url"]))
|
||||||
$post["text"] .= " ".$post["url"];
|
$post["text"] .= " ".$post["url"];
|
||||||
|
elseif ($profile->service == "google")
|
||||||
|
$post["text"] .= html_entity_decode(" ", ENT_QUOTES, 'UTF-8'); // Send a special blank to identify the post through the "fromgplus" addon
|
||||||
|
|
||||||
$message = array();
|
$message = array();
|
||||||
$message["text"] = $post["text"];
|
$message["text"] = $post["text"];
|
||||||
|
|
|
@ -138,6 +138,7 @@ function fromgplus_post($a, $uid, $source, $body, $location) {
|
||||||
|
|
||||||
$_REQUEST['profile_uid'] = $uid;
|
$_REQUEST['profile_uid'] = $uid;
|
||||||
$_REQUEST['source'] = $source;
|
$_REQUEST['source'] = $source;
|
||||||
|
$_REQUEST['extid'] = NETWORK_GPLUS;
|
||||||
|
|
||||||
// $_REQUEST['verb']
|
// $_REQUEST['verb']
|
||||||
// $_REQUEST['parent']
|
// $_REQUEST['parent']
|
||||||
|
@ -276,6 +277,7 @@ function fromgplus_cleantext($text) {
|
||||||
function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
|
function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
|
||||||
require_once("include/Photo.php");
|
require_once("include/Photo.php");
|
||||||
require_once("include/items.php");
|
require_once("include/items.php");
|
||||||
|
require_once("include/network.php");
|
||||||
|
|
||||||
$post = "";
|
$post = "";
|
||||||
$quote = "";
|
$quote = "";
|
||||||
|
@ -286,13 +288,13 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
|
||||||
switch($attachment->objectType) {
|
switch($attachment->objectType) {
|
||||||
case "video":
|
case "video":
|
||||||
$pagedata["type"] = "video";
|
$pagedata["type"] = "video";
|
||||||
$pagedata["url"] = $attachment->url;
|
$pagedata["url"] = original_url($attachment->url);
|
||||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "article":
|
case "article":
|
||||||
$pagedata["type"] = "link";
|
$pagedata["type"] = "link";
|
||||||
$pagedata["url"] = $attachment->url;
|
$pagedata["url"] = original_url($attachment->url);
|
||||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||||
|
|
||||||
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
|
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
|
||||||
|
@ -336,9 +338,9 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "photo-album":
|
case "photo-album":
|
||||||
$pagedata["url"] = $attachment->url;
|
$pagedata["url"] = original_url($attachment->url);
|
||||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||||
$post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
|
$post .= "\n\n[bookmark=".$pagedata["url"]."]".$pagedata["title"]."[/bookmark]\n";
|
||||||
|
|
||||||
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
|
$images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
|
||||||
|
|
||||||
|
@ -357,7 +359,7 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
|
||||||
|
|
||||||
case "album":
|
case "album":
|
||||||
$pagedata["type"] = "link";
|
$pagedata["type"] = "link";
|
||||||
$pagedata["url"] = $attachment->url;
|
$pagedata["url"] = original_url($attachment->url);
|
||||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||||
|
|
||||||
$thumb = $attachment->thumbnails[0];
|
$thumb = $attachment->thumbnails[0];
|
||||||
|
@ -370,7 +372,7 @@ function fromgplus_handleattachments($a, $uid, $item, $displaytext, $shared) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "audio":
|
case "audio":
|
||||||
$pagedata["url"] = $attachment->url;
|
$pagedata["url"] = original_url($attachment->url);
|
||||||
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
$pagedata["title"] = fromgplus_html2bbcode($attachment->displayName);
|
||||||
$post .= "\n\n[bookmark=".$pagedata["url"]."]".$pagedata["title"]."[/bookmark]\n";
|
$post .= "\n\n[bookmark=".$pagedata["url"]."]".$pagedata["title"]."[/bookmark]\n";
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue