convert AS "instrument" objects to the more appropriate "generator" - this probably should happen in pubcrawl addon also

This commit is contained in:
zotlabs 2019-05-28 20:23:03 -07:00
parent 1bf046c142
commit 0fa4c89a1b

View File

@ -299,7 +299,7 @@ class Activity {
} }
if($i['app']) { if($i['app']) {
$ret['instrument'] = [ 'type' => 'Service', 'name' => $i['app'] ]; $ret['generator'] = [ 'type' => 'Application', 'name' => $i['app'] ];
} }
if($i['location'] || $i['coord']) { if($i['location'] || $i['coord']) {
$ret['location'] = [ 'type' => 'Place' ]; $ret['location'] = [ 'type' => 'Place' ];
@ -506,7 +506,7 @@ class Activity {
if($i['created'] !== $i['edited']) if($i['created'] !== $i['edited'])
$ret['updated'] = datetime_convert('UTC','UTC',$i['edited'],ATOM_TIME); $ret['updated'] = datetime_convert('UTC','UTC',$i['edited'],ATOM_TIME);
if($i['app']) { if($i['app']) {
$ret['instrument'] = [ 'type' => 'Service', 'name' => $i['app'] ]; $ret['generator'] = [ 'type' => 'Application', 'name' => $i['app'] ];
} }
if($i['location'] || $i['coord']) { if($i['location'] || $i['coord']) {
$ret['location'] = [ 'type' => 'Place' ]; $ret['location'] = [ 'type' => 'Place' ];
@ -1337,13 +1337,13 @@ class Activity {
$s['verb'] = ACTIVITY_POST; $s['verb'] = ACTIVITY_POST;
$s['obj_type'] = ACTIVITY_OBJ_NOTE; $s['obj_type'] = ACTIVITY_OBJ_NOTE;
$instrument = $act->get_property_obj('instrument'); $generator = $act->get_property_obj('generator');
if(! $instrument) if(! $generator)
$instrument = $act->get_property_obj('instrument',$act->obj); $generator = $act->get_property_obj('generator',$act->obj);
if($instrument && array_key_exists('type',$instrument) if($generator && array_key_exists('type',$generator)
&& $instrument['type'] === 'Service' && array_key_exists('name',$instrument)) { && in_array($generator['type'], [ 'Application','Service' ] ) && array_key_exists('name',$generator)) {
$s['app'] = escape_tags($instrument['name']); $s['app'] = escape_tags($generator['name']);
} }
if($channel['channel_system']) { if($channel['channel_system']) {
@ -1606,14 +1606,14 @@ class Activity {
$s['obj'] = $act->obj; $s['obj'] = $act->obj;
} }
$instrument = $act->get_property_obj('instrument'); $generator = $act->get_property_obj('generator');
if((! $instrument) && (! $response_activity)) { if((! $generator) && (! $response_activity)) {
$instrument = $act->get_property_obj('instrument',$act->obj); $generator = $act->get_property_obj('generator',$act->obj);
} }
if($instrument && array_key_exists('type',$instrument) if($generator && array_key_exists('type',$generator)
&& $instrument['type'] === 'Service' && array_key_exists('name',$instrument)) { && in_array($generator['type'], [ 'Application', 'Service' ] ) && array_key_exists('name',$generator)) {
$s['app'] = escape_tags($instrument['name']); $s['app'] = escape_tags($generator['name']);
} }