aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Activity.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Lib/Activity.php')
-rw-r--r--Zotlabs/Lib/Activity.php112
1 files changed, 110 insertions, 2 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index ef6ee6c3e..8cfa18997 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -32,6 +32,12 @@ class Activity {
if($x['type'] === ACTIVITY_OBJ_THING) {
return self::fetch_thing($x);
}
+ if($x['type'] === ACTIVITY_OBJ_EVENT) {
+ return self::fetch_event($x);
+ }
+ if($x['type'] === ACTIVITY_OBJ_PHOTO) {
+ return self::fetch_image($x);
+ }
return $x;
@@ -99,6 +105,63 @@ class Activity {
}
}
+
+ static function fetch_image($x) {
+
+
+ $ret = [
+ 'type' => 'Image',
+ 'id' => $x['id'],
+ 'name' => $x['title'],
+ 'content' => bbcode($x['body']),
+ 'source' => [ 'mediaType' => 'text/bbcode', 'content' => $x['body'] ],
+ 'published' => datetime_convert('UTC','UTC',$x['created'],ATOM_TIME),
+ 'updated' => datetime_convert('UTC','UTC', $x['edited'],ATOM_TIME),
+ 'url' => [
+ 'type' => 'Link',
+ 'mediaType' => $x['link'][0]['type'],
+ 'href' => $x['link'][0]['href'],
+ 'width' => $x['link'][0]['width'],
+ 'height' => $x['link'][0]['height']
+ ]
+ ];
+ return $ret;
+ }
+
+ static function fetch_event($x) {
+
+ // convert old Zot event objects to ActivityStreams Event objects
+
+ if (array_key_exists('content',$x) && array_key_exists('dtstart',$x)) {
+ $ev = bbtoevent($x['content']);
+ if($ev) {
+
+ $actor = null;
+ if(array_key_exists('author',$x) && array_key_exists('link',$x['author'])) {
+ $actor = $x['author']['link'][0]['href'];
+ }
+ $y = [
+ 'type' => 'Event',
+ 'id' => z_root() . '/event/' . $ev['event_hash'],
+ 'summary' => bbcode($ev['summary']),
+ // RFC3339 Section 4.3
+ 'startTime' => (($ev['adjust']) ? datetime_convert('UTC','UTC',$ev['dtstart'], ATOM_TIME) : datetime_convert('UTC','UTC',$ev['dtstart'],'Y-m-d\\TH:i:s-00:00')),
+ 'content' => bbcode($ev['description']),
+ 'location' => [ 'type' => 'Place', 'content' => bbcode($ev['location']) ],
+ 'source' => [ 'content' => format_event_bbcode($ev), 'mediaType' => 'text/bbcode' ],
+ 'actor' => $actor,
+ ];
+ if($actor) {
+ return $y;
+ }
+ }
+ }
+
+ return $x;
+
+ }
+
+
static function encode_item_collection($items,$id,$type,$extra = null) {
$ret = [
@@ -348,10 +411,17 @@ class Activity {
$ret['type'] = 'Tombstone';
$ret['formerType'] = self::activity_obj_mapper($i['obj_type']);
$ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/item/' . urlencode($i['mid']));
+ $actor = self::encode_person($i['author'],false);
+ if($actor)
+ $ret['actor'] = $actor;
+ else
+ return [];
return $ret;
}
$ret['type'] = self::activity_mapper($i['verb']);
+
+
$ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/activity/' . urlencode($i['mid']));
if($i['title'])
@@ -423,6 +493,10 @@ class Activity {
if(! is_array($i['obj'])) {
$i['obj'] = json_decode($i['obj'],true);
}
+ if($i['obj']['type'] === ACTIVITY_OBJ_PHOTO) {
+ $i['obj']['id'] = $i['id'];
+ }
+
$obj = self::encode_object($i['obj']);
if($obj)
$ret['object'] = $obj;
@@ -568,6 +642,9 @@ class Activity {
'http://activitystrea.ms/schema/1.0/tag' => 'Add',
'http://activitystrea.ms/schema/1.0/follow' => 'Follow',
'http://activitystrea.ms/schema/1.0/unfollow' => 'Unfollow',
+ 'http://purl.org/zot/activity/attendyes' => 'Accept',
+ 'http://purl.org/zot/activity/attendno' => 'Reject',
+ 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept'
];
@@ -607,6 +684,9 @@ class Activity {
'http://activitystrea.ms/schema/1.0/tag' => 'Add',
'http://activitystrea.ms/schema/1.0/follow' => 'Follow',
'http://activitystrea.ms/schema/1.0/unfollow' => 'Unfollow',
+ 'http://purl.org/zot/activity/attendyes' => 'Accept',
+ 'http://purl.org/zot/activity/attendno' => 'Reject',
+ 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept'
];
@@ -1412,7 +1492,33 @@ class Activity {
$s['obj_type'] = ACTIVITY_OBJ_COMMENT;
}
- $s['obj'] = $act->obj;
+
+ if($act->obj['type'] === 'Event') {
+ $s['obj'] = [];
+ $s['obj']['asld'] = $act->obj;
+ $s['obj']['type'] = ACTIVITY_OBJ_EVENT;
+ $s['obj']['id'] = $act->obj['id'];
+ $s['obj']['title'] = $act->obj['summary'];
+
+ if(strpos($act->obj['startTime'],'Z'))
+ $s['obj']['adjust'] = true;
+ else
+ $s['obj']['adjust'] = false;
+
+ $s['obj']['dtstart'] = datetime_convert('UTC','UTC',$act->obj['startTime']);
+ if($act->obj['endTime'])
+ $s['obj']['dtend'] = datetime_convert('UTC','UTC',$act->obj['endTime']);
+ else
+ $s['obj']['nofinish'] = true;
+ $s['obj']['description'] = $act->obj['content'];
+
+ if(array_path_exists('location/content',$act->obj))
+ $s['obj']['location'] = $act->obj['location']['content'];
+
+ }
+ else {
+ $s['obj'] = $act->obj;
+ }
$instrument = $act->get_property_obj('instrument');
if((! $instrument) && (! $response_activity)) {
@@ -1540,7 +1646,9 @@ class Activity {
}
- if($act->obj['type'] === 'Image') {
+ // avoid double images from hubzilla to zap/osada
+
+ if($act->obj['type'] === 'Image' && strpos($s['body'],'zrl=') === false) {
$ptr = null;