From 4ff71fc0c7d28b8a843cc67eac1d9463afe575ee Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 22 Jan 2015 02:34:38 +0100 Subject: change mod/sharedwithme backend to use activity object - this is not backwards compatible --- mod/sharedwithme.php | 72 +++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) (limited to 'mod/sharedwithme.php') diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php index d4aa129ac..53884788d 100644 --- a/mod/sharedwithme.php +++ b/mod/sharedwithme.php @@ -1,5 +1,4 @@ 1) && (argv(1) === 'dropall')) { - q("DELETE FROM item WHERE verb LIKE '%s' AND uid = %d", - dbesc($postverb . '%'), + q("DELETE FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d", + dbesc(ACTIVITY_POST), + dbesc(ACTIVITY_OBJ_FILE), intval(local_user()) ); @@ -77,11 +83,13 @@ function sharedwithme_content(&$a) { } //list files - $r = q("SELECT * FROM item WHERE verb LIKE '%s' AND uid = %d", - dbesc($postverb . '%'), - intval(local_user()) + $r = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d AND owner_xchan != '%s'", + dbesc(ACTIVITY_POST), + dbesc(ACTIVITY_OBJ_FILE), + intval(local_user()), + dbesc($channel['channel_hash']) ); - + $o = profile_tabs($a, $is_owner, $channel['channel_address']); $o .= '
'; @@ -96,19 +104,15 @@ function sharedwithme_content(&$a) { if($r) { foreach($r as $rr) { - //don't display the files we shared with others - if($rr['owner_xchan'] != $channel['channel_hash']) { - unobscure($rr); - $url = rawurldecode($rr['body']); - $o .= '' . $url . ' 

'; - } + $object = json_decode($rr['object'],true); + $url = rawurldecode($object['link']['href']); + $o .= '' . $url . ' 

'; } } $o .= '
'; return $o; - } -- cgit v1.2.3 From 3731ff97ffa9d6c98c7287458edd783823f68305 Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 22 Jan 2015 04:57:59 +0100 Subject: make $links an array of links --- mod/sharedwithme.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mod/sharedwithme.php') diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php index 53884788d..ff93051da 100644 --- a/mod/sharedwithme.php +++ b/mod/sharedwithme.php @@ -1,5 +1,6 @@ ' . $url . ' 

'; } } -- cgit v1.2.3 From 87dcc4c145cae992d7aa009c36fa45cf543cad55 Mon Sep 17 00:00:00 2001 From: marijus Date: Thu, 22 Jan 2015 22:50:38 +0100 Subject: possible performance improvement for sharedwithme update query --- mod/sharedwithme.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'mod/sharedwithme.php') diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php index ff93051da..baaf41f61 100644 --- a/mod/sharedwithme.php +++ b/mod/sharedwithme.php @@ -12,7 +12,7 @@ function sharedwithme_content(&$a) { $is_owner = (local_user() && (local_user() == $channel['channel_id'])); - //maintenance - see if a file got dropped and remove it systemwide + //maintenance - see if a file got dropped and remove it systemwide - this should possibly go to include/poller $x = q("SELECT * FROM item WHERE verb = '%s' AND obj_type = '%s' AND uid = %d", dbesc(ACTIVITY_UPDATE), dbesc(ACTIVITY_OBJ_FILE), @@ -26,18 +26,21 @@ function sharedwithme_content(&$a) { $object = json_decode($xx['object'],true); $hash = $object['hash']; - //If object has a mid it's an update - the inlcuded mid is the latest and should not be removed + //If object has a mid it's an update activity - the inlcuded mid is the latest and should not be removed $update = (($object['mid']) ? true : false); if($update) { $mid = $object['mid']; - $y = q("DELETE FROM item WHERE (mid != '%s' AND obj_type = '%s' AND object LIKE '%s') AND (verb = '%s' OR verb = '%s')", + unset($object['mid']); //remove mid from object to match the post activity object + + $y = q("DELETE FROM item WHERE (mid != '%s' AND obj_type = '%s') AND (object = '%s' AND verb = '%s') OR (object = '%s' AND verb = '%s')", dbesc($mid), dbesc(ACTIVITY_OBJ_FILE), - dbesc('%"hash":"' . $hash . '"%'), + dbesc(json_encode($object)), dbesc(ACTIVITY_POST), + dbesc($xx['object']), dbesc(ACTIVITY_UPDATE) ); -- cgit v1.2.3 From 8789c96e78734cbc5420404eff149e514fe17ee7 Mon Sep 17 00:00:00 2001 From: marijus Date: Fri, 23 Jan 2015 14:50:39 +0100 Subject: some code restructure --- mod/sharedwithme.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod/sharedwithme.php') diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php index baaf41f61..bbb9c2aef 100644 --- a/mod/sharedwithme.php +++ b/mod/sharedwithme.php @@ -48,9 +48,9 @@ function sharedwithme_content(&$a) { else { - $z = q("DELETE FROM item WHERE (obj_type = '%s' AND object LIKE '%s') AND (verb = '%s' OR verb = '%s')", + $z = q("DELETE FROM item WHERE (obj_type = '%s' AND object = '%s') AND (verb = '%s' OR verb = '%s')", dbesc(ACTIVITY_OBJ_FILE), - dbesc('%"hash":"' . $hash . '"%'), + dbesc($xx['object']), dbesc(ACTIVITY_POST), dbesc(ACTIVITY_UPDATE) ); -- cgit v1.2.3 From 0cbe64c3606312302ad5d3ef56df5d152983ee4e Mon Sep 17 00:00:00 2001 From: marijus Date: Sat, 24 Jan 2015 01:13:02 +0100 Subject: some more kiss --- mod/sharedwithme.php | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) (limited to 'mod/sharedwithme.php') diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php index bbb9c2aef..8b7d2661c 100644 --- a/mod/sharedwithme.php +++ b/mod/sharedwithme.php @@ -24,38 +24,17 @@ function sharedwithme_content(&$a) { foreach($x as $xx) { $object = json_decode($xx['object'],true); - $hash = $object['hash']; - //If object has a mid it's an update activity - the inlcuded mid is the latest and should not be removed - $update = (($object['mid']) ? true : false); + $d_mid = $object['d_mid']; + $u_mid = $xx['mid']; - if($update) { - - $mid = $object['mid']; - - unset($object['mid']); //remove mid from object to match the post activity object - - $y = q("DELETE FROM item WHERE (mid != '%s' AND obj_type = '%s') AND (object = '%s' AND verb = '%s') OR (object = '%s' AND verb = '%s')", - dbesc($mid), - dbesc(ACTIVITY_OBJ_FILE), - dbesc(json_encode($object)), - dbesc(ACTIVITY_POST), - dbesc($xx['object']), - dbesc(ACTIVITY_UPDATE) - ); - - } - - else { - - $z = q("DELETE FROM item WHERE (obj_type = '%s' AND object = '%s') AND (verb = '%s' OR verb = '%s')", - dbesc(ACTIVITY_OBJ_FILE), - dbesc($xx['object']), - dbesc(ACTIVITY_POST), - dbesc(ACTIVITY_UPDATE) - ); - - } + $y = q("DELETE FROM item WHERE obj_type = '%s' AND (verb = '%s' AND mid = '%s') OR (verb = '%s' AND mid = '%s')", + dbesc(ACTIVITY_OBJ_FILE), + dbesc(ACTIVITY_POST), + dbesc($d_mid), + dbesc(ACTIVITY_UPDATE), + dbesc($u_mid) + ); } -- cgit v1.2.3