From 54bb33d232fc36f7f8e24eee7ec5a803c48babf9 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 23 Mar 2014 18:50:28 +0100 Subject: [PATCH] Diaspora: Images from shared messages now appear in the posting. --- include/diaspora.php | 29 ++++++++++++++++++++++++----- include/dsprphotoq.php | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index df6700ae2..7476a5c26 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1009,20 +1009,36 @@ function diaspora_reshare($importer,$xml,$msg) { } elseif($source_xml->post->status_message) { $body = diaspora2bb($source_xml->post->status_message->raw_message); + + // Checking for embedded pictures + if($source_xml->post->status_message->photo->remote_photo_path AND + $source_xml->post->status_message->photo->remote_photo_name) { + + $remote_photo_path = notags(unxmlify($source_xml->post->status_message->photo->remote_photo_path)); + $remote_photo_name = notags(unxmlify($source_xml->post->status_message->photo->remote_photo_name)); + + $body = '[img]'.$remote_photo_path.$remote_photo_name.'[/img]'."\n".$body; + + logger('diaspora_reshare: embedded picture link found: '.$body, LOGGER_DEBUG); + } + $body = scale_external_images($body); // Add OEmbed and other information to the body $body = diaspora_add_page_info_to_body($body); } else { + // Maybe it is a reshare of a photo that will be delivered at a later time (testing) logger('diaspora_reshare: no reshare content found: ' . print_r($source_xml,true)); - return; - } - if(! $body) { - logger('diaspora_reshare: empty body: source= ' . $x); - return; + $body = ""; + //return; } + //if(! $body) { + // logger('diaspora_reshare: empty body: source= ' . $x); + // return; + //} + $person = find_diaspora_person_by_handle($orig_author); /*if(is_array($person) && x($person,'name') && x($person,'url')) @@ -1113,6 +1129,9 @@ function diaspora_reshare($importer,$xml,$msg) { $datarray['tag'] = $str_tags; $datarray['app'] = 'Diaspora'; + // if empty content it might be a photo that hasn't arrived yet. If a photo arrives, we'll make it visible. (testing) + $datarray['visible'] = ((strlen($body)) ? 1 : 0); + $message_id = item_store($datarray); //if($message_id) { diff --git a/include/dsprphotoq.php b/include/dsprphotoq.php index 06e733d79..47592006d 100644 --- a/include/dsprphotoq.php +++ b/include/dsprphotoq.php @@ -8,7 +8,7 @@ function dsprphotoq_run($argv, $argc){ if(is_null($a)){ $a = new App; } - + if(is_null($db)){ @include(".htconfig.php"); require_once("include/dba.php");