aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boot.php4
-rw-r--r--database.sql4
-rw-r--r--include/Photo.php13
-rw-r--r--include/bb2diaspora.php159
-rw-r--r--include/diaspora.php134
-rw-r--r--include/group.php5
-rw-r--r--include/notifier.php88
-rw-r--r--include/poller.php8
-rw-r--r--mod/receive.php3
-rw-r--r--update.php19
-rw-r--r--view/api_timeline_atom.tpl2
-rw-r--r--view/diaspora_photo.tpl13
12 files changed, 408 insertions, 44 deletions
diff --git a/boot.php b/boot.php
index b0ff7830c..16b8f9c85 100644
--- a/boot.php
+++ b/boot.php
@@ -7,9 +7,9 @@ require_once('include/text.php');
require_once("include/pgettext.php");
-define ( 'FRIENDIKA_VERSION', '2.2.1080' );
+define ( 'FRIENDIKA_VERSION', '2.2.1081' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
-define ( 'DB_UPDATE_VERSION', 1081 );
+define ( 'DB_UPDATE_VERSION', 1082 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
diff --git a/database.sql b/database.sql
index 605433e6e..f659e8049 100644
--- a/database.sql
+++ b/database.sql
@@ -267,6 +267,7 @@ CREATE TABLE IF NOT EXISTS `photo` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL,
`contact-id` int(10) unsigned NOT NULL,
+ `guid` char(64) NOT NULL,
`resource-id` char(255) NOT NULL,
`created` datetime NOT NULL,
`edited` datetime NOT NULL,
@@ -288,7 +289,8 @@ CREATE TABLE IF NOT EXISTS `photo` (
KEY `resource-id` (`resource-id`),
KEY `album` (`album`),
KEY `scale` (`scale`),
- KEY `profile` (`profile`)
+ KEY `profile` (`profile`),
+ KEY `guid` (`guid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
diff --git a/include/Photo.php b/include/Photo.php
index de4c3d9e0..1450374ff 100644
--- a/include/Photo.php
+++ b/include/Photo.php
@@ -185,11 +185,20 @@ class Photo {
public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
+ $r = q("select `guid` from photo where `resource-id` = '%s' and `guid` != '' limit 1",
+ dbesc($rid)
+ );
+ if(count($r))
+ $guid = $r[0]['guid'];
+ else
+ $guid = get_guid();
+
$r = q("INSERT INTO `photo`
- ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )",
+ ( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )",
intval($uid),
intval($cid),
+ dbesc($guid),
dbesc($rid),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
new file mode 100644
index 000000000..5ce34d666
--- /dev/null
+++ b/include/bb2diaspora.php
@@ -0,0 +1,159 @@
+<?php
+
+require_once("include/oembed.php");
+require_once('include/event.php');
+
+
+
+function stripdcode_br_cb($s) {
+ return '[code]' . str_replace('<br />', '', $s[1]) . '[/code]';
+}
+
+
+ // BBcode 2 HTML was written by WAY2WEB.net
+ // extended to work with Mistpark/Friendika - Mike Macgirvin
+
+function bb2diaspora($Text,$preserve_nl = false) {
+
+ // Replace any html brackets with HTML Entities to prevent executing HTML or script
+ // Don't use strip_tags here because it breaks [url] search by replacing & with amp
+
+ $Text = str_replace("<", "&lt;", $Text);
+ $Text = str_replace(">", "&gt;", $Text);
+
+
+ if($preserve_nl)
+ $Text = str_replace(array("\n","\r"), array('',''),$Text);
+
+ // Set up the parameters for a URL search string
+ $URLSearchString = "^\[\]";
+ // Set up the parameters for a MAIL search string
+ $MAILSearchString = $URLSearchString;
+
+ // Perform URL Search
+
+ // [img]pathtoimage[/img]
+
+
+ $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '[$1]($1)', $Text);
+ $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.*?)\[/url\])", '[$2]($1)', $Text);
+
+// $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('Image/photo: ') . '$1', $Text);
+// $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('image/photo'), $Text);
+
+ // Perform MAIL Search
+ $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '[$1](mailto:$1)', $Text);
+ $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.*?)\[\/mail\]/", '[$2](mailto:$1)', $Text);
+
+ $Text = str_replace('*', '\\*', $Text);
+ $Text = str_replace('_', '\\_', $Text);
+
+ $Text = str_replace('`','\\`', $Text);
+
+ // Check for bold text
+ $Text = preg_replace("(\[b\](.*?)\[\/b\])is",'**$1**',$Text);
+
+ // Check for Italics text
+ $Text = preg_replace("(\[i\](.*?)\[\/i\])is",'_$1_',$Text);
+
+ // Check for Underline text
+// $Text = preg_replace("(\[u\](.*?)\[\/u\])is",'<u>$1</u>',$Text);
+
+ // Check for strike-through text
+// $Text = preg_replace("(\[s\](.*?)\[\/s\])is",'<strike>$1</strike>',$Text);
+
+ // Check for over-line text
+// $Text = preg_replace("(\[o\](.*?)\[\/o\])is",'<span class="overline">$1</span>',$Text);
+
+ // Check for colored text
+// $Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])is","<span style=\"color: $1;\">$2</span>",$Text);
+
+ // Check for sized text
+// $Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])is","<span style=\"font-size: $1;\">$2</span>",$Text);
+
+ // Check for list text
+// $Text = preg_replace("/\[list\](.*?)\[\/list\]/is", '<ul class="listbullet">$1</ul>' ,$Text);
+// $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/is", '<ul class="listdecimal">$1</ul>' ,$Text);
+// $Text = preg_replace("/\[list=i\](.*?)\[\/list\]/s",'<ul class="listlowerroman">$1</ul>' ,$Text);
+// $Text = preg_replace("/\[list=I\](.*?)\[\/list\]/s", '<ul class="listupperroman">$1</ul>' ,$Text);
+// $Text = preg_replace("/\[list=a\](.*?)\[\/list\]/s", '<ul class="listloweralpha">$1</ul>' ,$Text);
+// $Text = preg_replace("/\[list=A\](.*?)\[\/list\]/s", '<ul class="listupperalpha">$1</ul>' ,$Text);
+// $Text = preg_replace("/\[li\](.*?)\[\/li\]/s", '<li>$1</li>' ,$Text);
+
+// $Text = preg_replace("/\[td\](.*?)\[\/td\]/s", '<td>$1</td>' ,$Text);
+// $Text = preg_replace("/\[tr\](.*?)\[\/tr\]/s", '<tr>$1</tr>' ,$Text);
+// $Text = preg_replace("/\[table\](.*?)\[\/table\]/s", '<table>$1</table>' ,$Text);
+
+// $Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/s", '<table border="1" >$1</table>' ,$Text);
+// $Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/s", '<table border="0" >$1</table>' ,$Text);
+
+
+// $Text = str_replace("[*]", "<li>", $Text);
+
+ // Check for font change text
+// $Text = preg_replace("(\[font=(.*?)\](.*?)\[\/font\])","<span style=\"font-family: $1;\">$2</span>",$Text);
+
+ // Declare the format for [code] layout
+
+ $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/is",'stripdcode_br_cb',$Text);
+
+// $CodeLayout = '<code>$1</code>';
+ // Check for [code] text
+ $Text = preg_replace("/\[code\](.*?)\[\/code\]/is","```$1```", $Text);
+
+
+
+
+ // Declare the format for [quote] layout
+// $QuoteLayout = '<blockquote>$1</blockquote>';
+ // Check for [quote] text
+// $Text = preg_replace("/\[quote\](.*?)\[\/quote\]/is","$QuoteLayout", $Text);
+
+ // Images
+
+ // html5 video and audio
+
+// $Text = preg_replace("/\[video\](.*?)\[\/video\]/", '<video src="$1" controls="controls" width="425" height="350"><a href="$1">$1</a></video>', $Text);
+
+// $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '<audio src="$1" controls="controls"><a href="$1">$1</a></audio>', $Text);
+
+// $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text);
+
+ // [img=widthxheight]image source[/img]
+// $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/", '<img src="$3" style="height:{$2}px; width:{$1}px;" >', $Text);
+
+// if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){
+// // use oembed for youtube links
+// $Text = preg_replace("/\[youtube\]/",'[embed]',$Text);
+// $Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text);
+// } else {
+// // Youtube extensions
+ // $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
+ // $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
+// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<iframe width="425" height="349" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>', $Text);
+// }
+// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text);
+
+
+
+ // oembed tag
+// $Text = oembed_bbcode2html($Text);
+
+ // If we found an event earlier, strip out all the event code and replace with a reformatted version.
+
+// if(x($ev,'desc') && x($ev,'start')) {
+// $sub = format_event_html($ev);
+
+ // $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text);
+ //$Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text);
+// $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text);
+// $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text);
+// $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text);
+// }
+
+
+
+ call_hooks('bb2diaspora',$Text);
+
+ return $Text;
+}
diff --git a/include/diaspora.php b/include/diaspora.php
index 4420129b0..320f716bf 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -2,6 +2,7 @@
require_once('include/crypto.php');
require_once('include/items.php');
+require_once('include/bb2diaspora.php');
function diaspora_get_contact_by_handle($uid,$handle) {
$r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND `uid` = %d AND `addr` = '%s' LIMIT 1",
@@ -513,7 +514,8 @@ function diaspora_comment($importer,$xml,$msg) {
if($parent_author_signature) {
- $owner_signed_data = $guid . ';' . $parent_guid . ';' . $text . ';' . $msg['author'];
+// $owner_signed_data = $guid . ';' . $parent_guid . ';' . $text . ';' . $msg['author'];
+ $owner_signed_data = $guid . ';' . $parent_guid . ';' . $text . ';' . $diaspora_handle;
$parent_author_signature = base64_decode($parent_author_signature);
@@ -596,6 +598,57 @@ function diaspora_comment($importer,$xml,$msg) {
}
+function diaspora_photo($importer,$xml,$msg) {
+
+ $remote_photo_path = notags(unxmlify($xml->remote_photo_path));
+
+ $remote_photo_name = notags(unxmlify($xml->remote_photo_name));
+
+ $status_message_guid = notags(unxmlify($xml->status_message_guid));
+
+ $guid = notags(unxmlify($xml->guid));
+
+ $diaspora_handle = notags(unxmlify($xml->diaspora_handle));
+
+ $public = notags(unxmlify($xml->public));
+
+ $created_at = notags(unxmlify($xml_created_at));
+
+
+ $contact = diaspora_get_contact_by_handle($importer['uid'],$msg['author']);
+ if(! $contact)
+ return;
+
+ if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
+ logger('diaspora_photo: Ignoring this author.');
+ http_status_exit(202);
+ // NOTREACHED
+ }
+
+ $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
+ intval($importer['uid']),
+ dbesc($status_message_guid)
+ );
+ if(! count($r)) {
+ logger('diaspora_photo: parent item not found: parent: ' . $parent_guid . ' item: ' . $guid);
+ return;
+ }
+ $parent_item = $r[0];
+
+ $link_text = '[img]' . $remote_photo_path . $remote_photo_name . '[/img]' . "\n";
+
+ $r = q("update item set `body` = '%s' where `id` = %d and `uid` = %d limit 1",
+ dbesc($link_text . $parent_item['body']),
+ intval($parent_item['id']),
+ intval($parent_item['uid'])
+ );
+
+ return;
+}
+
+
+
+
function diaspora_like($importer,$xml,$msg) {
$a = get_app();
@@ -682,7 +735,8 @@ function diaspora_like($importer,$xml,$msg) {
}
if($parent_author_signature) {
- $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $msg['author'];
+// $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $msg['author'];
+ $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $diaspora_handle;
$parent_author_signature = base64_decode($parent_author_signature);
@@ -845,9 +899,26 @@ function diaspora_send_status($item,$owner,$contact) {
$a = get_app();
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
$theiraddr = $contact['addr'];
- require_once('include/bbcode.php');
- $body = xmlify(bbcode($item['body']));
+ $images = array();
+
+ $body = $item['body'];
+
+ $cnt = preg_match_all('|\[img\](.*?)\[\/img\]|',$body,$matches,PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ $detail = array();
+ $detail['str'] = $mtch[0];
+ $detail['path'] = dirname($mtch[1]) . '/';
+ $detail['file'] = basename($mtch[1]);
+ $detail['guid'] = $item['guid'];
+ $detail['handle'] = $myaddr;
+ $images[] = $detail;
+ $body = str_replace($detail['str'],t('link'),$body);
+ }
+ }
+
+ $body = xmlify(bb2diaspora($body));
$public = (($item['private']) ? 'false' : 'true');
require_once('include/datetime.php');
@@ -862,17 +933,62 @@ function diaspora_send_status($item,$owner,$contact) {
'$created' => $created
));
- logger('diaspora_send_status: base message: ' . $msg, LOGGER_DATA);
+ logger('diaspora_send_status: ' . $owner['username'] . ' -> ' . $contact['name'] . ' base message: ' . $msg, LOGGER_DATA);
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
post_url($contact['notify'] . '/',$slap);
$return_code = $a->get_curl_code();
logger('diaspora_send_status: returns: ' . $return_code);
+
+ if(count($images)) {
+ diaspora_send_images($item,$owner,$contact,$images);
+ }
+
return $return_code;
}
+function diaspora_send_images($item,$owner,$contact,$images) {
+ $a = get_app();
+ if(! count($images))
+ return;
+ $mysite = substr($a->get_baseurl(),strpos($a->get_baseurl(),'://') + 3) . '/photo';
+
+ $tpl = get_markup_template('diaspora_photo.tpl');
+ foreach($images as $image) {
+ if(! stristr($image['path'],$mysite))
+ continue;
+ $resource = str_replace('.jpg','',$image['file']);
+ $resource = substr($resource,0,strpos($resource,'-'));
+
+ $r = q("select * from photo where `resource-id` = '%s' and `uid` = %d limit 1",
+ dbesc($resource),
+ intval($owner['uid'])
+ );
+ if(! count($r))
+ continue;
+ $public = (($r[0]['allow_cid'] || $r[0]['allow_gid'] || $r[0]['deny_cid'] || $r[0]['deny_gid']) ? 'false' : 'true' );
+ $msg = replace_macros($tpl,array(
+ '$path' => xmlify($image['path']),
+ '$filename' => xmlify($image['file']),
+ '$msg_guid' => xmlify($image['guid']),
+ '$guid' => xmlify($r[0]['guid']),
+ '$handle' => xmlify($image['handle']),
+ '$public' => xmlify($public),
+ '$created_at' => xmlify(datetime_convert('UTC','UTC',$r[0]['created'],'Y-m-d h:i:s \U\T\C'))
+ ));
+
+ logger('diaspora_send_photo: base message: ' . $msg, LOGGER_DATA);
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+
+ post_url($contact['notify'] . '/',$slap);
+ $return_code = $a->get_curl_code();
+ logger('diaspora_send_photo: returns: ' . $return_code);
+ }
+
+}
+
function diaspora_send_followup($item,$owner,$contact) {
$a = get_app();
@@ -898,16 +1014,16 @@ function diaspora_send_followup($item,$owner,$contact) {
$like = false;
}
- $text = bbcode($item['body']);
+ $text = bb2diaspora($item['body']);
// sign it
if($like)
- $signed_text = $item['guid'] . ';' . $target_type . ';' . $positive . ';' . $myaddr;
+ $signed_text = $item['guid'] . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $myaddr;
else
$signed_text = $item['guid'] . ';' . $parent_guid . ';' . $text . ';' . $myaddr;
- $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey']),'sha');
+ $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha'));
$msg = replace_macros($tpl,array(
'$guid' => xmlify($item['guid']),
@@ -966,7 +1082,7 @@ function diaspora_send_relay($item,$owner,$contact) {
$like = false;
}
- $text = bbcode($item['body']);
+ $text = bb2diaspora($item['body']);
// sign it
diff --git a/include/group.php b/include/group.php
index 1ebae7b7b..f21ce42e0 100644
--- a/include/group.php
+++ b/include/group.php
@@ -124,9 +124,10 @@ function group_public_members($gid) {
$r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member`
LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
WHERE `gid` = %d AND `group_member`.`uid` = %d
- AND `contact`.`network` != 'dfrn' AND `contact`.`network` != 'mail' AND `contact`.`network` != 'face' ",
+ AND ( `contact`.`network` = '%s' OR `contact`.`notify` = '' )",
intval($gid),
- intval(local_user())
+ intval(local_user()),
+ dbesc(NETWORK_OSTATUS)
);
if(count($r))
$ret = count($r);
diff --git a/include/notifier.php b/include/notifier.php
index cf8871fb9..1c8245c7a 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -139,7 +139,7 @@ function notifier_run($argv, $argc){
$hub = get_config('system','huburl');
// If this is a public conversation, notify the feed hub
- $notify_hub = true;
+ $public_message = true;
// fill this in with a single salmon slap if applicable
$slap = '';
@@ -153,7 +153,7 @@ function notifier_run($argv, $argc){
if($parent['wall'] == 0 && (! $expire)) {
// local followup to remote post
$followup = true;
- $notify_hub = false; // not public
+ $public_message = false; // not public
$conversant_str = dbesc($parent['contact-id']);
}
else {
@@ -163,7 +163,7 @@ function notifier_run($argv, $argc){
|| (strlen($parent['allow_gid']))
|| (strlen($parent['deny_cid']))
|| (strlen($parent['deny_gid']))) {
- $notify_hub = false; // private recipients, not public
+ $public_message = false; // private recipients, not public
}
$allow_people = expand_acl($parent['allow_cid']);
@@ -177,7 +177,7 @@ function notifier_run($argv, $argc){
$recipients[] = $item['contact-id'];
$conversants[] = $item['contact-id'];
// pull out additional tagged people to notify (if public message)
- if($notify_hub && strlen($item['inform'])) {
+ if($public_message && strlen($item['inform'])) {
$people = explode(',',$item['inform']);
foreach($people as $person) {
if(substr($person,0,4) === 'cid:') {
@@ -241,7 +241,7 @@ function notifier_run($argv, $argc){
));
if($cmd === 'mail') {
- $notify_hub = false; // mail is not public
+ $public_message = false; // mail is not public
$body = fix_private_photos($item['body'],$owner['uid']);
@@ -257,7 +257,7 @@ function notifier_run($argv, $argc){
));
}
elseif($cmd === 'suggest') {
- $notify_hub = false; // suggestions are not public
+ $public_message = false; // suggestions are not public
$sugg_template = get_markup_template('atom_suggest.tpl');
@@ -296,7 +296,7 @@ function notifier_run($argv, $argc){
// private emails may be in included in public conversations. Filter them.
- if(($notify_hub) && $item['private'])
+ if(($public_message) && $item['private'])
continue;
$contact = get_item_contact($item,$contacts);
@@ -305,7 +305,7 @@ function notifier_run($argv, $argc){
$atom .= atom_entry($item,'text',$contact,$owner,true);
- if(($top_level) && ($notify_hub) && ($item['author-link'] === $item['owner-link']) && (! $expire))
+ if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
$slaps[] = atom_entry($item,'html',$contact,$owner,true);
}
}
@@ -403,7 +403,7 @@ function notifier_run($argv, $argc){
// only send salmon if public - e.g. if it's ok to notify
// a public hub, it's ok to send a salmon
- if((count($slaps)) && ($notify_hub) && (! $expire)) {
+ if((count($slaps)) && ($public_message) && (! $expire)) {
logger('notifier: slapdelivery: ' . $contact['name']);
foreach($slaps as $slappy) {
if($contact['notify']) {
@@ -505,12 +505,15 @@ function notifier_run($argv, $argc){
require_once('include/diaspora.php');
if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
break;
+
+ if(! $contact['pubkey'])
+ break;
if($target_item['verb'] === ACTIVITY_DISLIKE) {
// unsupported
break;
}
- elseif($target_item['deleted'] && (! $parent_item['verb'] === ACTIVITY_LIKE)) {
+ elseif(($target_item['deleted']) && ($target_item['verb'] !== ACTIVITY_LIKE)) {
// diaspora delete,
diaspora_send_retraction($target_item,$owner,$contact);
break;
@@ -544,7 +547,7 @@ function notifier_run($argv, $argc){
// send additional slaps to mentioned remote tags (@foo@example.com)
- if($slap && count($url_recipients) && ($followup || $top_level) && $notify_hub && (! $expire)) {
+ if($slap && count($url_recipients) && ($followup || $top_level) && $public_message && (! $expire)) {
if(! get_config('system','dfrn_only')) {
foreach($url_recipients as $url) {
if($url) {
@@ -556,7 +559,7 @@ function notifier_run($argv, $argc){
}
}
- if((strlen($hub)) && ($notify_hub)) {
+ if((strlen($hub)) && ($public_message)) {
$hubs = explode(',', $hub);
if(count($hubs)) {
foreach($hubs as $h) {
@@ -572,12 +575,12 @@ function notifier_run($argv, $argc){
}
}
- if($notify_hub) {
+ if($public_message) {
/**
*
* If you have less than 999 dfrn friends and it's a public message,
- * we'll just go ahead and push them out securely with dfrn/rino.
+ * we'll just go ahead and push them out securely with dfrn/rino or Diaspora.
* If you've got more than that, you'll have to rely on PuSH delivery.
*
*/
@@ -592,9 +595,10 @@ function notifier_run($argv, $argc){
*/
$r = q("SELECT `id`, `name` FROM `contact`
- WHERE `network` = '%s' AND `uid` = %d AND `blocked` = 0 AND `pending` = 0
+ WHERE `network` in ('%s','%s') AND `uid` = %d AND `blocked` = 0 AND `pending` = 0
AND `rel` != %d ",
dbesc(NETWORK_DFRN),
+ dbesc(NETWORK_DIASPORA),
intval($owner['uid']),
intval(CONTACT_IS_SHARING)
);
@@ -607,19 +611,55 @@ function notifier_run($argv, $argc){
/* Don't deliver to folks who have already been delivered to */
- if(! in_array($rr['id'], $conversants)) {
- $n = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
- intval($rr['id'])
- );
+ if(in_array($rr['id'],$conversants))
+ continue;
- if(count($n)) {
+ $n = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
+ intval($rr['id'])
+ );
+
+ if(count($n)) {
+ $contact = $n[0];
+ switch($contact['network']) {
+ case NETWORK_DFRN :
+ logger('notifier: dfrnpubdelivery: ' . $contact['name']);
+ $deliver_status = dfrn_deliver($owner,$contact,$atom);
+ break;
+ case NETWORK_DIASPORA :
+ require_once('include/diaspora.php');
+ if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
+ break;
+
+ if(! $contact['pubkey'])
+ break;
- logger('notifier: dfrnpubdelivery: ' . $n[0]['name']);
- $deliver_status = dfrn_deliver($owner,$n[0],$atom);
+ if($target_item['verb'] === ACTIVITY_DISLIKE) {
+ // unsupported
+ break;
+ }
+ elseif(($target_item['deleted']) && ($target_item['verb'] !== ACTIVITY_LIKE)) {
+ // diaspora delete,
+ diaspora_send_retraction($target_item,$owner,$contact);
+ break;
+ }
+ elseif($followup) {
+ // send comments, likes and retractions of likes to owner to relay
+ diaspora_send_followup($target_item,$owner,$contact);
+ break;
+ }
+ elseif($target_item['parent'] != $target_item['id']) {
+ // we are the relay - send comments, likes and unlikes to our conversants
+ diaspora_send_relay($target_item,$owner,$contact);
+ break;
+ }
+ elseif($top_level) {
+ diaspora_send_status($target_item,$owner,$contact);
+ break;
+ }
+ default:
+ break;
}
}
- else
- logger('notifier: dfrnpubdelivery: ignoring ' . $rr['name']);
}
}
}
diff --git a/include/poller.php b/include/poller.php
index 651736a99..e80b696bf 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -82,12 +82,18 @@ function poller_run($argv, $argc){
if(! $restart)
proc_run('php','include/cronhooks.php');
+ // Only poll from those with suitable relationships,
+ // and which have a polling address and ignore Diaspora since
+ // we are unable to match those posts with a Diaspora GUID and prevent duplicates.
+
$contacts = q("SELECT `id` FROM `contact`
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
+ AND `network` != '%s'
$sql_extra
AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()",
intval(CONTACT_IS_SHARING),
- intval(CONTACT_IS_FRIEND)
+ intval(CONTACT_IS_FRIEND),
+ dbesc(NETWORK_DIASPORA)
);
if(! count($contacts)) {
diff --git a/mod/receive.php b/mod/receive.php
index c3738c143..b50774933 100644
--- a/mod/receive.php
+++ b/mod/receive.php
@@ -63,6 +63,9 @@ function receive_post(&$a) {
elseif($xmlbase->retraction) {
diaspora_retraction($importer,$xmlbase->retraction,$msg);
}
+ elseif($xmlbase->photo) {
+ diaspora_photo($importer,$xmlbase->photo,$msg);
+ }
else {
logger('mod-diaspora: unknown message type: ' . print_r($xmlbase,true));
}
diff --git a/update.php b/update.php
index adfb5fe02..ef036008f 100644
--- a/update.php
+++ b/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1081 );
+define( 'UPDATE_VERSION' , 1082 );
/**
*
@@ -673,4 +673,19 @@ function update_1079() {
function update_1080() {
q("ALTER TABLE `fcontact` ADD `updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'");
-} \ No newline at end of file
+}
+
+function update_1081() {
+ q("ALTER TABLE `photo` ADD `guid` CHAR( 64 ) NOT NULL AFTER `contact`id`,
+ ADD INDEX ( `guid` ) ");
+ $r = q("SELECT distinct(`resource-id`) FROM `photo` WHERE 1 group by `id`");
+ if(count($r)) {
+ foreach($r as $rr) {
+ $guid = get_guid();
+ q("update `photo` set `guid` = '%s' where `resource-id` = '%s'",
+ dbesc($guid),
+ dbesc($rr['resource-id'])
+ );
+ }
+ }
+}
diff --git a/view/api_timeline_atom.tpl b/view/api_timeline_atom.tpl
index 0e427feaa..fb4f51f59 100644
--- a/view/api_timeline_atom.tpl
+++ b/view/api_timeline_atom.tpl
@@ -83,7 +83,7 @@
<poco:primary>true</poco:primary>
</poco:urls>
</author>
- <link rel="ostatus:conversation" href="$status.url"/>
+ <link rel="ostatus:conversation" type="text/html" href="$status.url"/>
</entry>
{{ endfor }}
diff --git a/view/diaspora_photo.tpl b/view/diaspora_photo.tpl
new file mode 100644
index 000000000..75ca7f15c
--- /dev/null
+++ b/view/diaspora_photo.tpl
@@ -0,0 +1,13 @@
+<XML>
+ <post>
+ <photo>
+ <remote_photo_path>$path</remote_photo_path>
+ <remote_photo_name>$filename</remote_photo_name>
+ <status_message_guid>$msg_guid</status_message_guid>
+ <guid>$guid</guid>
+ <diaspora_handle>$handle</diaspora_handle>
+ <public>$public</public>
+ <created_at>$created_at</created_at>
+ </photo>
+ </post>
+</XML> \ No newline at end of file