Notify on custom items - rework hooks
This commit is contained in:
parent
d1fd69337f
commit
7c5cfe6697
@ -285,8 +285,21 @@ class Notifier {
|
||||
}
|
||||
|
||||
if(! in_array(intval($target_item['item_type']), [ ITEM_TYPE_POST ] )) {
|
||||
logger('notifier: target item not forwardable: type ' . $target_item['item_type'], LOGGER_DEBUG);
|
||||
return;
|
||||
$hookinfo=[
|
||||
'targetitem'=>$target_item,
|
||||
'deliver'=>false
|
||||
];
|
||||
if (intval($target_item['item_type'] == ITEM_TYPE_CUSTOM)) {
|
||||
call_hooks('customitem_deliver',$hookinfo);
|
||||
}
|
||||
|
||||
if (!$hookinfo['deliver']) {
|
||||
logger('notifier: target item not forwardable: type ' . $target_item['item_type'], LOGGER_DEBUG);
|
||||
return;
|
||||
}
|
||||
|
||||
$target_item = $hookinfo['targetitem'];
|
||||
|
||||
}
|
||||
|
||||
// Check for non published items, but allow an exclusion for transmitting hidden file activities
|
||||
|
@ -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;
|
||||
|
||||
$hookinfo = [
|
||||
'a' => $a,
|
||||
'item' => $item
|
||||
];
|
||||
|
||||
call_hooks('fetch_and_store',$hookinfo);
|
||||
|
||||
$item = $hookinfo['item'];
|
||||
|
||||
if($item) {
|
||||
|
||||
array_unshift($p,[ $a, $item, $replies]);
|
||||
|
||||
if($item['parent_mid'] === $item['mid'] || count($p) > 20) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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 ]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
1
doc/hook/activity_decode_mapper.bb
Normal file
1
doc/hook/activity_decode_mapper.bb
Normal file
@ -0,0 +1 @@
|
||||
[h2]activity_decode_mapper[/h2]
|
1
doc/hook/activity_mapper.bb
Normal file
1
doc/hook/activity_mapper.bb
Normal file
@ -0,0 +1 @@
|
||||
[h2]activity_mapper[/h2]
|
1
doc/hook/activity_obj_decode_mapper.bb
Normal file
1
doc/hook/activity_obj_decode_mapper.bb
Normal file
@ -0,0 +1 @@
|
||||
[h2]activity_obj_decode_mapper[/h2]
|
1
doc/hook/activity_obj_mapper.bb
Normal file
1
doc/hook/activity_obj_mapper.bb
Normal file
@ -0,0 +1 @@
|
||||
[h2]activity_obj_mapper[/h2]
|
1
doc/hook/encode_object.bb
Normal file
1
doc/hook/encode_object.bb
Normal file
@ -0,0 +1 @@
|
||||
[h2]encode_object[/h2]
|
1
doc/hook/fetch_and_store.bb
Normal file
1
doc/hook/fetch_and_store.bb
Normal file
@ -0,0 +1 @@
|
||||
[h2]fetch_and_store[/h2]
|
@ -34,6 +34,18 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
|
||||
[zrl=[baseurl]/help/hook/activity_filter]activity_filter[/zrl]
|
||||
Called when generating the list of filters for the network page
|
||||
|
||||
[zrl=[baseurl]/help/hook/activity_filter]activity_mapper[/zrl]
|
||||
Called when determining the activity type for transmission.
|
||||
|
||||
[zrl=[baseurl]/help/hook/activity_filter]activity_decode_mapper[/zrl]
|
||||
Called when determining the activity type for transmission.
|
||||
|
||||
[zrl=[baseurl]/help/hook/activity_filter]activity_obj_mapper[/zrl]
|
||||
Called when determining the object type for transmission.
|
||||
|
||||
[zrl=[baseurl]/help/hook/activity_filter]activity_obj_decode_mapper[/zrl]
|
||||
Called when determining the object type for transmission.
|
||||
|
||||
[zrl=[baseurl]/help/hook/activity_order]activity_order[/zrl]
|
||||
Called when generating the list of order options for the network page
|
||||
|
||||
@ -232,6 +244,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
|
||||
[zrl=[baseurl]/help/hook/drop_item]drop_item[/zrl]
|
||||
called when an 'item' is removed
|
||||
|
||||
[zrl=[baseurl]/help/hook/encode_object]encode_object[/zrl]
|
||||
called when encoding an object for transmission.
|
||||
|
||||
[zrl=[baseurl]/help/hook/enotify]enotify[/zrl]
|
||||
called before any notification
|
||||
|
||||
@ -262,6 +277,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
|
||||
[zrl=[baseurl]/help/hook/feature_settings_post]feature_settings_post[/zrl]
|
||||
called from settings page when posting from 'addon/feature settings'
|
||||
|
||||
[zrl=[baseurl]/help/hook/fetch_and_store]fetch_and_store[/zrl]
|
||||
called to allow filtering of 'decoded' items before storage.
|
||||
|
||||
[zrl=[baseurl]/help/hook/file_thumbnail]file_thumbnail[/zrl]
|
||||
called when generating thumbnail images for cloud page in 'view tiles' mode
|
||||
|
||||
|
@ -1640,20 +1640,14 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
|
||||
'allow_exec' => $allow_exec
|
||||
];
|
||||
|
||||
if ($arr['item_type']==ITEM_TYPE_CUSTOM) {
|
||||
/* Custom items are not stored by default
|
||||
because they require an addon to process. */
|
||||
$d['item']['cancel']=true;
|
||||
|
||||
call_hooks('item_custom',$d);
|
||||
}
|
||||
/**
|
||||
* @hooks item_store
|
||||
* Called when item_store() stores a record of type item.
|
||||
* * \e array \b item
|
||||
* * \e boolean \b allow_exec
|
||||
*/
|
||||
call_hooks('item_store', $d);
|
||||
call_hooks('item_store_before', $d);
|
||||
|
||||
$arr = $d['item'];
|
||||
$allow_exec = $d['allow_exec'];
|
||||
|
||||
@ -1961,6 +1955,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
|
||||
*/
|
||||
call_hooks('item_store', $arr);
|
||||
|
||||
|
||||
/**
|
||||
* @hooks post_remote
|
||||
* Called when an activity arrives from another site.
|
||||
@ -2129,14 +2124,6 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) {
|
||||
'allow_exec' => $allow_exec
|
||||
];
|
||||
|
||||
if ($arr['item_type']==ITEM_TYPE_CUSTOM) {
|
||||
/* Custom items are not stored by default
|
||||
because they require an addon to process. */
|
||||
$d['item']['cancel']=true;
|
||||
|
||||
call_hooks('item_custom_update',$d);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hooks item_store_update
|
||||
* Called when item_store_update() is called to update a stored item. It
|
||||
@ -2144,7 +2131,7 @@ function item_store_update($arr, $allow_exec = false, $deliver = true) {
|
||||
* * \e array \b item
|
||||
* * \e boolean \b allow_exec
|
||||
*/
|
||||
call_hooks('item_store_update', $d);
|
||||
call_hooks('item_store_update_before', $d);
|
||||
$arr = $d['item'];
|
||||
$allow_exec = $d['allow_exec'];
|
||||
|
||||
|
Reference in New Issue
Block a user