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.php88
1 files changed, 63 insertions, 25 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 08a8b8d03..43315a87f 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -168,6 +168,10 @@ class Activity {
if($r) {
xchan_query($r,true);
$r = fetch_post_tags($r,true);
+ if ($r[0]['verb'] === 'Create' && $r[0]['obj_type'] === ACTIVITY_OBJ_EVENT) {
+ $r[0]['verb'] = 'Invite';
+ return self::encode_activity($r[0]);
+ }
return self::encode_item($r[0]);
}
}
@@ -220,7 +224,7 @@ class Activity {
'startTime' => (($ev['adjust']) ? datetime_convert($ev['timezone'],'UTC',$ev['dtstart'], ATOM_TIME) : datetime_convert('UTC','UTC',$ev['dtstart'],'Y-m-d\\TH:i:s-00:00')),
'content' => bbcode($ev['description'], [ 'cache' => true ]),
'location' => [ 'type' => 'Place', 'content' => bbcode($ev['location'], [ 'cache' => true ]) ],
- 'source' => [ 'content' => format_event_bbcode($ev), 'mediaType' => 'text/bbcode' ],
+ 'source' => [ 'content' => format_event_bbcode($ev,true), 'mediaType' => 'text/bbcode' ],
'actor' => $actor,
];
if(! $ev['nofinish']) {
@@ -611,10 +615,10 @@ class Activity {
if($i['id'] != $i['parent']) {
$reply = true;
- // inReplyTo needs to be set in the activity for followup actiions (Like, Dislike, Attend, Announce, etc.),
- // but *not* for comments, where it should only be present in the object
-
- if (! in_array($ret['type'],[ 'Create','Update' ])) {
+ // inReplyTo needs to be set in the activity for followup actions (Like, Dislike, Announce, etc.),
+ // but *not* for comments and RSVPs, where it should only be present in the object
+
+ if (! in_array($ret['type'],[ 'Create','Update','Accept','Reject','TentativeAccept','TentativeReject' ])) {
$ret['inReplyTo'] = ((strpos($i['thr_parent'],'http') === 0) ? $i['thr_parent'] : z_root() . '/item/' . urlencode($i['thr_parent']));
}
@@ -672,6 +676,9 @@ class Activity {
return [];
}
+ if(array_path_exists('object/type',$ret) && $ret['object']['type'] === 'Event' && $ret['type'] === 'Create') {
+ $ret['type'] = 'Invite';
+ }
if($i['target']) {
if(! is_array($i['target'])) {
@@ -822,7 +829,8 @@ class Activity {
'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'
+ 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept',
+ 'Invite' => 'Invite',
];
call_hooks('activity_mapper',$acts);
@@ -868,7 +876,8 @@ class Activity {
'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'
+ 'http://purl.org/zot/activity/attendmaybe' => 'TentativeAccept',
+ 'Invite' => 'Invite',
];
call_hooks('activity_decode_mapper',$acts);
@@ -902,6 +911,7 @@ class Activity {
'http://purl.org/zot/activity/thing' => 'Object',
'http://purl.org/zot/activity/file' => 'zot:File',
'http://purl.org/zot/activity/mood' => 'zot:Mood',
+ 'Invite' => 'Invite',
];
@@ -941,7 +951,7 @@ class Activity {
'http://purl.org/zot/activity/thing' => 'Object',
'http://purl.org/zot/activity/file' => 'zot:File',
'http://purl.org/zot/activity/mood' => 'zot:Mood',
-
+ 'Invite' => 'Invite',
];
call_hooks('activity_obj_mapper',$objs);
@@ -1664,15 +1674,23 @@ class Activity {
if($act->type === 'Dislike') {
$content['content'] = sprintf( t('Doesn\'t like %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content'];
}
- if($act->type === 'Accept' && $act->obj['type'] === 'Event' ) {
- $content['content'] = sprintf( t('Will attend %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content'];
- }
- if($act->type === 'Reject' && $act->obj['type'] === 'Event' ) {
- $content['content'] = sprintf( t('Will not attend %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content'];
- }
- if($act->type === 'TentativeAccept' && $act->obj['type'] === 'Event' ) {
- $content['content'] = sprintf( t('May attend %1$s\'s %2$s'),$mention,$act->obj['type']) . "\n\n" . $content['content'];
+
+ // handle event RSVPs
+ if (($act->obj['type'] === 'Event') || ($act->obj['type'] === 'Invite' && array_path_exists('object/type',$act->obj) && $act->obj['object']['type'] === 'Event')) {
+ if ($act->type === 'Accept') {
+ $content['content'] = sprintf( t('Will attend %s\'s event'),$mention) . EOL . EOL . $content['content'];
+ }
+ if ($act->type === 'Reject') {
+ $content['content'] = sprintf( t('Will not attend %s\'s event'),$mention) . EOL . EOL . $content['content'];
+ }
+ if ($act->type === 'TentativeAccept') {
+ $content['content'] = sprintf( t('May attend %s\'s event'),$mention) . EOL . EOL . $content['content'];
+ }
+ if ($act->type === 'TentativeReject') {
+ $content['content'] = sprintf( t('May not attend %s\'s event'),$mention) . EOL . EOL . $content['content'];
+ }
}
+
if($act->type === 'Announce') {
$content['content'] = sprintf( t('🔁 Repeated %1$s\'s %2$s'), $mention, $act->obj['type']);
}
@@ -1703,28 +1721,42 @@ class Activity {
$s['obj_type'] = ACTIVITY_OBJ_COMMENT;
}
+ $eventptr = null;
+
+ if ($act->obj['type'] === 'Invite' && array_path_exists('object/type',$act->obj) && $act->obj['object']['type'] === 'Event') {
+ $eventptr = $act->obj['object'];
+ $s['mid'] = $s['parent_mid'] = $act->obj['id'];
+ }
+
if($act->obj['type'] === 'Event') {
+ if ($act->type === 'Invite') {
+ $s['mid'] = $s['parent_mid'] = $act->id;
+ }
+ $eventptr = $act->obj;
+ }
+
+ if ($eventptr) {
$s['obj'] = [];
- $s['obj']['asld'] = $act->obj;
+ $s['obj']['asld'] = $eventptr;
$s['obj']['type'] = ACTIVITY_OBJ_EVENT;
- $s['obj']['id'] = $act->obj['id'];
- $s['obj']['title'] = $act->obj['name'];
+ $s['obj']['id'] = $eventptr['id'];
+ $s['obj']['title'] = $eventptr['name'];
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']);
+ $s['obj']['dtstart'] = datetime_convert('UTC','UTC',$eventptr['startTime']);
if($act->obj['endTime'])
- $s['obj']['dtend'] = datetime_convert('UTC','UTC',$act->obj['endTime']);
+ $s['obj']['dtend'] = datetime_convert('UTC','UTC',$eventptr['endTime']);
else
$s['obj']['nofinish'] = true;
- $s['obj']['description'] = $act->obj['content'];
+ $s['obj']['description'] = $eventptr['content'];
- if(array_path_exists('location/content',$act->obj))
- $s['obj']['location'] = $act->obj['location']['content'];
+ if(array_path_exists('location/content',$eventptr))
+ $s['obj']['location'] = $eventptr['location']['content'];
}
else {
@@ -1957,9 +1989,15 @@ class Activity {
$s['plink'] = $s['mid'];
}
- if($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips)))
+ if ($act->recips && (! in_array(ACTIVITY_PUBLIC_INBOX,$act->recips)))
$s['item_private'] = 1;
+ if (is_array($act->obj)) {
+ if (array_key_exists('directMessage',$act->obj) && intval($act->obj['directMessage'])) {
+ $s['item_private'] = 2;
+ }
+ }
+
set_iconfig($s,'activitypub','recips',$act->raw_recips);
$parent = (($s['parent_mid'] && $s['parent_mid'] === $s['mid']) ? true : false);