aboutsummaryrefslogtreecommitdiffstats
path: root/include/diaspora.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-10-05 22:17:51 -0700
committerfriendica <info@friendica.com>2014-10-05 22:17:51 -0700
commit34ef3fda76a924d09e77a698e38b79922b8b7f88 (patch)
tree94e12c405735a6e044121396e38557d6b64756e0 /include/diaspora.php
parent2cadc5a840ed47ab50a657e2b0bfa3ab80105d5a (diff)
downloadvolse-hubzilla-34ef3fda76a924d09e77a698e38b79922b8b7f88.tar.gz
volse-hubzilla-34ef3fda76a924d09e77a698e38b79922b8b7f88.tar.bz2
volse-hubzilla-34ef3fda76a924d09e77a698e38b79922b8b7f88.zip
attempt to deal with the diaspora recursive reshare from hell (Bob reshared Nancy's reshare of George's reshare of Lilly's reshare of Nathan's post). The attribution may be wrong so this is still a work in progress.
Diffstat (limited to 'include/diaspora.php')
-rwxr-xr-xinclude/diaspora.php50
1 files changed, 40 insertions, 10 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index 519aba112..0d4271cee 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -902,6 +902,44 @@ function diaspora_post($importer,$xml,$msg) {
}
+
+function get_diaspora_reshare_xml($url,$recurse = 0) {
+
+ $x = z_fetch_url($url);
+ if(! $x['success'])
+ $x = z_fetch_url(str_replace('https://','http://',$source_url));
+ if(! $x['success']) {
+ logger('get_diaspora_reshare_xml: unable to fetch source url ' . $source_url);
+ return;
+ }
+ logger('diaspora_reshare: source: ' . $x['body'], LOGGER_DATA);
+
+ $source_xml = parse_xml_string($x['body'],false);
+
+ if(! $source_xml) {
+ logger('get_diaspora_reshare_xml: unparseable result from ' . $url);
+ return '';
+ }
+
+ if($source_xml->post->status_message) {
+ return $source_xml;
+ }
+
+ // see if it's a reshare of a reshare
+
+ if($source_xml->root_diaspora_id && $source_xml->root_guid && $recurse < 15) {
+ $orig_author = notags(unxmlify($xml->root_diaspora_id));
+ $orig_guid = notags(unxmlify($xml->root_guid));
+ $source_url = 'https://' . substr($orig_author,strpos($orig_author,'@')+1) . '/p/' . $orig_guid . '.xml';
+ $y = get_diaspora_reshare_xml($source_url,$recurse+1);
+ if($y)
+ return $y;
+ }
+ return false;
+}
+
+
+
function diaspora_reshare($importer,$xml,$msg) {
logger('diaspora_reshare: init: ' . print_r($xml,true), LOGGER_DATA);
@@ -940,16 +978,8 @@ function diaspora_reshare($importer,$xml,$msg) {
$source_url = 'https://' . substr($orig_author,strpos($orig_author,'@')+1) . '/p/' . $orig_guid . '.xml';
$orig_url = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid;
- $x = z_fetch_url($source_url);
- if(! $x['success'])
- $x = z_fetch_url(str_replace('https://','http://',$source_url));
- if(! $x['success']) {
- logger('diaspora_reshare: unable to fetch source url ' . $source_url);
- return;
- }
- logger('diaspora_reshare: source: ' . $x['body'], LOGGER_DATA);
- $source_xml = parse_xml_string($x['body'],false);
+ $source_xml = get_diaspora_reshare_xml($source_url);
if($source_xml->post->status_message) {
$body = diaspora2bb($source_xml->post->status_message->raw_message);
@@ -995,7 +1025,7 @@ function diaspora_reshare($importer,$xml,$msg) {
. "' profile='" . $orig_author_link
. "' avatar='" . $orig_author_photo
. "' link='" . $orig_url
- . "' posted='" . datetime_convert('UTC','UTC',unxmlify($sourcexml->post->status_message->created_at))
+ . "' posted='" . datetime_convert('UTC','UTC',unxmlify($source_xml->post->status_message->created_at))
. "' message_id='" . unxmlify($source_xml->post->status_message->guid)
. "']" . $body . "[/share]";