Notify on custom items - rework hooks
This commit is contained in:
parent
d1fd69337f
commit
7c5cfe6697
@ -285,10 +285,23 @@ class Notifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(! in_array(intval($target_item['item_type']), [ ITEM_TYPE_POST ] )) {
|
if(! in_array(intval($target_item['item_type']), [ ITEM_TYPE_POST ] )) {
|
||||||
|
$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);
|
logger('notifier: target item not forwardable: type ' . $target_item['item_type'], LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$target_item = $hookinfo['targetitem'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Check for non published items, but allow an exclusion for transmitting hidden file activities
|
// Check for non published items, but allow an exclusion for transmitting hidden file activities
|
||||||
|
|
||||||
if(intval($target_item['item_unpublished']) || intval($target_item['item_delayed']) ||
|
if(intval($target_item['item_unpublished']) || intval($target_item['item_delayed']) ||
|
||||||
|
@ -42,6 +42,8 @@ class Activity {
|
|||||||
if($x['type'] === ACTIVITY_OBJ_PHOTO) {
|
if($x['type'] === ACTIVITY_OBJ_PHOTO) {
|
||||||
return self::fetch_image($x);
|
return self::fetch_image($x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
call_hooks('encode_object',$x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $x;
|
return $x;
|
||||||
@ -806,6 +808,7 @@ class Activity {
|
|||||||
'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept'
|
'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
call_hooks('activity_mapper',$acts);
|
||||||
|
|
||||||
if(array_key_exists($verb,$acts) && $acts[$verb]) {
|
if(array_key_exists($verb,$acts) && $acts[$verb]) {
|
||||||
return $acts[$verb];
|
return $acts[$verb];
|
||||||
@ -851,6 +854,7 @@ class Activity {
|
|||||||
'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept'
|
'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
call_hooks('activity_decode_mapper',$acts);
|
||||||
|
|
||||||
foreach($acts as $k => $v) {
|
foreach($acts as $k => $v) {
|
||||||
if($verb === $v) {
|
if($verb === $v) {
|
||||||
@ -884,6 +888,8 @@ class Activity {
|
|||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
call_hooks('activity_obj_decode_mapper',$objs);
|
||||||
|
|
||||||
foreach($objs as $k => $v) {
|
foreach($objs as $k => $v) {
|
||||||
if($obj === $v) {
|
if($obj === $v) {
|
||||||
return $k;
|
return $k;
|
||||||
@ -921,6 +927,8 @@ class Activity {
|
|||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
call_hooks('activity_obj_mapper',$objs);
|
||||||
|
|
||||||
if(array_key_exists($obj,$objs)) {
|
if(array_key_exists($obj,$objs)) {
|
||||||
return $objs[$obj];
|
return $objs[$obj];
|
||||||
}
|
}
|
||||||
@ -1941,6 +1949,15 @@ class Activity {
|
|||||||
set_iconfig($s,'activitypub','rawmsg',$act->raw,1);
|
set_iconfig($s,'activitypub','rawmsg',$act->raw,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hookinfo = [
|
||||||
|
'act' => $act,
|
||||||
|
's' => $s
|
||||||
|
];
|
||||||
|
|
||||||
|
call_hooks('decode_note',$hookinfo);
|
||||||
|
|
||||||
|
$s = $hookinfo['s'];
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2130,9 +2147,17 @@ class Activity {
|
|||||||
break;
|
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]);
|
array_unshift($p,[ $a, $item, $replies]);
|
||||||
|
|
||||||
@ -2140,6 +2165,7 @@ class Activity {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
$current_act = $a;
|
$current_act = $a;
|
||||||
$current_item = $item;
|
$current_item = $item;
|
||||||
}
|
}
|
||||||
@ -2188,11 +2214,19 @@ class Activity {
|
|||||||
default:
|
default:
|
||||||
break;
|
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 ]);
|
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]
|
[zrl=[baseurl]/help/hook/activity_filter]activity_filter[/zrl]
|
||||||
Called when generating the list of filters for the network page
|
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]
|
[zrl=[baseurl]/help/hook/activity_order]activity_order[/zrl]
|
||||||
Called when generating the list of order options for the network page
|
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]
|
[zrl=[baseurl]/help/hook/drop_item]drop_item[/zrl]
|
||||||
called when an 'item' is removed
|
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]
|
[zrl=[baseurl]/help/hook/enotify]enotify[/zrl]
|
||||||
called before any notification
|
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]
|
[zrl=[baseurl]/help/hook/feature_settings_post]feature_settings_post[/zrl]
|
||||||
called from settings page when posting from 'addon/feature settings'
|
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]
|
[zrl=[baseurl]/help/hook/file_thumbnail]file_thumbnail[/zrl]
|
||||||
called when generating thumbnail images for cloud page in 'view tiles' mode
|
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
|
'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
|
* @hooks item_store
|
||||||
* Called when item_store() stores a record of type item.
|
* Called when item_store() stores a record of type item.
|
||||||
* * \e array \b item
|
* * \e array \b item
|
||||||
* * \e boolean \b allow_exec
|
* * \e boolean \b allow_exec
|
||||||
*/
|
*/
|
||||||
call_hooks('item_store', $d);
|
call_hooks('item_store_before', $d);
|
||||||
|
|
||||||
$arr = $d['item'];
|
$arr = $d['item'];
|
||||||
$allow_exec = $d['allow_exec'];
|
$allow_exec = $d['allow_exec'];
|
||||||
|
|
||||||
@ -1961,6 +1955,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
|
|||||||
*/
|
*/
|
||||||
call_hooks('item_store', $arr);
|
call_hooks('item_store', $arr);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hooks post_remote
|
* @hooks post_remote
|
||||||
* Called when an activity arrives from another site.
|
* 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
|
'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
|
* @hooks item_store_update
|
||||||
* Called when item_store_update() is called to update a stored item. It
|
* 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 array \b item
|
||||||
* * \e boolean \b allow_exec
|
* * \e boolean \b allow_exec
|
||||||
*/
|
*/
|
||||||
call_hooks('item_store_update', $d);
|
call_hooks('item_store_update_before', $d);
|
||||||
$arr = $d['item'];
|
$arr = $d['item'];
|
||||||
$allow_exec = $d['allow_exec'];
|
$allow_exec = $d['allow_exec'];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user