function diaspora_post($importer,$xml) {
+ $a = get_app();
$guid = notags(unxmlify($xml->guid));
$diaspora_handle = notags(unxmlify($xml->diaspora_handle));
dbesc($message_id),
dbesc($guid)
);
- if(count($r))
+ if(count($r)) {
+ logger('diaspora_post: message exists: ' . $guid);
return;
+ }
// allocate a guid on our system - we aren't fixing any collisions.
// we're ignoring them
$datarray['body'] = $body;
$datarray['app'] = 'Diaspora';
- item_store($datarray);
+ $message_id = item_store($datarray);
+
+ if($message_id) {
+ q("update item set plink = '%s' where id = %d limit 1",
+ dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
+ intval($message_id)
+ );
+ }
return;
function diaspora_comment($importer,$xml,$msg) {
+ $a = get_app();
$guid = notags(unxmlify($xml->guid));
$parent_guid = notags(unxmlify($xml->parent_guid));
$diaspora_handle = notags(unxmlify($xml->diaspora_handle));
$text = $xml->text;
$contact = diaspora_get_contact_by_handle($importer['uid'],$msg['author']);
- if(! $contact)
+ if(! $contact) {
+ logger('diaspora_comment: cannot find contact: ' . $msg['author']);
return;
+ }
if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
logger('diaspora_comment: Ignoring this author.');
dbesc($guid)
);
if(count($r)) {
- logger('daspora_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;
}
$message_id = item_store($datarray);
+ if($message_id) {
+ q("update item set plink = '%s' where id = %d limit 1",
+ dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
+ intval($message_id)
+ );
+ }
+
if(! $parent_author_signature) {
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($message_id),
function diaspora_photo($importer,$xml,$msg) {
+ $a = get_app();
$remote_photo_path = notags(unxmlify($xml->remote_photo_path));
$remote_photo_name = notags(unxmlify($xml->remote_photo_name));
return;
$contact = diaspora_get_contact_by_handle($importer['uid'],$msg['author']);
- if(! $contact)
+ if(! $contact) {
+ logger('diaspora_like: cannot find contact: ' . $msg['author']);
return;
+ }
if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
logger('diaspora_like: Ignoring this author.');
}
if($parent_author_signature) {
-// $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $msg['author'];
- $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $diaspora_handle;
+
+ $owner_signed_data = $guid . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $diaspora_handle;
$parent_author_signature = base64_decode($parent_author_signature);
$message_id = item_store($arr);
+
+ if($message_id) {
+ q("update item set plink = '%s' where id = %d limit 1",
+ dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id),
+ intval($message_id)
+ );
+ }
+
if(! $parent_author_signature) {
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($message_id),
$public = (($item['private']) ? 'false' : 'true');
require_once('include/datetime.php');
- $created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d h:i:s \U\T\C');
+ $created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C');
$tpl = get_markup_template('diaspora_post.tpl');
$msg = replace_macros($tpl, array(
'$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'))
+ '$created_at' => xmlify(datetime_convert('UTC','UTC',$r[0]['created'],'Y-m-d H:i:s \U\T\C'))
));
$text = html_entity_decode(bb2diaspora($body));
// fetch the original signature if somebody sent the post to us to relay
- // If we are relaying for a reply originating here, there wasn't a 'send to relay'
+ // If we are relaying for a reply originating on our own account, there wasn't a 'send to relay'
// action. It wasn't needed. In that case create the original signature and the
// owner (parent author) signature
+ // comments from other networks will be relayed under our name, with a brief
+ // preamble to describe what's happening and noting the real author
$r = q("select * from sign where iid = %d limit 1",
intval($item['id'])
$orig_sign = $r[0];
$signed_text = $orig_sign['signed_text'];
$authorsig = $orig_sign['signature'];
+ $handle = $orig_sign['signer'];
}
else {
dbesc(base64_encode($authorsig)),
dbesc($myaddr)
);
-
+ $handle = $myaddr;
}
}
'$parentsig' => xmlify($parentauthorsig),
'$body' => xmlify($text),
'$positive' => xmlify($positive),
- '$handle' => xmlify($myaddr)
+ '$handle' => xmlify($handle)
));
logger('diaspora_relay_comment: base message: ' . $msg, LOGGER_DATA);