diff options
author | friendica <info@friendica.com> | 2014-08-25 22:43:44 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-08-25 22:43:44 -0700 |
commit | 6e99848043d198af5013c2439e7a2d16d8a32c52 (patch) | |
tree | 83c1b8471605dadc9d810d01fb08e81658cadce1 | |
parent | eb8f194419975a6cd3debba145c8769da055b8dc (diff) | |
download | volse-hubzilla-6e99848043d198af5013c2439e7a2d16d8a32c52.tar.gz volse-hubzilla-6e99848043d198af5013c2439e7a2d16d8a32c52.tar.bz2 volse-hubzilla-6e99848043d198af5013c2439e7a2d16d8a32c52.zip |
more diaspora stuff - most of the basic bits are there except queueing and physical delivery (I'm keeping delivery turned off until some of the bugs are fixed so we don't cause inifinite loops or network meltdowns) - now it's just a matter of going through and methodically finding all the bugs
-rwxr-xr-x | include/diaspora.php | 47 | ||||
-rwxr-xr-x | include/items.php | 1 | ||||
-rw-r--r-- | include/notifier.php | 2 | ||||
-rw-r--r-- | view/tpl/diaspora_comment.tpl | 16 | ||||
-rw-r--r-- | view/tpl/diaspora_comment_relay.tpl | 17 | ||||
-rw-r--r-- | view/tpl/diaspora_conversation.tpl | 34 | ||||
-rw-r--r-- | view/tpl/diaspora_like.tpl | 17 | ||||
-rw-r--r-- | view/tpl/diaspora_like_relay.tpl | 18 | ||||
-rw-r--r-- | view/tpl/diaspora_message.tpl | 18 | ||||
-rw-r--r-- | view/tpl/diaspora_photo.tpl | 18 | ||||
-rw-r--r-- | view/tpl/diaspora_post.tpl | 12 | ||||
-rw-r--r-- | view/tpl/diaspora_profile.tpl | 21 | ||||
-rw-r--r-- | view/tpl/diaspora_relay_retraction.tpl | 15 | ||||
-rw-r--r-- | view/tpl/diaspora_relayable_retraction.tpl | 16 | ||||
-rw-r--r-- | view/tpl/diaspora_reshare.tpl | 18 | ||||
-rw-r--r-- | view/tpl/diaspora_retract.tpl | 14 | ||||
-rw-r--r-- | view/tpl/diaspora_share.tpl | 13 | ||||
-rw-r--r-- | view/tpl/diaspora_signed_retract.tpl | 15 |
18 files changed, 300 insertions, 12 deletions
diff --git a/include/diaspora.php b/include/diaspora.php index ebd1906f3..1e101b4a7 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -153,9 +153,9 @@ function diaspora_process_outbound($arr) { if($arr['walltowall']) return; - if($arr['recipients']) { + if($arr['env_recips']) { $r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url = '%s' - and xchan_hash in (" . implode(',',$arr['recipients']) . ") + and xchan_hash in (" . implode(',',$arr['env_recips']) . ") and xchan_network in ('diaspora', 'friendica-over-diaspora') ", dbesc($arr['hub']['hubloc_url']) ); @@ -228,13 +228,13 @@ function diaspora_process_outbound($arr) { diaspora_send_retraction($arr['target_item'],$arr['channel'],$contact,true); return; } - elseif($arr['target_item']['mid'] !== $mid['target_item']['parent_mid']) { + elseif($arr['target_item']['mid'] !== $arr['target_item']['parent_mid']) { // we are the relay - send comments, likes and relayable_retractions to our conversants logger('delivery: diaspora relay: ' . $loc); diaspora_send_relay($arr['target_item'],$arr['channel'],$contact,true); return; } - elseif(($arr['top_level_post']) && (! $arr['walltowall'])) { + elseif($arr['top_level_post']) { // currently no workable solution for sending walltowall logger('delivery: diaspora status: ' . $loc); diaspora_send_status($arr['target_item'],$arr['channel'],$contact,true); @@ -2241,12 +2241,38 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { } */ - //if(strlen($title)) - // $body = "[b]".html_entity_decode($title)."[/b]\n\n".$body; + + $body = str_ireplace("[quote", "\n\n[quote", $body); + $body = str_ireplace("[/quote]", "[/quote]\n\n", $body); + + // strip bookmark indicators + + $body = preg_replace('/\#\^\[([zu])rl/i', '[$1rl', $body); + $body = preg_replace('/\#\^http/i', 'http', $body); + + // protect tags and mentions from hijacking + + if(! intval(get_pconfig($owner['channel_id'],'system','allow_tag_hijacking'))) { + $new_tag = html_entity_decode('⋕',ENT_COMPAT,'UTF-8'); + $new_mention = html_entity_decode('@',ENT_COMPAT,'UTF-8'); + + // #-tags + $body = preg_replace('/\#\[url/i', $new_tag . '[url', $body); + $body = preg_replace('/\#\[zrl/i', $new_tag . '[zrl', $body); + // @-mentions + $body = preg_replace('/\@\[url/i', $new_mention . '[url', $body); + $body = preg_replace('/\@\[zrl/i', $new_mention . '[zrl', $body); + } + + // remove multiple newlines + do { + $oldbody = $body; + $body = str_replace("\n\n\n", "\n\n", $body); + } while ($oldbody != $body); + // convert to markdown $body = xmlify(html_entity_decode(bb2diaspora($body))); - //$body = bb2diaspora($body); // Adding the title if(strlen($title)) @@ -2262,7 +2288,6 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { } } - $public = (($item['item_private']) ? 'false' : 'true'); require_once('include/datetime.php'); @@ -2279,7 +2304,7 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { '$handle' => xmlify($myaddr), '$public' => $public, '$created' => $created, - '$provider' => $item['app'] + '$provider' => (($item['app']) ? $item['app'] : 'redmatrix') )); } else { $tpl = get_markup_template('diaspora_post.tpl'); @@ -2289,11 +2314,11 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) { '$handle' => xmlify($myaddr), '$public' => $public, '$created' => $created, - '$provider' => $item['app'] + '$provider' => (($item['app']) ? $item['app'] : 'redmatrix') )); } - logger('diaspora_send_status: '.$owner['channel_name'].' -> '.$contact['xchan_name'].' base message: '.$msg, LOGGER_DATA); + logger('diaspora_send_status: '.$owner['channel_name'].' -> '.$contact['xchan_name'].' base message: ' . $msg, LOGGER_DATA); $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['channel_prvkey'],$contact['xchan_pubkey'],$public_batch))); diff --git a/include/items.php b/include/items.php index f10a5c570..e9f11ee4a 100755 --- a/include/items.php +++ b/include/items.php @@ -95,6 +95,7 @@ function collect_recipients($item,&$private_envelope) { $recipients[] = $item['author_xchan']; if($item['owner_xchan'] != $item['author_xchan']) $recipients[] = $item['owner_xchan']; + return $recipients; } diff --git a/include/notifier.php b/include/notifier.php index 7c4f64ae0..7f4d7a9f8 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -493,7 +493,7 @@ function notifier_run($argv, $argc){ } - if($hub['network'] === 'diaspora' || $hub['network'] === 'friendica-over-diaspora') { + if($hub['hubloc_network'] === 'diaspora' || $hub['hubloc_network'] === 'friendica-over-diaspora') { if(! get_config('system','diaspora_enabled')) continue; diff --git a/view/tpl/diaspora_comment.tpl b/view/tpl/diaspora_comment.tpl new file mode 100644 index 000000000..8df3842d0 --- /dev/null +++ b/view/tpl/diaspora_comment.tpl @@ -0,0 +1,16 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <comment> + <guid>{{$guid}}</guid> + <parent_guid>{{$parent_guid}}</parent_guid> + <author_signature>{{$authorsig}}</author_signature> + <text>{{$body}}</text> + <diaspora_handle>{{$handle}}</diaspora_handle> + </comment> + </post> +</XML>
\ No newline at end of file diff --git a/view/tpl/diaspora_comment_relay.tpl b/view/tpl/diaspora_comment_relay.tpl new file mode 100644 index 000000000..c01441e3c --- /dev/null +++ b/view/tpl/diaspora_comment_relay.tpl @@ -0,0 +1,17 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <comment> + <guid>{{$guid}}</guid> + <parent_guid>{{$parent_guid}}</parent_guid> + <parent_author_signature>{{$parentsig}}</parent_author_signature> + <author_signature>{{$authorsig}}</author_signature> + <text>{{$body}}</text> + <diaspora_handle>{{$handle}}</diaspora_handle> + </comment> + </post> +</XML>
\ No newline at end of file diff --git a/view/tpl/diaspora_conversation.tpl b/view/tpl/diaspora_conversation.tpl new file mode 100644 index 000000000..fd11b826a --- /dev/null +++ b/view/tpl/diaspora_conversation.tpl @@ -0,0 +1,34 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <conversation> + <guid>{{$conv.guid}}</guid> + <subject>{{$conv.subject}}</subject> + <created_at>{{$conv.created_at}}</created_at> + + {{foreach $conv.messages as $msg}} + + <message> + <guid>{{$msg.guid}}</guid> + <parent_guid>{{$msg.parent_guid}}</parent_guid> + {{if $msg.parent_author_signature}} + <parent_author_signature>{{$msg.parent_author_signature}}</parent_author_signature> + {{/if}} + <author_signature>{{$msg.author_signature}}</author_signature> + <text>{{$msg.text}}</text> + <created_at>{{$msg.created_at}}</created_at> + <diaspora_handle>{{$msg.diaspora_handle}}</diaspora_handle> + <conversation_guid>{{$msg.conversation_guid}}</conversation_guid> + </message> + + {{/foreach}} + + <diaspora_handle>{{$conv.diaspora_handle}}</diaspora_handle> + <participant_handles>{{$conv.participant_handles}}</participant_handles> + </conversation> + </post> +</XML> diff --git a/view/tpl/diaspora_like.tpl b/view/tpl/diaspora_like.tpl new file mode 100644 index 000000000..b35ec46ad --- /dev/null +++ b/view/tpl/diaspora_like.tpl @@ -0,0 +1,17 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <like> + <positive>{{$positive}}</positive> + <guid>{{$guid}}</guid> + <target_type>{{$target_type}}</target_type> + <parent_guid>{{$parent_guid}}</parent_guid> + <author_signature>{{$authorsig}}</author_signature> + <diaspora_handle>{{$handle}}</diaspora_handle> + </like> + </post> +</XML> diff --git a/view/tpl/diaspora_like_relay.tpl b/view/tpl/diaspora_like_relay.tpl new file mode 100644 index 000000000..379bf0f45 --- /dev/null +++ b/view/tpl/diaspora_like_relay.tpl @@ -0,0 +1,18 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <like> + <positive>{{$positive}}</positive> + <guid>{{$guid}}</guid> + <target_type>{{$target_type}}</target_type> + <parent_guid>{{$parent_guid}}</parent_guid> + <parent_author_signature>{{$parentsig}}</parent_author_signature> + <author_signature>{{$authorsig}}</author_signature> + <diaspora_handle>{{$handle}}</diaspora_handle> + </like> + </post> +</XML> diff --git a/view/tpl/diaspora_message.tpl b/view/tpl/diaspora_message.tpl new file mode 100644 index 000000000..e1690734f --- /dev/null +++ b/view/tpl/diaspora_message.tpl @@ -0,0 +1,18 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <message> + <guid>{{$msg.guid}}</guid> + <parent_guid>{{$msg.parent_guid}}</parent_guid> + <author_signature>{{$msg.author_signature}}</author_signature> + <text>{{$msg.text}}</text> + <created_at>{{$msg.created_at}}</created_at> + <diaspora_handle>{{$msg.diaspora_handle}}</diaspora_handle> + <conversation_guid>{{$msg.conversation_guid}}</conversation_guid> + </message> + </post> +</XML> diff --git a/view/tpl/diaspora_photo.tpl b/view/tpl/diaspora_photo.tpl new file mode 100644 index 000000000..258a9c2f4 --- /dev/null +++ b/view/tpl/diaspora_photo.tpl @@ -0,0 +1,18 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <photo> + <guid>{{$guid}}</guid> + <diaspora_handle>{{$handle}}</diaspora_handle> + <public>{{$public}}</public> + <created_at>{{$created_at}}</created_at> + <remote_photo_path>{{$path}}</remote_photo_path> + <remote_photo_name>{{$filename}}</remote_photo_name> + <status_message_guid>{{$msg_guid}}</status_message_guid> + </photo> + </post> +</XML> diff --git a/view/tpl/diaspora_post.tpl b/view/tpl/diaspora_post.tpl new file mode 100644 index 000000000..2fe916e00 --- /dev/null +++ b/view/tpl/diaspora_post.tpl @@ -0,0 +1,12 @@ +<XML> + <post> + <status_message> + <raw_message>{{$body}}</raw_message> + <guid>{{$guid}}</guid> + <diaspora_handle>{{$handle}}</diaspora_handle> + <public>{{$public}}</public> + <created_at>{{$created}}</created_at> + <provider_display_name>{{$provider}}</provider_display_name> + </status_message> + </post> +</XML> diff --git a/view/tpl/diaspora_profile.tpl b/view/tpl/diaspora_profile.tpl new file mode 100644 index 000000000..e57b82820 --- /dev/null +++ b/view/tpl/diaspora_profile.tpl @@ -0,0 +1,21 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post><profile> + <diaspora_handle>{{$handle}}</diaspora_handle> + <first_name>{{$first}}</first_name> + <last_name>{{$last}}</last_name> + <image_url>{{$large}}</image_url> + <image_url_medium>{{$medium}}</image_url_medium> + <image_url_small>{{$small}}</image_url_small> + <birthday>{{$dob}}</birthday> + <gender>{{$gender}}</gender> + <bio>{{$about}}</bio> + <location>{{$location}}</location> + <searchable>{{$searchable}}</searchable> + <tag_string>{{$tags}}</tag_string> + </profile></post> +</XML> diff --git a/view/tpl/diaspora_relay_retraction.tpl b/view/tpl/diaspora_relay_retraction.tpl new file mode 100644 index 000000000..97a1344c9 --- /dev/null +++ b/view/tpl/diaspora_relay_retraction.tpl @@ -0,0 +1,15 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <relayable_retraction> + <target_type>{{$type}}</target_type> + <target_guid>{{$guid}}</target_guid> + <target_author_signature>{{$signature}}</target_author_signature> + <sender_handle>{{$handle}}</sender_handle> + </relayable_retraction> + </post> +</XML> diff --git a/view/tpl/diaspora_relayable_retraction.tpl b/view/tpl/diaspora_relayable_retraction.tpl new file mode 100644 index 000000000..c25e13db1 --- /dev/null +++ b/view/tpl/diaspora_relayable_retraction.tpl @@ -0,0 +1,16 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <relayable_retraction> + <parent_author_signature>{{$parentsig}}</parent_author_signature> + <target_guid>{{$guid}}</target_guid> + <target_type>{{$target_type}}</target_type> + <sender_handle>{{$handle}}</sender_handle> + <target_author_signature>{{$authorsig}}</target_author_signature> + </relayable_retraction> + </post> +</XML> diff --git a/view/tpl/diaspora_reshare.tpl b/view/tpl/diaspora_reshare.tpl new file mode 100644 index 000000000..c2b4bf774 --- /dev/null +++ b/view/tpl/diaspora_reshare.tpl @@ -0,0 +1,18 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <reshare> + <root_diaspora_id>{{$root_handle}}</root_diaspora_id> + <root_guid>{{$root_guid}}</root_guid> + <guid>{{$guid}}</guid> + <diaspora_handle>{{$handle}}</diaspora_handle> + <public>{{$public}}</public> + <created_at>{{$created}}</created_at> + <provider_display_name>{{$provider}}</provider_display_name> + </reshare> + </post> +</XML> diff --git a/view/tpl/diaspora_retract.tpl b/view/tpl/diaspora_retract.tpl new file mode 100644 index 000000000..345f4bcb6 --- /dev/null +++ b/view/tpl/diaspora_retract.tpl @@ -0,0 +1,14 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <retraction> + <post_guid>{{$guid}}</post_guid> + <diaspora_handle>{{$handle}}</diaspora_handle> + <type>{{$type}}</type> + </retraction> + </post> +</XML> diff --git a/view/tpl/diaspora_share.tpl b/view/tpl/diaspora_share.tpl new file mode 100644 index 000000000..5ff04440d --- /dev/null +++ b/view/tpl/diaspora_share.tpl @@ -0,0 +1,13 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <request> + <sender_handle>{{$sender}}</sender_handle> + <recipient_handle>{{$recipient}}</recipient_handle> + </request> + </post> +</XML>
\ No newline at end of file diff --git a/view/tpl/diaspora_signed_retract.tpl b/view/tpl/diaspora_signed_retract.tpl new file mode 100644 index 000000000..58c5cc237 --- /dev/null +++ b/view/tpl/diaspora_signed_retract.tpl @@ -0,0 +1,15 @@ +{{* + * AUTOMATICALLY GENERATED TEMPLATE + * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN + * + *}} +<XML> + <post> + <signed_retraction> + <target_guid>{{$guid}}</target_guid> + <target_type>{{$type}}</target_type> + <sender_handle>{{$handle}}</sender_handle> + <target_author_signature>{{$signature}}</target_author_signature> + </signed_retraction> + </post> +</XML> |