From 7c5cfe66973a8e529c01c3a214e9f8b791c89c23 Mon Sep 17 00:00:00 2001 From: "M. Dent" Date: Mon, 23 Sep 2019 10:11:27 +0200 Subject: Notify on custom items - rework hooks --- Zotlabs/Lib/Activity.php | 56 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 11 deletions(-) (limited to 'Zotlabs/Lib/Activity.php') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 771c6875b..bcf017286 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -42,6 +42,8 @@ class Activity { if($x['type'] === ACTIVITY_OBJ_PHOTO) { return self::fetch_image($x); } + + call_hooks('encode_object',$x); } return $x; @@ -806,6 +808,7 @@ class Activity { 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept' ]; + call_hooks('activity_mapper',$acts); if(array_key_exists($verb,$acts) && $acts[$verb]) { return $acts[$verb]; @@ -851,6 +854,7 @@ class Activity { 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept' ]; + call_hooks('activity_decode_mapper',$acts); foreach($acts as $k => $v) { if($verb === $v) { @@ -884,6 +888,8 @@ class Activity { ]; + call_hooks('activity_obj_decode_mapper',$objs); + foreach($objs as $k => $v) { if($obj === $v) { return $k; @@ -921,6 +927,8 @@ class Activity { ]; + call_hooks('activity_obj_mapper',$objs); + if(array_key_exists($obj,$objs)) { return $objs[$obj]; } @@ -1941,6 +1949,15 @@ class Activity { set_iconfig($s,'activitypub','rawmsg',$act->raw,1); } + $hookinfo = [ + 'act' => $act, + 's' => $s + ]; + + call_hooks('decode_note',$hookinfo); + + $s = $hookinfo['s']; + return $s; } @@ -2130,16 +2147,25 @@ class Activity { break; } - if(! $item) { - break; - } - array_unshift($p,[ $a, $item, $replies]); + $hookinfo = [ + 'a' => $a, + 'item' => $item + ]; + + call_hooks('fetch_and_store',$hookinfo); - if($item['parent_mid'] === $item['mid'] || count($p) > 20) { - break; - } + $item = $hookinfo['item']; + if($item) { + + array_unshift($p,[ $a, $item, $replies]); + + if($item['parent_mid'] === $item['mid'] || count($p) > 20) { + break; + } + + } $current_act = $a; $current_item = $item; } @@ -2188,11 +2214,19 @@ class Activity { default: break; } - if(! $item) { - break; - } - array_unshift($p,[ $a, $item ]); + $hookinfo = [ + 'a' => $a, + 'item' => $item + ]; + + call_hooks('fetch_and_store',$hookinfo); + + $item = $hookinfo['item']; + + if($item) { + array_unshift($p,[ $a, $item ]); + } } -- cgit v1.2.3