Diaspora: Images from shared messages now appear in the posting.

This commit is contained in:
Michael Vogel 2014-03-23 18:50:28 +01:00
parent e1a41aff05
commit 54bb33d232
2 changed files with 25 additions and 6 deletions

View file

@ -1009,20 +1009,36 @@ function diaspora_reshare($importer,$xml,$msg) {
} }
elseif($source_xml->post->status_message) { elseif($source_xml->post->status_message) {
$body = diaspora2bb($source_xml->post->status_message->raw_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); $body = scale_external_images($body);
// Add OEmbed and other information to the body // Add OEmbed and other information to the body
$body = diaspora_add_page_info_to_body($body); $body = diaspora_add_page_info_to_body($body);
} }
else { 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)); logger('diaspora_reshare: no reshare content found: ' . print_r($source_xml,true));
return; $body = "";
} //return;
if(! $body) {
logger('diaspora_reshare: empty body: source= ' . $x);
return;
} }
//if(! $body) {
// logger('diaspora_reshare: empty body: source= ' . $x);
// return;
//}
$person = find_diaspora_person_by_handle($orig_author); $person = find_diaspora_person_by_handle($orig_author);
/*if(is_array($person) && x($person,'name') && x($person,'url')) /*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['tag'] = $str_tags;
$datarray['app'] = 'Diaspora'; $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); $message_id = item_store($datarray);
//if($message_id) { //if($message_id) {

View file

@ -8,7 +8,7 @@ function dsprphotoq_run($argv, $argc){
if(is_null($a)){ if(is_null($a)){
$a = new App; $a = new App;
} }
if(is_null($db)){ if(is_null($db)){
@include(".htconfig.php"); @include(".htconfig.php");
require_once("include/dba.php"); require_once("include/dba.php");