aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2020-01-12 22:41:28 -0800
committerzotlabs <mike@macgirvin.com>2020-01-12 22:41:28 -0800
commitd3cbbe029c1f19a77ac0c278f735d81b9dd3a3ec (patch)
tree327424bb0963a62a9a8bbfd2b8b588ced248080f
parent88ebbd90d8925a74029a32f57ec581d2b3ba64ed (diff)
downloadvolse-hubzilla-d3cbbe029c1f19a77ac0c278f735d81b9dd3a3ec.tar.gz
volse-hubzilla-d3cbbe029c1f19a77ac0c278f735d81b9dd3a3ec.tar.bz2
volse-hubzilla-d3cbbe029c1f19a77ac0c278f735d81b9dd3a3ec.zip
rework activitystreams events - send invite/event activities instead of create/event. Also a first pass at creating a Zap export file from Hubzilla. Much more work is needed before this is functional.
-rw-r--r--Zotlabs/Lib/Activity.php35
-rw-r--r--Zotlabs/Lib/ActivityStreams.php6
-rw-r--r--include/channel.php17
-rw-r--r--include/event.php2
4 files changed, 44 insertions, 16 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 08a8b8d03..a0956c501 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -611,10 +611,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 +672,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'])) {
@@ -1664,15 +1667,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('&#x1f501; Repeated %1$s\'s %2$s'), $mention, $act->obj['type']);
}
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/include/channel.php b/include/channel.php
index 32bd596fc..e7d119b1e 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -796,7 +796,7 @@ function get_default_export_sections() {
* @return array
* See function for details
*/
-function identity_basic_export($channel_id, $sections = null) {
+function identity_basic_export($channel_id, $sections = null, $zap_compat = false) {
/*
* basic channel export
@@ -812,12 +812,16 @@ function identity_basic_export($channel_id, $sections = null) {
// with a non-standard platform and version.
$ret['compatibility'] = [
- 'project' => PLATFORM_NAME,
+ 'project' => (($zap_compat) ? 'zap' : PLATFORM_NAME),
'version' => STD_VERSION,
'database' => DB_UPDATE_VERSION,
'server_role' => System::get_server_role()
];
+ if ($zap_compat) {
+ $ret['compatibility']['codebase'] = 'zap';
+ }
+
/*
* Process channel information regardless of it is one of the sections desired
* because we need the channel relocation information in all export files/streams.
@@ -834,6 +838,13 @@ function identity_basic_export($channel_id, $sections = null) {
unset($ret['channel']['channel_password']);
unset($ret['channel']['channel_salt']);
}
+ if ($zap_compat) {
+ $channel['channel_guid_sig'] = 'sha256.' . $channel['channel_guid_sig'];
+ $channel['channel_hash'] = $channel['channel_portable_id'];
+ unset($channel['channel_portable_id']);
+ }
+
+
}
if(in_array('channel',$sections) || in_array('profile',$sections)) {
@@ -853,7 +864,7 @@ function identity_basic_export($channel_id, $sections = null) {
$ret['photo'] = [
'type' => $r[0]['mimetype'],
'data' => (($r[0]['os_storage'])
- ? base64url_encode(file_get_contents($r[0]['content'])) : base64url_encode($r[0]['content']))
+ ? base64url_encode(file_get_contents($r[0]['content'])) : base64url_encode(dbunescbin($r[0]['content'])))
];
}
}
diff --git a/include/event.php b/include/event.php
index 9d76aabd6..30dca2df2 100644
--- a/include/event.php
+++ b/include/event.php
@@ -1194,7 +1194,7 @@ function event_store_item($arr, $event) {
if(! $arr['mid']) {
$arr['uuid'] = $event['event_hash'];
- $arr['mid'] = z_root() . '/event/' . $event['event_hash'];
+ $arr['mid'] = z_root() . '/activity/' . $event['event_hash'];
}
$item_arr['aid'] = $z[0]['channel_account_id'];