diff options
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r-- | Zotlabs/Lib/Activity.php | 88 | ||||
-rw-r--r-- | Zotlabs/Lib/ActivityStreams.php | 6 | ||||
-rw-r--r-- | Zotlabs/Lib/Apps.php | 1 | ||||
-rw-r--r-- | Zotlabs/Lib/Enotify.php | 6 | ||||
-rw-r--r-- | Zotlabs/Lib/Libsync.php | 4 | ||||
-rw-r--r-- | Zotlabs/Lib/Libzot.php | 11 | ||||
-rw-r--r-- | Zotlabs/Lib/ThreadItem.php | 10 |
7 files changed, 87 insertions, 39 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); diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 006744aff..d8bd72943 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -101,7 +101,13 @@ class ActivityStreams { $this->actor = $this->get_actor('attributedTo',$this->obj); } } + + // fetch recursive or embedded activities + if ($this->obj && is_array($this->obj) && array_key_exists('object',$this->obj)) { + $this->obj['object'] = $this->get_compound_property($this->obj['object']); + } + if($this->obj && is_array($this->obj) && $this->obj['actor']) $this->obj['actor'] = $this->get_actor('actor',$this->obj); if($this->tgt && is_array($this->tgt) && $this->tgt['actor']) diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 69996b49d..9d60e9eae 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -74,7 +74,6 @@ class Apps { 'Directory', 'Search', 'Help', - 'Mail', 'Profile Photo' ]); diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index bc2710ee1..f6f8ad0cb 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -811,10 +811,10 @@ class Enotify { else { $itemem_text = (($item['item_thread_top']) ? t('created a new post') - : sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name'])); + : sprintf( t('commented on %s\'s post'), '[bdi]' . $item['owner']['xchan_name'] . '[/bdi]')); if($item['verb'] === ACTIVITY_SHARE) { - $itemem_text = sprintf( t('repeated %s\'s post'), $item['author']['xchan_name']); + $itemem_text = sprintf( t('repeated %s\'s post'), '[bdi]' . $item['author']['xchan_name'] . '[/bdi]'); } } @@ -849,7 +849,7 @@ class Enotify { //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), 'notify_id' => 'undefined', 'thread_top' => (($item['item_thread_top']) ? true : false), - 'message' => strip_tags(bbcode($itemem_text)), + 'message' => bbcode(escape_tags($itemem_text)), // these are for the superblock addon 'hash' => $item[$who]['xchan_hash'], 'uid' => $item['uid'], diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php index d93270bc5..b9e9bb38a 100644 --- a/Zotlabs/Lib/Libsync.php +++ b/Zotlabs/Lib/Libsync.php @@ -83,7 +83,7 @@ class Libsync { $info = (($packet) ? $packet : array()); $info['type'] = 'sync'; - $info['encoding'] = 'red'; // note: not zot, this packet is very platform specific + $info['encoding'] = 'hz'; // note: not zot, this packet is very platform specific $info['relocate'] = ['channel_address' => $channel['channel_address'], 'url' => z_root() ]; if(array_key_exists($uid,\App::$config) && array_key_exists('transient',\App::$config[$uid])) { @@ -144,7 +144,7 @@ class Libsync { foreach($synchubs as $hub) { $hash = random_string(); - $n = Libzot::build_packet($channel,'sync',$env_recips,json_encode($info),'red',$hub['hubloc_sitekey'],$hub['site_crypto']); + $n = Libzot::build_packet($channel,'sync',$env_recips,json_encode($info),'hz',$hub['hubloc_sitekey'],$hub['site_crypto']); Queue::insert(array( 'hash' => $hash, 'account_id' => $channel['channel_account_id'], diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 100d45c05..bb70dfbf2 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1220,8 +1220,8 @@ class Libzot { $arr['owner_xchan'] = $env['sender']; } - if($private) { - $arr['item_private'] = true; + if ($private && (! intval($arr['item_private']))) { + $arr['item_private'] = 1; } if ($arr['mid'] === $arr['parent_mid']) { @@ -1277,7 +1277,12 @@ class Libzot { logger('Channel sync received: ' . print_r($arr,true), LOGGER_DATA, LOG_DEBUG); logger('Channel sync recipients: ' . print_r($deliveries,true), LOGGER_DATA, LOG_DEBUG); - $result = Libsync::process_channel_sync_delivery($env['sender'],$arr,$deliveries); + if ($env['encoding'] === 'hz') { + $result = Libsync::process_channel_sync_delivery($env['sender'],$arr,$deliveries); + } + else { + logger('sync packet type not supported.'); + } } } if ($result) { diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 301ce1a18..2386a1f0d 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -346,7 +346,7 @@ class ThreadItem { $viewthread = z_root() . '/channel/' . $owner_address . '?f=&mid=' . urlencode(gen_link_id($item['mid'])); $comment_count_txt = sprintf( tt('%d comment','%d comments',$total_children),$total_children ); - $list_unseen_txt = (($unseen_comments) ? sprintf('%d unseen',$unseen_comments) : ''); + $list_unseen_txt = (($unseen_comments) ? sprintf( t('%d unseen'),$unseen_comments) : ''); $children = $this->get_children(); @@ -377,7 +377,7 @@ class ThreadItem { 'template' => $this->get_template(), 'mode' => $mode, 'item_type' => intval($item['item_type']), - 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), + //'type' => implode("",array_slice(explode("/",$item['verb']),-1)), 'body' => $body['html'], 'tags' => $body['tags'], 'categories' => $body['categories'], @@ -395,8 +395,8 @@ class ThreadItem { 'consensus' => $consensus, 'conlabels' => $conlabels, 'canvote' => $canvote, - 'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url'])), - 'olinktitle' => sprintf( t('View %s\'s profile - %s'), $this->get_owner_name(), (($item['owner']['xchan_addr']) ? $item['owner']['xchan_addr'] : $item['owner']['xchan_url'])), + 'linktitle' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']), + 'olinktitle' => (($item['owner']['xchan_addr']) ? $item['owner']['xchan_addr'] : $item['owner']['xchan_url']), 'llink' => $item['llink'], 'viewthread' => $viewthread, 'to' => t('to'), @@ -414,7 +414,7 @@ class ThreadItem { 'sparkle' => $sparkle, 'title' => $item['title'], 'title_tosource' => get_pconfig($conv->get_profile_owner(),'system','title_tosource'), - 'ago' => relative_date($item['created']), + //'ago' => relative_date($item['created']), 'app' => $item['app'], 'str_app' => sprintf( t('from %s'), $item['app']), 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), |