From 8fb1356623f9a2b6089e97103b593158e67c8676 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 26 Aug 2015 17:49:57 -0700 Subject: required for future work --- include/conversation.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 76a2f47d1..8bbb87e2c 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -404,7 +404,9 @@ function count_descendants($item) { * @brief Check if the activity of the item is visible. * * likes (etc.) can apply to other things besides posts. Check if they are post - * children, in which case we handle them specially. + * children, in which case we handle them specially. Activities which are unrecognised + * as having special meaning and hidden will be treated as posts or comments and visible + * in the stream. * * @param array $item * @return boolean @@ -412,12 +414,21 @@ function count_descendants($item) { function visible_activity($item) { $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE); + $post_types = array(ACTIVITY_OBJ_NOTE,ACTIVITY_OBJ_COMMENT,basename(ACTIVITY_OBJ_NOTE),basename(ACTIVITY_OBJ_COMMENT)); + foreach ($hidden_activities as $act) { if ((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) { return false; } } + // In order to share edits with networks which have no concept of editing, we'll create + // separate activities to indicate the edit. Our network will not require them, since our + // edits are automatically applied and the activity indicated. + + if(($item['verb'] === ACTIVITY_UPDATE) && (in_array($item['obj_type'],$post_types))) + return false; + return true; } -- cgit v1.2.3 From d1c23477dfb0ee48cf652d6e63969ed5a3809b18 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 26 Aug 2015 20:20:41 -0700 Subject: support likes on comments with diaspora owner by sending as activity --- include/diaspora.php | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index 74a56dd79..61556fd9d 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -2742,21 +2742,26 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { // versions of Diaspora (i.e. Diaspora-pistos) support // likes on comments + + // That version is now dead so detect a "sublike" and + // just send it as an activity. + + $sublike = false; + + if($item['verb'] === ACTIVITY_LIKE && $item['thr_parent']) { - $p = q("select * from item where mid = '%s' limit 1", - dbesc($item['thr_parent']) - ); - } - else { - // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always - // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent. - // The only item with `parent` and `id` as the parent id is the parent item. - $p = q("select * from item where parent = %d and id = %d limit 1", - intval($item['parent']), - intval($item['parent']) - ); + $sublike = true; } + + // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always + // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent. + // The only item with `parent` and `id` as the parent id is the parent item. + $p = q("select * from item where parent = %d and id = %d limit 1", + intval($item['parent']), + intval($item['parent']) + ); + if($p) $parent = $p[0]; else { @@ -2771,12 +2776,12 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { if( $item['item_restrict'] & ITEM_DELETED) { $relay_retract = true; - $target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment'); + $target_type = ( ($item['verb'] === ACTIVITY_LIKE && (! $sublike)) ? 'Like' : 'Comment'); $sql_sign_id = 'retract_iid'; $tpl = get_markup_template('diaspora_relayable_retraction.tpl'); } - elseif($item['verb'] === ACTIVITY_LIKE) { + elseif(($item['verb'] === ACTIVITY_LIKE) && (! $sublike)) { $like = true; $target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment'); -- cgit v1.2.3