Notify on custom items - rework hooks

This commit is contained in:
M. Dent
2019-09-23 10:11:27 +02:00
committed by Mario
parent d1fd69337f
commit 7c5cfe6697
10 changed files with 90 additions and 32 deletions

View File

@@ -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 ]);
}
}