From 8227be0ab0018866cb3a1a5d597b8712ba547d7f Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 19 Oct 2014 19:20:25 -0700 Subject: show true author of wall-to-wall comments to Diaspora viewers just like we did for wall-to-wall posts. --- include/bb2diaspora.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 76708143b..9a87de5b2 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -286,6 +286,19 @@ function bb2diaspora_itemwallwall(&$item) { . '[url=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/url]' . "\n\n" . $item['body']; } + + // We have to do something similar for wall-to-wall comments. ITEM_WALL|ITEM_ORIGIN indicates that it was posted on this site. + // Regular matrix comments may have one of these bits set, but not both. + + if(($item['mid'] != $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && ($item['item_flags'] & (ITEM_WALL|ITEM_ORIGIN)) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) { + logger('bb2diaspora_itemwallwall: wall to wall comment',LOGGER_DEBUG); + // post will come across with the owner's identity. Throw a preamble onto the post to indicate the true author. + $item['body'] = "\n\n" + . '[img]' . $item['author']['xchan_photo_m'] . '[/img]' + . '[url=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/url]' . "\n\n" + . $item['body']; + } + // $item['author'] might cause a surprise further down the line if it wasn't expected to be here. if(! $author_exists) -- cgit v1.2.3 From 577d84b883b52dde84c18c659a8c4674abe4e94e Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 20 Oct 2014 19:06:02 -0700 Subject: bb2diaspora wallwall comment - match both bits (ITEM_WALL|ITEM_ORIGIN) --- include/bb2diaspora.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 9a87de5b2..665fd4622 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -290,7 +290,7 @@ function bb2diaspora_itemwallwall(&$item) { // We have to do something similar for wall-to-wall comments. ITEM_WALL|ITEM_ORIGIN indicates that it was posted on this site. // Regular matrix comments may have one of these bits set, but not both. - if(($item['mid'] != $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && ($item['item_flags'] & (ITEM_WALL|ITEM_ORIGIN)) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) { + if(($item['mid'] != $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && (($item['item_flags'] & (ITEM_WALL|ITEM_ORIGIN)) == (ITEM_WALL|ITEM_ORIGIN)) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) { logger('bb2diaspora_itemwallwall: wall to wall comment',LOGGER_DEBUG); // post will come across with the owner's identity. Throw a preamble onto the post to indicate the true author. $item['body'] = "\n\n" -- cgit v1.2.3 From e8a7fb3d015b36af31312daf50739cf73f0f4368 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 20 Oct 2014 21:15:29 -0700 Subject: strip out the Diaspora quoted reshare markers --- include/bb2diaspora.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 665fd4622..5663ce9ef 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -116,6 +116,8 @@ function diaspora_mention_callback($matches) { function diaspora2bb($s,$use_zrl = false) { + $s = str_replace(" \n>","",$s); + $s = html_entity_decode($s,ENT_COMPAT,'UTF-8'); // Too many new lines. So deactivated the following line -- cgit v1.2.3 From 902b5c52e5ca9359522f33bbecaf7f2f3c1ba90d Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 22 Oct 2014 18:14:21 -0700 Subject: backtrack on attribution for wall-to-wall comments - triggered too often and unnecessarily. --- include/bb2diaspora.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 5663ce9ef..4f37e5aa8 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -292,14 +292,18 @@ function bb2diaspora_itemwallwall(&$item) { // We have to do something similar for wall-to-wall comments. ITEM_WALL|ITEM_ORIGIN indicates that it was posted on this site. // Regular matrix comments may have one of these bits set, but not both. - if(($item['mid'] != $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && (($item['item_flags'] & (ITEM_WALL|ITEM_ORIGIN)) == (ITEM_WALL|ITEM_ORIGIN)) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) { - logger('bb2diaspora_itemwallwall: wall to wall comment',LOGGER_DEBUG); + // Update: this is getting triggered way too often and unnecessarily. Commenting out until we find a better solution. + // It's not an easy problem. For now we'll live with the mis-attributions, as wall to wall comments are much less frequent + // than wall-to-wall posts. + +// if(($item['mid'] != $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && (($item['item_flags'] & (ITEM_WALL|ITEM_ORIGIN)) == (ITEM_WALL|ITEM_ORIGIN)) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) { +// logger('bb2diaspora_itemwallwall: wall to wall comment',LOGGER_DEBUG); // post will come across with the owner's identity. Throw a preamble onto the post to indicate the true author. - $item['body'] = "\n\n" - . '[img]' . $item['author']['xchan_photo_m'] . '[/img]' - . '[url=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/url]' . "\n\n" - . $item['body']; - } +// $item['body'] = "\n\n" +// . '[img]' . $item['author']['xchan_photo_m'] . '[/img]' +// . '[url=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/url]' . "\n\n" +// . $item['body']; +// } // $item['author'] might cause a surprise further down the line if it wasn't expected to be here. -- cgit v1.2.3 From 1845ddc4c3d3f729dde3905f0f87741ac3d3bf66 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 24 Oct 2014 04:17:48 -0700 Subject: don't decrypt the message body more than once. --- include/bb2diaspora.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 4f37e5aa8..d094e33c2 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -340,8 +340,13 @@ function bb2diaspora_itembody($item,$force_update = false) { if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) { $key = get_config('system','prvkey'); - $newitem['title'] = (($item['title']) ? crypto_unencapsulate(json_decode($item['title'],true),$key) : ''); - $newitem['body'] = (($item['body']) ? crypto_unencapsulate(json_decode($item['body'],true),$key) : ''); + $b = json_decode($item['title'],true); + // if called from diaspora_process_outbound, this decoding has already been done. + // Everything else that calls us will not yet be decoded. + if($b && is_array($b) && array_key_exists('iv',$b)) { + $newitem['title'] = (($item['title']) ? crypto_unencapsulate(json_decode($item['title'],true),$key) : ''); + $newitem['body'] = (($item['body']) ? crypto_unencapsulate(json_decode($item['body'],true),$key) : ''); + } } bb2diaspora_itemwallwall($newitem); -- cgit v1.2.3 From cf05266b15e49020c217107fd81896171d5ef26b Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 24 Oct 2014 14:04:32 -0700 Subject: should probably check the body since the title is only going to be rarely set. --- include/bb2diaspora.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/bb2diaspora.php') diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index d094e33c2..8a178d1ac 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -340,7 +340,7 @@ function bb2diaspora_itembody($item,$force_update = false) { if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) { $key = get_config('system','prvkey'); - $b = json_decode($item['title'],true); + $b = json_decode($item['body'],true); // if called from diaspora_process_outbound, this decoding has already been done. // Everything else that calls us will not yet be decoded. if($b && is_array($b) && array_key_exists('iv',$b)) { -- cgit v1.2.3