diaspora - crazy amount of work remaining

This commit is contained in:
friendica 2014-08-19 02:00:34 -07:00
parent b3d450626e
commit dc212c80e2
2 changed files with 64 additions and 81 deletions

View File

@ -671,36 +671,24 @@ function diaspora_post($importer,$xml,$msg) {
return 202; return 202;
} }
$message_id = $diaspora_handle . ':' . $guid; $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `guid` = '%s' LIMIT 1",
intval($importer['channel_id']), intval($importer['channel_id']),
dbesc($message_id),
dbesc($guid) dbesc($guid)
); );
if(count($r)) { if($r) {
// check dates if post editing is implemented
logger('diaspora_post: message exists: ' . $guid); logger('diaspora_post: message exists: ' . $guid);
return; return;
} }
// 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);
$body = diaspora2bb($xml->raw_message); $body = diaspora2bb($xml->raw_message);
//WTF? FIXME
// 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);
$datarray = array(); $datarray = array();
@ -708,6 +696,8 @@ function diaspora_post($importer,$xml,$msg) {
$tags = get_tags($body); $tags = get_tags($body);
// FIXME call handle_tags()
if(count($tags)) { if(count($tags)) {
foreach($tags as $tag) { foreach($tags as $tag) {
if(strpos($tag,'#') === 0) { if(strpos($tag,'#') === 0) {
@ -743,40 +733,36 @@ function diaspora_post($importer,$xml,$msg) {
$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'];
// FIXME
$datarray['contact-id'] = $contact['id']; $datarray['contact-id'] = $contact['id'];
$datarray['wall'] = 0; $datarray['wall'] = 0;
$datarray['network'] = NETWORK_DIASPORA; $datarray['network'] = NETWORK_DIASPORA;
$datarray['verb'] = ACTIVITY_POST; $datarray['verb'] = ACTIVITY_POST;
$datarray['guid'] = $guid; $datarray['mid'] = $datarray['parent-mid'] = $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-link'] = $contact['url']; $datarray['author_xchan'] = $contact['xchan_hash'];
//$datarray['owner-avatar'] = $contact['thumb']; $datarray['owner_xchan'] = $importer['channel_hash'];
$datarray['owner-avatar'] = ((x($contact,'thumb')) ? $contact['thumb'] : $contact['photo']);
$datarray['author-name'] = $contact['name'];
$datarray['author-link'] = $contact['url'];
$datarray['author-avatar'] = $contact['thumb'];
$datarray['body'] = $body; $datarray['body'] = $body;
$datarray['tag'] = $str_tags;
// FIXME
// $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. // if empty content it might be a photo that hasn't arrived yet. If a photo arrives, we'll make it visible.
// $datarray['visible'] = ((strlen($body)) ? 1 : 0);
$datarray['visible'] = ((strlen($body)) ? 1 : 0); $result = item_store($datarray);
$message_id = 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;
} }
@ -1105,20 +1091,20 @@ function diaspora_comment($importer,$xml,$msg) {
return 202; return 202;
} }
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1", $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `mid` = '%s' LIMIT 1",
intval($importer['channel_id']), intval($importer['channel_id']),
dbesc($guid) dbesc($guid)
); );
if(count($r)) { if($r) {
logger('diaspora_comment: our comment just got relayed back to us (or there was a guid collision) : ' . $guid); logger('diaspora_comment: our comment just got relayed back to us (or there was a guid collision) : ' . $guid);
return; return;
} }
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1", $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `mid` = '%s' LIMIT 1",
intval($importer['channel_id']), intval($importer['channel_id']),
dbesc($parent_guid) dbesc($parent_guid)
); );
if(! count($r)) { if(! $r) {
logger('diaspora_comment: parent item not found: parent: ' . $parent_guid . ' item: ' . $guid); logger('diaspora_comment: parent item not found: parent: ' . $parent_guid . ' item: ' . $guid);
return; return;
} }
@ -1183,7 +1169,6 @@ function diaspora_comment($importer,$xml,$msg) {
} }
$body = diaspora2bb($text); $body = diaspora2bb($text);
$message_id = $diaspora_handle . ':' . $guid;
$datarray = array(); $datarray = array();
@ -1216,59 +1201,54 @@ function diaspora_comment($importer,$xml,$msg) {
} }
$datarray['uid'] = $importer['channel_id']; $datarray['uid'] = $importer['channel_id'];
$datarray['contact-id'] = $contact['id'];
$datarray['type'] = 'remote-comment'; //FIXME
$datarray['wall'] = $parent_item['wall']; // $datarray['contact-id'] = $contact['id'];
$datarray['network'] = NETWORK_DIASPORA; // $datarray['type'] = 'remote-comment';
// $datarray['wall'] = $parent_item['wall'];
// $datarray['network'] = NETWORK_DIASPORA;
$datarray['verb'] = ACTIVITY_POST; $datarray['verb'] = ACTIVITY_POST;
$datarray['gravity'] = GRAVITY_COMMENT; $datarray['mid'] = $guid;
$datarray['guid'] = $guid; $datarray['parent_mid'] = $parent_item['mid'];
$datarray['uri'] = $message_id;
$datarray['parent-uri'] = $parent_item['uri'];
// No timestamps for comments? OK, we'll the use current time. // No timestamps for comments? OK, we'll the use current time.
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert(); $datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert();
$datarray['private'] = $parent_item['private']; $datarray['private'] = $parent_item['private'];
$datarray['owner-name'] = $parent_item['owner-name']; $datarray['owner_xchan'] = $parent_item['owner_xchan'];
$datarray['owner-link'] = $parent_item['owner-link']; $datarray['author_xchan'] = $person['xchan_hash'];
$datarray['owner-avatar'] = $parent_item['owner-avatar'];
$datarray['author-name'] = $person['name'];
$datarray['author-link'] = $person['url'];
$datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
$datarray['body'] = $body; $datarray['body'] = $body;
$datarray['tag'] = $str_tags;
// FIXME
// $datarray['tag'] = $str_tags;
// We can't be certain what the original app is if the message is relayed. // We can't be certain what the original app is if the message is relayed.
if(($parent_item['origin']) && (! $parent_author_signature)) // if(($parent_item['origin']) && (! $parent_author_signature))
$datarray['app'] = 'Diaspora'; // $datarray['app'] = 'Diaspora';
$message_id = item_store($datarray); $result = item_store($datarray);
//if($message_id) { // if(($parent_item['origin']) && (! $parent_author_signature)) {
//q("update item set plink = '%s' where id = %d", // q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
// //dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id), // intval($message_id),
// dbesc($a->get_baseurl().'/display/'.$datarray['guid']), // dbesc($signed_data),
// intval($message_id) // dbesc(base64_encode($author_signature)),
//); // dbesc($diaspora_handle)
//} // );
if(($parent_item['origin']) && (! $parent_author_signature)) {
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($message_id),
dbesc($signed_data),
dbesc(base64_encode($author_signature)),
dbesc($diaspora_handle)
);
// if the message isn't already being relayed, notify others // if the message isn't already being relayed, notify others
// the existence of parent_author_signature means the parent_author or owner // the existence of parent_author_signature means the parent_author or owner
// is already relaying. // is already relaying.
proc_run('php','include/notifier.php','comment-import',$message_id); // proc_run('php','include/notifier.php','comment-import',$message_id);
} // }
// FIXME
/*
$myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0 ", $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']), dbesc($parent_item['uri']),
intval($importer['channel_id']) intval($importer['channel_id'])
@ -1311,6 +1291,9 @@ function diaspora_comment($importer,$xml,$msg) {
break; break;
} }
} }
*/
return; return;
} }

View File

@ -1 +1 @@
2014-08-18.771 2014-08-19.772