mind numbing drudgery continued...
This commit is contained in:
parent
bbcf0be16a
commit
eb27bea794
2
boot.php
2
boot.php
@ -47,7 +47,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' );
|
|||||||
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
|
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
|
||||||
define ( 'ZOT_REVISION', 1 );
|
define ( 'ZOT_REVISION', 1 );
|
||||||
|
|
||||||
define ( 'DB_UPDATE_VERSION', 1126 );
|
define ( 'DB_UPDATE_VERSION', 1127 );
|
||||||
|
|
||||||
define ( 'EOL', '<br />' . "\r\n" );
|
define ( 'EOL', '<br />' . "\r\n" );
|
||||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||||
|
@ -772,10 +772,13 @@ function diaspora_post($importer,$xml,$msg) {
|
|||||||
return 202;
|
return 202;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
|
$search_guid = ((strlen($guid) == 64) ? $guid . '%' : $guid);
|
||||||
|
|
||||||
|
$r = q("SELECT id FROM item WHERE uid = %d AND mid like '%s' LIMIT 1",
|
||||||
intval($importer['channel_id']),
|
intval($importer['channel_id']),
|
||||||
dbesc($guid)
|
dbesc($search_guid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
// check dates if post editing is implemented
|
// check dates if post editing is implemented
|
||||||
logger('diaspora_post: message exists: ' . $guid);
|
logger('diaspora_post: message exists: ' . $guid);
|
||||||
@ -797,9 +800,6 @@ function diaspora_post($importer,$xml,$msg) {
|
|||||||
$tags = get_tags($body);
|
$tags = get_tags($body);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(count($tags)) {
|
if(count($tags)) {
|
||||||
|
|
||||||
$datarray['term'] = array();
|
$datarray['term'] = array();
|
||||||
@ -843,6 +843,7 @@ function diaspora_post($importer,$xml,$msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this won't work for Friendica or Redmatrix but it's probably the best we can do.
|
||||||
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
|
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
|
||||||
|
|
||||||
$datarray['uid'] = $importer['channel_id'];
|
$datarray['uid'] = $importer['channel_id'];
|
||||||
@ -893,13 +894,12 @@ function diaspora_reshare($importer,$xml,$msg) {
|
|||||||
return 202;
|
return 202;
|
||||||
}
|
}
|
||||||
|
|
||||||
$message_id = $diaspora_handle . ':' . $guid;
|
$search_guid = ((strlen($guid) == 64) ? $guid . '%' : $guid);
|
||||||
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `guid` = '%s' LIMIT 1",
|
$r = q("SELECT id FROM item WHERE uid = %d AND mid like '%s' LIMIT 1",
|
||||||
intval($importer['channel_id']),
|
intval($importer['channel_id']),
|
||||||
dbesc($message_id),
|
dbesc($search_guid)
|
||||||
dbesc($guid)
|
|
||||||
);
|
);
|
||||||
if(count($r)) {
|
if($r) {
|
||||||
logger('diaspora_reshare: message exists: ' . $guid);
|
logger('diaspora_reshare: message exists: ' . $guid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -909,16 +909,17 @@ function diaspora_reshare($importer,$xml,$msg) {
|
|||||||
|
|
||||||
$source_url = 'https://' . substr($orig_author,strpos($orig_author,'@')+1) . '/p/' . $orig_guid . '.xml';
|
$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;
|
$orig_url = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid;
|
||||||
$x = fetch_url($source_url);
|
$x = z_fetch_url($source_url);
|
||||||
if(! $x)
|
if(! $x['success'])
|
||||||
$x = fetch_url(str_replace('https://','http://',$source_url));
|
$x = z_fetch_url(str_replace('https://','http://',$source_url));
|
||||||
if(! $x) {
|
if(! $x['success']) {
|
||||||
logger('diaspora_reshare: unable to fetch source url ' . $source_url);
|
logger('diaspora_reshare: unable to fetch source url ' . $source_url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger('diaspora_reshare: source: ' . $x);
|
logger('diaspora_reshare: source: ' . $x['body']);
|
||||||
|
|
||||||
|
$x = str_replace(array('<activity_streams-photo>','</activity_streams-photo>'),array('<asphoto>','</asphoto>'),$x['body']);
|
||||||
|
|
||||||
$x = str_replace(array('<activity_streams-photo>','</activity_streams-photo>'),array('<asphoto>','</asphoto>'),$x);
|
|
||||||
$source_xml = parse_xml_string($x,false);
|
$source_xml = parse_xml_string($x,false);
|
||||||
|
|
||||||
if(strlen($source_xml->post->asphoto->objectId) && ($source_xml->post->asphoto->objectId != 0) && ($source_xml->post->asphoto->image_url)) {
|
if(strlen($source_xml->post->asphoto->objectId) && ($source_xml->post->asphoto->objectId != 0) && ($source_xml->post->asphoto->image_url)) {
|
||||||
@ -947,7 +948,7 @@ function diaspora_reshare($importer,$xml,$msg) {
|
|||||||
$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 = add_page_info_to_body($body, false, true);
|
// $body = add_page_info_to_body($body, false, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Maybe it is a reshare of a photo that will be delivered at a later time (testing)
|
// Maybe it is a reshare of a photo that will be delivered at a later time (testing)
|
||||||
@ -971,18 +972,6 @@ function diaspora_reshare($importer,$xml,$msg) {
|
|||||||
$prefix = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . $details . "\n";*/
|
$prefix = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . $details . "\n";*/
|
||||||
|
|
||||||
|
|
||||||
// allocate a guid on our system - we aren't fixing any collisions.
|
|
||||||
// we're ignoring them
|
|
||||||
|
|
||||||
$g = q("select * from guid where guid = '%s' limit 1",
|
|
||||||
dbesc($guid)
|
|
||||||
);
|
|
||||||
if(! count($g)) {
|
|
||||||
q("insert into guid ( guid ) values ( '%s' )",
|
|
||||||
dbesc($guid)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$created = unxmlify($xml->created_at);
|
$created = unxmlify($xml->created_at);
|
||||||
$private = ((unxmlify($xml->public) == 'false') ? 1 : 0);
|
$private = ((unxmlify($xml->public) == 'false') ? 1 : 0);
|
||||||
|
|
||||||
@ -992,7 +981,11 @@ function diaspora_reshare($importer,$xml,$msg) {
|
|||||||
|
|
||||||
$tags = get_tags($body);
|
$tags = get_tags($body);
|
||||||
|
|
||||||
|
|
||||||
if(count($tags)) {
|
if(count($tags)) {
|
||||||
|
|
||||||
|
$datarray['term'] = array();
|
||||||
|
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
if(strpos($tag,'#') === 0) {
|
if(strpos($tag,'#') === 0) {
|
||||||
if(strpos($tag,'[url='))
|
if(strpos($tag,'[url='))
|
||||||
@ -1005,63 +998,49 @@ function diaspora_reshare($importer,$xml,$msg) {
|
|||||||
if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
|
if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag,'/') . '(.*?)\)/',$body))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
$basetag = str_replace('_',' ',substr($tag,1));
|
$basetag = str_replace('_',' ',substr($tag,1));
|
||||||
$body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
|
$body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
|
||||||
if(strlen($str_tags))
|
|
||||||
$str_tags .= ',';
|
$datarray['term'][] = array(
|
||||||
$str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
|
'uid' => $importer['channel_id'],
|
||||||
continue;
|
'type' => TERM_HASHTAG,
|
||||||
|
'otype' => TERM_OBJ_POST,
|
||||||
|
'term' => $basetag,
|
||||||
|
'url' => z_root() . '/search?tag=' . rawurlencode($basetag)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cnt = preg_match_all('/@\[url=(.*?)\](.*?)\[\/url\]/ism',$body,$matches,PREG_SET_ORDER);
|
||||||
|
if($cnt) {
|
||||||
|
foreach($matches as $mtch) {
|
||||||
|
$datarray['term'][] = array(
|
||||||
|
'uid' => $importer['channel_id'],
|
||||||
|
'type' => TERM_MENTION,
|
||||||
|
'otype' => TERM_OBJ_POST,
|
||||||
|
'term' => $mtch[2],
|
||||||
|
'url' => $mtch[1]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This won't work
|
||||||
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
|
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
|
||||||
|
|
||||||
$datarray['uid'] = $importer['channel_id'];
|
$datarray['uid'] = $importer['channel_id'];
|
||||||
$datarray['contact-id'] = $contact['id'];
|
$datarray['mid'] = $datarray['parent_mid'] = $guid;
|
||||||
$datarray['wall'] = 0;
|
|
||||||
$datarray['network'] = NETWORK_DIASPORA;
|
|
||||||
$datarray['guid'] = $guid;
|
|
||||||
$datarray['uri'] = $datarray['parent-uri'] = $message_id;
|
|
||||||
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
|
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
|
||||||
$datarray['private'] = $private;
|
$datarray['item_private'] = $private;
|
||||||
$datarray['parent'] = 0;
|
|
||||||
$datarray['plink'] = $plink;
|
$datarray['plink'] = $plink;
|
||||||
$datarray['owner-name'] = $contact['name'];
|
$datarray['owner_xchan'] = $contact['xchan_hash'];
|
||||||
$datarray['owner-link'] = $contact['url'];
|
$datarray['author_xchan'] = $person['xchan_hash'];
|
||||||
$datarray['owner-avatar'] = ((x($contact,'thumb')) ? $contact['thumb'] : $contact['photo']);
|
|
||||||
if (!intval(get_config('system','wall-to-wall_share'))) {
|
|
||||||
$prefix = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$person['name']).
|
|
||||||
"' profile='".$person['url'].
|
|
||||||
"' avatar='".((x($person,'thumb')) ? $person['thumb'] : $person['photo']).
|
|
||||||
"' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$orig_url)."']";
|
|
||||||
$datarray['author-name'] = $contact['name'];
|
|
||||||
$datarray['author-link'] = $contact['url'];
|
|
||||||
$datarray['author-avatar'] = $contact['thumb'];
|
|
||||||
$datarray['body'] = $prefix.$body."[/share]";
|
|
||||||
} else {
|
|
||||||
// Let reshared messages look like wall-to-wall posts
|
|
||||||
$datarray['author-name'] = $person['name'];
|
|
||||||
$datarray['author-link'] = $person['url'];
|
|
||||||
$datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
|
|
||||||
$datarray['body'] = $body;
|
|
||||||
}
|
|
||||||
|
|
||||||
$datarray['tag'] = $str_tags;
|
$datarray['body'] = $body;
|
||||||
$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);
|
$result = item_store($datarray);
|
||||||
|
|
||||||
//if($message_id) {
|
|
||||||
// q("update item set plink = '%s' where id = %d",
|
|
||||||
// dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
|
|
||||||
// intval($message_id)
|
|
||||||
// );
|
|
||||||
//}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1460,7 +1439,6 @@ function diaspora_conversation($importer,$xml,$msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$body = diaspora2bb($msg_text);
|
$body = diaspora2bb($msg_text);
|
||||||
$message_id = $msg_diaspora_handle . ':' . $msg_guid;
|
|
||||||
|
|
||||||
$author_signed_data = $msg_guid . ';' . $msg_parent_guid . ';' . $msg_text . ';' . unxmlify($mesg->created_at) . ';' . $msg_diaspora_handle . ';' . $msg_conversation_guid;
|
$author_signed_data = $msg_guid . ';' . $msg_parent_guid . ';' . $msg_text . ';' . unxmlify($mesg->created_at) . ';' . $msg_diaspora_handle . ';' . $msg_conversation_guid;
|
||||||
|
|
||||||
@ -1473,8 +1451,8 @@ function diaspora_conversation($importer,$xml,$msg) {
|
|||||||
else {
|
else {
|
||||||
$person = find_diaspora_person_by_handle($msg_diaspora_handle);
|
$person = find_diaspora_person_by_handle($msg_diaspora_handle);
|
||||||
|
|
||||||
if(is_array($person) && x($person,'pubkey'))
|
if(is_array($person) && x($person,'xchan_pubkey'))
|
||||||
$key = $person['pubkey'];
|
$key = $person['xchan_pubkey'];
|
||||||
else {
|
else {
|
||||||
logger('diaspora_conversation: unable to find author details');
|
logger('diaspora_conversation: unable to find author details');
|
||||||
continue;
|
continue;
|
||||||
@ -1499,7 +1477,7 @@ function diaspora_conversation($importer,$xml,$msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("select id from mail where `uri` = '%s' limit 1",
|
$r = q("select id from mail where mid = '%s' limit 1",
|
||||||
dbesc($message_id)
|
dbesc($message_id)
|
||||||
);
|
);
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
@ -1507,19 +1485,15 @@ function diaspora_conversation($importer,$xml,$msg) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
q("insert into mail ( `uid`, `guid`, `convid`, `from-name`,`from-photo`,`from-url`,`contact-id`,`title`,`body`,`seen`,`reply`,`uri`,`parent-uri`,`created`) values ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s','%s','%s')",
|
q("insert into mail ( `uid`, `convid`, `from_xchan`,`to_xchan`,`title`,`body`,`mail_flags`,`mid`,`parent_mid`,`created`) values ( %d, %d, '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s')",
|
||||||
intval($importer['channel_id']),
|
intval($importer['channel_id']),
|
||||||
dbesc($msg_guid),
|
|
||||||
intval($conversation['id']),
|
intval($conversation['id']),
|
||||||
dbesc($person['name']),
|
dbesc($person['xchan_hash']),
|
||||||
dbesc($person['photo']),
|
dbesc($importer['channel_hash']),
|
||||||
dbesc($person['url']),
|
|
||||||
intval($contact['id']),
|
|
||||||
dbesc($subject),
|
dbesc($subject),
|
||||||
dbesc($body),
|
dbesc($body),
|
||||||
0,
|
0,
|
||||||
0,
|
dbesc($msg_guid),
|
||||||
dbesc($message_id),
|
|
||||||
dbesc($parent_uri),
|
dbesc($parent_uri),
|
||||||
dbesc($msg_created_at)
|
dbesc($msg_created_at)
|
||||||
);
|
);
|
||||||
@ -1530,6 +1504,9 @@ function diaspora_conversation($importer,$xml,$msg) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
require_once('include/enotify.php');
|
require_once('include/enotify.php');
|
||||||
|
/******
|
||||||
|
//FIXME
|
||||||
|
|
||||||
notification(array(
|
notification(array(
|
||||||
'type' => NOTIFY_MAIL,
|
'type' => NOTIFY_MAIL,
|
||||||
'notify_flags' => $importer['notify-flags'],
|
'notify_flags' => $importer['notify-flags'],
|
||||||
@ -1544,6 +1521,8 @@ function diaspora_conversation($importer,$xml,$msg) {
|
|||||||
'verb' => ACTIVITY_POST,
|
'verb' => ACTIVITY_POST,
|
||||||
'otype' => 'mail'
|
'otype' => 'mail'
|
||||||
));
|
));
|
||||||
|
*******/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -615,6 +615,7 @@ CREATE TABLE IF NOT EXISTS `likes` (
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `mail` (
|
CREATE TABLE IF NOT EXISTS `mail` (
|
||||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`convid` int(10) unsigned NOT NULL DEFAULT '0',
|
||||||
`mail_flags` int(10) unsigned NOT NULL DEFAULT '0',
|
`mail_flags` int(10) unsigned NOT NULL DEFAULT '0',
|
||||||
`from_xchan` char(255) NOT NULL DEFAULT '',
|
`from_xchan` char(255) NOT NULL DEFAULT '',
|
||||||
`to_xchan` char(255) NOT NULL DEFAULT '',
|
`to_xchan` char(255) NOT NULL DEFAULT '',
|
||||||
@ -628,6 +629,7 @@ CREATE TABLE IF NOT EXISTS `mail` (
|
|||||||
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
`expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `convid` (`convid`),
|
||||||
KEY `created` (`created`),
|
KEY `created` (`created`),
|
||||||
KEY `mail_flags` (`mail_flags`),
|
KEY `mail_flags` (`mail_flags`),
|
||||||
KEY `account_id` (`account_id`),
|
KEY `account_id` (`account_id`),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
define( 'UPDATE_VERSION' , 1126 );
|
define( 'UPDATE_VERSION' , 1127 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -1430,3 +1430,13 @@ function update_r1125() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function update_r1126() {
|
||||||
|
$r = q("ALTER TABLE `mail` ADD `convid` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `id` ,
|
||||||
|
ADD INDEX ( `convid` )");
|
||||||
|
if($r)
|
||||||
|
return UPDATE_SUCCESS;
|
||||||
|
return UPDATE_FAILED;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user