From 9a1f051068b5d301bbe1f08b6b160447fa94a34a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 2 Apr 2018 13:32:10 -0700 Subject: missing year on profile birthday input, some optimisations to stats --- include/items.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index d1625e944..e232a0200 100755 --- a/include/items.php +++ b/include/items.php @@ -2551,9 +2551,7 @@ function tag_deliver($uid, $item_id) { $j_obj = json_decode($item['obj'],true); logger('tag_deliver: tag object: ' . print_r($j_obj,true), LOGGER_DATA); if($j_obj && $j_obj['id'] && $j_obj['title']) { - if(is_array($j_obj['link'])) - $taglink = get_rel_link($j_obj['link'],'alternate'); - + //COMMUNITYTAG store_item_tag($u[0]['channel_id'],$p[0]['id'],TERM_OBJ_POST,TERM_COMMUNITYTAG,$j_obj['title'],$j_obj['id']); $x = q("update item set edited = '%s', received = '%s', changed = '%s' where mid = '%s' and uid = %d", dbesc(datetime_convert()), -- cgit v1.2.3 From 753e1e4616acc19ff54024443e9ed3d60b0296fc Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 2 Apr 2018 19:32:22 -0700 Subject: commtag refactor --- include/items.php | 93 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 35 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index e232a0200..5e84c62c7 100755 --- a/include/items.php +++ b/include/items.php @@ -2532,41 +2532,7 @@ function tag_deliver($uid, $item_id) { */ if($item['obj_type'] === ACTIVITY_OBJ_TAGTERM) { - - // We received a community tag activity for a post. - // See if we are the owner of the parent item and have given permission to tag our posts. - // If so tag the parent post. - - logger('tag_deliver: community tag activity received'); - - if(($item['owner_xchan'] === $u[0]['channel_hash']) && (! get_pconfig($u[0]['channel_id'],'system','blocktags'))) { - logger('tag_deliver: community tag recipient: ' . $u[0]['channel_name']); - $j_tgt = json_decode($item['target'],true); - if($j_tgt && $j_tgt['id']) { - $p = q("select * from item where mid = '%s' and uid = %d limit 1", - dbesc($j_tgt['id']), - intval($u[0]['channel_id']) - ); - if($p) { - $j_obj = json_decode($item['obj'],true); - logger('tag_deliver: tag object: ' . print_r($j_obj,true), LOGGER_DATA); - if($j_obj && $j_obj['id'] && $j_obj['title']) { - //COMMUNITYTAG - store_item_tag($u[0]['channel_id'],$p[0]['id'],TERM_OBJ_POST,TERM_COMMUNITYTAG,$j_obj['title'],$j_obj['id']); - $x = q("update item set edited = '%s', received = '%s', changed = '%s' where mid = '%s' and uid = %d", - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc($j_tgt['id']), - intval($u[0]['channel_id']) - ); - Zotlabs\Daemon\Master::Summon(array('Notifier','edit_post',$p[0]['id'])); - } - } - } - } - else - logger('Tag permission denied for ' . $u[0]['channel_address']); + item_community_tag($u[0],$item); } /* @@ -2761,6 +2727,63 @@ function tag_deliver($uid, $item_id) { } + +function item_community_tag($channel,$item) { + + + // We received a community tag activity for a post. + // See if we are the owner of the parent item and have given permission to tag our posts. + // If so tag the parent post. + + logger('tag_deliver: community tag activity received'); + + // refactor of this code block is in progress and is not yet completed + + $tag_the_post = false; + $p = null; + + $j_tgt = json_decode($item['target'],true); + if($j_tgt && $j_tgt['id']) { + $p = q("select * from item where mid = '%s' and uid = %d limit 1", + dbesc($j_tgt['id']), + intval($channel['channel_id']) + ); + } + if($p) { + xchan_query($p); + $items = fetch_post_tags($p,true); + $pitem = $items[0]; + $auth = get_iconfig($pitem,'system','communitytagauth'); + if($auth) { + if(rsa_verify('tagauth.' . $item['mid'],$auth,$pitem['owner']['xchan_pubkey'])) { + logger('tag_deliver: tagging the post: ' . $channel['channel_name']); + $tag_the_post = true; + } + } + else { + if(($pitem['owner_xchan'] === $channel['channel_hash']) && (! intval(get_pconfig($channel['channel_id'],'system','blocktags')))) { + logger('tag_deliver: community tag recipient: ' . $channel['channel_name']); + $tag_the_post = true; + $sig = rsa_sign('tagauth.' . $item['mid'],$channel['channel_prvkey']); + set_iconfig($item['id'],'system','communitytagauth',$sig,1); + } + } + + if($tag_the_post) { + store_item_tag($channel['channel_id'],$pitem['id'],TERM_OBJ_POST,TERM_COMMUNITYTAG,$j_obj['title'],$j_obj['id']); + } + + } + + if(! $tag_the_post) { + logger('Tag permission denied for ' . $channel['channel_address']); + } + +} + + + + /** * @brief This function is called pre-deliver to see if a post matches the criteria to be tag delivered. * -- cgit v1.2.3 From 4e21c14ff6b8c8dddf10acaf5cac9fe0764e4899 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 2 Apr 2018 20:39:28 -0700 Subject: community tagging refactor - we no longer send an edited post/comment to everybody. The post owner approves the tag and this is transmitted along with the tag activity. Recipients check the signature of the approval and add the tag to their local copy of the post. --- include/items.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 5e84c62c7..62f1c6195 100755 --- a/include/items.php +++ b/include/items.php @@ -2735,13 +2735,12 @@ function item_community_tag($channel,$item) { // See if we are the owner of the parent item and have given permission to tag our posts. // If so tag the parent post. - logger('tag_deliver: community tag activity received'); - - // refactor of this code block is in progress and is not yet completed + logger('tag_deliver: community tag activity received: channel: ' . $channel['channel_name']); $tag_the_post = false; $p = null; + $j_obj = json_decode($item['obj'],true); $j_tgt = json_decode($item['target'],true); if($j_tgt && $j_tgt['id']) { $p = q("select * from item where mid = '%s' and uid = %d limit 1", @@ -2753,9 +2752,9 @@ function item_community_tag($channel,$item) { xchan_query($p); $items = fetch_post_tags($p,true); $pitem = $items[0]; - $auth = get_iconfig($pitem,'system','communitytagauth'); + $auth = get_iconfig($item,'system','communitytagauth'); if($auth) { - if(rsa_verify('tagauth.' . $item['mid'],$auth,$pitem['owner']['xchan_pubkey'])) { + if(rsa_verify('tagauth.' . $item['mid'],base64url_decode($auth),$pitem['owner']['xchan_pubkey'])) { logger('tag_deliver: tagging the post: ' . $channel['channel_name']); $tag_the_post = true; } @@ -2765,18 +2764,17 @@ function item_community_tag($channel,$item) { logger('tag_deliver: community tag recipient: ' . $channel['channel_name']); $tag_the_post = true; $sig = rsa_sign('tagauth.' . $item['mid'],$channel['channel_prvkey']); - set_iconfig($item['id'],'system','communitytagauth',$sig,1); + logger('tag_deliver: setting iconfig for ' . $item['id']); + set_iconfig($item['id'],'system','communitytagauth',base64url_encode($sig),1); } } if($tag_the_post) { store_item_tag($channel['channel_id'],$pitem['id'],TERM_OBJ_POST,TERM_COMMUNITYTAG,$j_obj['title'],$j_obj['id']); } - - } - - if(! $tag_the_post) { - logger('Tag permission denied for ' . $channel['channel_address']); + else { + logger('Tag permission denied for ' . $channel['channel_address']); + } } } -- cgit v1.2.3 From 5ac0f371c748367b16fedde27edc9771b08bf4c6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 3 Apr 2018 17:52:54 -0700 Subject: community tags: allow signature of either author or owner so that it stands a chance of working across multiple delivery chains --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 62f1c6195..6ddab9bf8 100755 --- a/include/items.php +++ b/include/items.php @@ -2754,7 +2754,7 @@ function item_community_tag($channel,$item) { $pitem = $items[0]; $auth = get_iconfig($item,'system','communitytagauth'); if($auth) { - if(rsa_verify('tagauth.' . $item['mid'],base64url_decode($auth),$pitem['owner']['xchan_pubkey'])) { + if(rsa_verify('tagauth.' . $item['mid'],base64url_decode($auth),$pitem['owner']['xchan_pubkey']) || rsa_verify('tagauth.' . $item['mid'],base64url_decode($auth),$pitem['author']['xchan_pubkey'])) { logger('tag_deliver: tagging the post: ' . $channel['channel_name']); $tag_the_post = true; } -- cgit v1.2.3