X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fdiaspora.php;h=4ec7489ca4e87a3cb71c962f9343cf3b68e62b51;hb=6d3581dac8dc5a27a18a39709fa3ae38c080c490;hp=b72239c4ceab1255dc7f297f831231747f6884c7;hpb=e1bc0b4ff820c3d98ba2188ca408cc88ed9ba7eb;p=friendica.git diff --git a/include/diaspora.php b/include/diaspora.php index b72239c4ce..4ec7489ca4 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -14,6 +14,7 @@ require_once('include/queue_fn.php'); require_once('include/lock.php'); require_once('include/threads.php'); require_once('mod/share.php'); +require_once('include/enotify.php'); function diaspora_dispatch_public($msg) { @@ -57,6 +58,8 @@ function diaspora_dispatch($importer,$msg,$attempt=1) { return; } + $data = $msg; + // php doesn't like dashes in variable names $msg['message'] = str_replace( @@ -73,48 +76,83 @@ function diaspora_dispatch($importer,$msg,$attempt=1) { if($xmlbase->request) { + $tempfile = tempnam(get_temppath(), "diaspora-request"); + file_put_contents($tempfile, json_encode($data)); $ret = diaspora_request($importer,$xmlbase->request); } elseif($xmlbase->status_message) { + //$tempfile = tempnam(get_temppath(), "diaspora-status_message"); + //file_put_contents($tempfile, json_encode($data)); $ret = diaspora_post($importer,$xmlbase->status_message,$msg); } elseif($xmlbase->profile) { + //$tempfile = tempnam(get_temppath(), "diaspora-profile"); + //file_put_contents($tempfile, json_encode($data)); $ret = diaspora_profile($importer,$xmlbase->profile,$msg); } elseif($xmlbase->comment) { + //$tempfile = tempnam(get_temppath(), "diaspora-comment"); + //file_put_contents($tempfile, json_encode($data)); $ret = diaspora_comment($importer,$xmlbase->comment,$msg); } elseif($xmlbase->like) { + //$tempfile = tempnam(get_temppath(), "diaspora-like"); + //file_put_contents($tempfile, json_encode($data)); $ret = diaspora_like($importer,$xmlbase->like,$msg); } elseif($xmlbase->asphoto) { + $tempfile = tempnam(get_temppath(), "diaspora-asphoto"); + file_put_contents($tempfile, json_encode($data)); $ret = diaspora_asphoto($importer,$xmlbase->asphoto,$msg); } elseif($xmlbase->reshare) { + //$tempfile = tempnam(get_temppath(), "diaspora-reshare"); + //file_put_contents($tempfile, json_encode($data)); $ret = diaspora_reshare($importer,$xmlbase->reshare,$msg); } elseif($xmlbase->retraction) { + $tempfile = tempnam(get_temppath(), "diaspora-retraction"); + file_put_contents($tempfile, json_encode($data)); $ret = diaspora_retraction($importer,$xmlbase->retraction,$msg); } elseif($xmlbase->signed_retraction) { + //$tempfile = tempnam(get_temppath(), "diaspora-signed_retraction"); + //file_put_contents($tempfile, json_encode($data)); $ret = diaspora_signed_retraction($importer,$xmlbase->signed_retraction,$msg); } elseif($xmlbase->relayable_retraction) { + //$tempfile = tempnam(get_temppath(), "diaspora-relayable_retraction"); + //file_put_contents($tempfile, json_encode($data)); $ret = diaspora_signed_retraction($importer,$xmlbase->relayable_retraction,$msg); } elseif($xmlbase->photo) { + //$tempfile = tempnam(get_temppath(), "diaspora-photo"); + //file_put_contents($tempfile, json_encode($data)); $ret = diaspora_photo($importer,$xmlbase->photo,$msg,$attempt); } elseif($xmlbase->conversation) { + $tempfile = tempnam(get_temppath(), "diaspora-conversation"); + file_put_contents($tempfile, json_encode($data)); $ret = diaspora_conversation($importer,$xmlbase->conversation,$msg); } elseif($xmlbase->message) { + $tempfile = tempnam(get_temppath(), "diaspora-message"); + file_put_contents($tempfile, json_encode($data)); $ret = diaspora_message($importer,$xmlbase->message,$msg); } elseif($xmlbase->participation) { + //$tempfile = tempnam(get_temppath(), "diaspora-participation"); + //file_put_contents($tempfile, json_encode($data)); + $ret = diaspora_participation($importer,$xmlbase->participation); + } + elseif($xmlbase->poll_participation) { + $tempfile = tempnam(get_temppath(), "diaspora-poll_participation"); + file_put_contents($tempfile, json_encode($data)); $ret = diaspora_participation($importer,$xmlbase->participation); } else { + $tempfile = tempnam(get_temppath(), "diaspora-unknown"); + file_put_contents($tempfile, json_encode($data)); logger('diaspora_dispatch: unknown message type: ' . print_r($xmlbase,true)); } return $ret; @@ -728,7 +766,7 @@ function diaspora_request($importer,$xml) { require_once('include/Photo.php'); - $photos = import_profile_photo($contact_record['photo'],$importer['uid'],$contact_record['id']); + update_contact_avatar($contact_record['photo'],$importer['uid'],$contact_record['id']); // technically they are sharing with us (CONTACT_IS_SHARING), // but if our page-type is PAGE_COMMUNITY or PAGE_SOAPBOX @@ -739,26 +777,17 @@ function diaspora_request($importer,$xml) { else $new_relation = CONTACT_IS_FOLLOWER; - $r = q("UPDATE `contact` SET - `photo` = '%s', - `thumb` = '%s', - `micro` = '%s', - `rel` = %d, + $r = q("UPDATE `contact` SET `rel` = %d, `name-date` = '%s', `uri-date` = '%s', - `avatar-date` = '%s', `blocked` = 0, `pending` = 0, `writable` = 1 WHERE `id` = %d ", - dbesc($photos[0]), - dbesc($photos[1]), - dbesc($photos[2]), intval($new_relation), dbesc(datetime_convert()), dbesc(datetime_convert()), - dbesc(datetime_convert()), intval($contact_record['id']) ); @@ -1598,47 +1627,6 @@ function diaspora_comment($importer,$xml,$msg) { proc_run('php','include/notifier.php','comment-import',$message_id); } - $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0 ", - dbesc($parent_item['uri']), - intval($importer['uid']) - ); - - if(count($myconv)) { - $importer_url = $a->get_baseurl() . '/profile/' . $importer['nickname']; - - foreach($myconv as $conv) { - - // now if we find a match, it means we're in this conversation - - if(! link_compare($conv['author-link'],$importer_url)) - continue; - - require_once('include/enotify.php'); - - $conv_parent = $conv['parent']; - - notification(array( - 'type' => NOTIFY_COMMENT, - 'notify_flags' => $importer['notify-flags'], - 'language' => $importer['language'], - 'to_name' => $importer['username'], - 'to_email' => $importer['email'], - 'uid' => $importer['uid'], - 'item' => $datarray, - 'link' => $a->get_baseurl().'/display/'.urlencode($datarray['guid']), - 'source_name' => $datarray['author-name'], - 'source_link' => $datarray['author-link'], - 'source_photo' => $datarray['author-avatar'], - 'verb' => ACTIVITY_POST, - 'otype' => 'item', - 'parent' => $conv_parent, - 'parent_uri' => $parent_uri - )); - - // only send one notification - break; - } - } return; } @@ -1793,7 +1781,6 @@ function diaspora_conversation($importer,$xml,$msg) { intval($conversation['id']) ); - require_once('include/enotify.php'); notification(array( 'type' => NOTIFY_MAIL, 'notify_flags' => $importer['notify-flags'], @@ -2473,7 +2460,7 @@ function diaspora_profile($importer,$xml,$msg) { require_once('include/Photo.php'); - $images = import_profile_photo($image_url,$importer['uid'],$contact['id']); + update_contact_avatar($image_url,$importer['uid'],$contact['id']); // Generic birthday. We don't know the timezone. The year is irrelevant. @@ -2491,15 +2478,12 @@ function diaspora_profile($importer,$xml,$msg) { /// @TODO Update name on item['author-name'] if the name changed. See consume_feed() /// (Not doing this currently because D* protocol is scheduled for revision soon). - $r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `name-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s', `avatar-date` = '%s' , `bd` = '%s', `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `id` = %d AND `uid` = %d", + $r = q("UPDATE `contact` SET `name` = '%s', `nick` = '%s', `addr` = '%s', `name-date` = '%s', `bd` = '%s', + `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($name), dbesc($nick), dbesc($diaspora_handle), dbesc(datetime_convert()), - dbesc($image_url), - dbesc($images[1]), - dbesc($images[2]), - dbesc(datetime_convert()), dbesc($birthday), dbesc($location), dbesc($about),