diff options
Diffstat (limited to 'include/diaspora.php')
-rwxr-xr-x | include/diaspora.php | 69 |
1 files changed, 27 insertions, 42 deletions
diff --git a/include/diaspora.php b/include/diaspora.php index 33ad4211b..18e131f8f 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -24,9 +24,8 @@ function diaspora_dispatch_public($msg) { // find everybody following or allowing this author - $r = q("SELECT * from channel where channel_id in ( SELECT abook_channel from abook left join xchan on abook_xchan = xchan_hash WHERE xchan_network like '%%diaspora%%' and xchan_addr = '%s' ) and ( channel_pageflags & %d ) = 0 ", - dbesc($msg['author']), - intval(PAGE_REMOVED) + $r = q("SELECT * from channel where channel_id in ( SELECT abook_channel from abook left join xchan on abook_xchan = xchan_hash WHERE xchan_network like '%%diaspora%%' and xchan_addr = '%s' ) and channel_removed = 0 ", + dbesc($msg['author']) ); // also need to look for those following public streams @@ -65,8 +64,6 @@ function diaspora_dispatch($importer,$msg) { } $allowed = get_pconfig($importer['channel_id'],'system','diaspora_allowed'); - if($allowed === false) - $allowed = 1; if(! intval($allowed)) { logger('mod-diaspora: disallowed for channel ' . $importer['channel_name']); @@ -179,8 +176,6 @@ function diaspora_process_outbound($arr) { $allowed = get_pconfig($arr['channel']['channel_id'],'system','diaspora_allowed'); - if($allowed === false) - $allowed = 1; if(! intval($allowed)) { logger('mod-diaspora: disallowed for channel ' . $arr['channel']['channel_name']); @@ -194,7 +189,7 @@ function diaspora_process_outbound($arr) { $target_item = $arr['target_item']; - if($target_item && array_key_exists('item_flags',$target_item) && ($target_item['item_flags'] & ITEM_OBSCURED)) { + if($target_item && array_key_exists('item_obscured',$target_item) && intval($target_item['item_obscured'])) { $key = get_config('system','prvkey'); if($target_item['title']) $target_item['title'] = crypto_unencapsulate(json_decode($target_item['title'],true),$key); @@ -243,7 +238,7 @@ function diaspora_process_outbound($arr) { if(! $contact['xchan_pubkey']) continue; - if(($target_item['item_restrict'] & ITEM_DELETED) + if(intval($target_item['item_deleted']) && (($target_item['mid'] === $target_item['parent_mid']) || $arr['followup'])) { // send both top-level retractions and relayable retractions for owner to relay diaspora_send_retraction($target_item,$arr['channel'],$contact); @@ -272,8 +267,8 @@ function diaspora_process_outbound($arr) { $contact = $arr['hub']; - if(($target_item['deleted']) - && ($target_item['mid'] === $target_item['parent_mod'])) { + if(intval($target_item['item_deleted']) + && ($target_item['mid'] === $target_item['parent_mid'])) { // top-level retraction logger('delivery: diaspora retract: ' . $loc); diaspora_send_retraction($target_item,$arr['channel'],$contact,true); @@ -349,7 +344,7 @@ function find_diaspora_person_by_handle($handle) { if(! $person) { // try webfinger. Make sure to distinguish between diaspora, - // redmatrix w/diaspora protocol and friendica w/diaspora protocol. + // hubzilla w/diaspora protocol and friendica w/diaspora protocol. $result = discover_by_webbie($handle); if($result) { @@ -728,6 +723,7 @@ function diaspora_request($importer,$xml) { $msg = t('You have started sharing with a $Projectname premium channel.'); $msg .= t('$Projectname premium channels are not available for sharing with Diaspora members. This sharing request has been blocked.') . "\r"; + $msg .= t('Please do not reply to this message, as this channel is not sharing with you and any reply will not be seen by the recipient.') . "\r"; $created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C'); @@ -786,7 +782,7 @@ function diaspora_request($importer,$xml) { $closeness = 80; - $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_my_perms, abook_their_perms, abook_closeness, abook_rating, abook_created, abook_updated, abook_connected, abook_dob, abook_flags) values ( %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', %d )", + $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_my_perms, abook_their_perms, abook_closeness, abook_rating, abook_created, abook_updated, abook_connected, abook_dob, abook_pending) values ( %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', %d )", intval($importer['channel_account_id']), intval($importer['channel_id']), dbesc($ret['xchan_hash']), @@ -798,7 +794,7 @@ function diaspora_request($importer,$xml) { dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(NULL_DATE), - intval(($default_perms) ? 0 : ABOOK_FLAG_PENDING) + intval(($default_perms) ? 0 : 1) ); @@ -984,9 +980,8 @@ function diaspora_post($importer,$xml,$msg) { $datarray['app'] = $app; - $datarray['item_flags'] = ITEM_THREAD_TOP; $datarray['item_unseen'] = 1; - + $datarray['item_thread_top'] = 1; $tgroup = tgroup_check($importer['channel_id'],$datarray); @@ -995,7 +990,6 @@ function diaspora_post($importer,$xml,$msg) { return 202; } - $result = item_store($datarray); return; @@ -1543,7 +1537,7 @@ function diaspora_comment($importer,$xml,$msg) { $key = get_config('system','pubkey'); $x = array('signer' => $diaspora_handle, 'body' => $text, 'signed_text' => $signed_data, 'signature' => base64_encode($author_signature)); - $datarray['diaspora_meta'] = json_encode(crypto_encapsulate(json_encode($x),$key)); + $datarray['diaspora_meta'] = json_encode($x); } @@ -1567,7 +1561,7 @@ function diaspora_comment($importer,$xml,$msg) { if($result && $result['success']) $message_id = $result['item_id']; - if(($parent_item['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) { + if(intval($parent_item['item_origin']) && (! $parent_author_signature)) { // if the message isn't already being relayed, notify others // the existence of parent_author_signature means the parent_author or owner // is already relaying. @@ -1724,11 +1718,10 @@ function diaspora_conversation($importer,$xml,$msg) { continue; } - $key = get_config('system','pubkey'); if($subject) - $subject = json_encode(crypto_encapsulate($subject,$key)); + $subject = str_rot47(base64url_encode($subject)); if($body) - $body = json_encode(crypto_encapsulate($body,$key)); + $body = str_rot47(base64url_encode($body)); q("insert into mail ( `channel_id`, `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']), @@ -1858,9 +1851,9 @@ function diaspora_message($importer,$xml,$msg) { $key = get_config('system','pubkey'); if($subject) - $subject = json_encode(crypto_encapsulate($subject,$key)); + $subject = str_rot47(base64url_encode($subject)); if($body) - $body = json_encode(crypto_encapsulate($body,$key)); + $body = str_rot47(base64url_encode($body)); q("insert into mail ( `channel_id`, `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']), @@ -2157,7 +2150,7 @@ function diaspora_like($importer,$xml,$msg) { $key = get_config('system','pubkey'); $x = array('signer' => $diaspora_handle, 'body' => $text, 'signed_text' => $signed_data, 'signature' => base64_encode($author_signature)); - $arr['diaspora_meta'] = json_encode(crypto_encapsulate(json_encode($x),$key)); + $arr['diaspora_meta'] = json_encode($x); } $x = item_store($arr); @@ -2169,7 +2162,7 @@ function diaspora_like($importer,$xml,$msg) { // the existence of parent_author_signature means the parent_author or owner // is already relaying. The parent_item['origin'] indicates the message was created on our system - if(($parent_item['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) + if(intval($parent_item['item_origin']) && (! $parent_author_signature)) proc_run('php','include/notifier.php','comment-import',$message_id); return; @@ -2278,19 +2271,12 @@ function diaspora_signed_retraction($importer,$xml,$msg) { $r[0]['parent'] ); if($p) { - if(($p[0]['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) { -// FIXME so we can relay this -// q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", -// $r[0]['id'], -// dbesc($signed_data), -// dbesc($sig), -// dbesc($diaspora_handle) -// ); + if(intval($p[0]['item_origin']) && (! $parent_author_signature)) { // the existence of parent_author_signature would have meant the parent_author or owner // is already relaying. - logger('diaspora_signed_retraction: relaying relayable_retraction'); + logger('diaspora_signed_retraction: relaying relayable_retraction'); proc_run('php','include/notifier.php','drop',$r[0]['id']); } } @@ -2636,7 +2622,7 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) { $target_type = 'Post'; $positive = 'true'; - if(($item_['item_restrict'] & ITEM_DELETED)) + if(intval($item['item_deleted'])) logger('diaspora_send_followup: received deleted "like". Those should go to diaspora_send_retraction'); } else { @@ -2732,7 +2718,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { $relay_retract = false; $sql_sign_id = 'iid'; - if( $item['item_restrict'] & ITEM_DELETED) { + if( intval($item['item_deleted'])) { $relay_retract = true; $target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment'); @@ -2744,7 +2730,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { $like = true; $target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment'); -// $positive = (($item['item_restrict'] & ITEM_DELETED) ? 'false' : 'true'); +// $positive = (intval($item['item_deleted']) ? 'false' : 'true'); $positive = 'true'; $tpl = get_markup_template('diaspora_like_relay.tpl'); @@ -2894,11 +2880,10 @@ function diaspora_send_mail($item,$owner,$contact) { ); if(array_key_exists('mail_flags',$item) && ($item['mail_flags'] & MAIL_OBSCURED)) { - $key = get_config('system','prvkey'); -// if($item['title']) -// $item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key); + if($item['title']) + $item['title'] = base64url_decode(str_rot47($item['title'])); if($item['body']) - $item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key); + $item['body'] = base64url_decode(str_rot47($item['body'])); } |