diff options
author | nobody <nobody@zotlabs.com> | 2021-02-17 19:42:58 -0800 |
---|---|---|
committer | nobody <nobody@zotlabs.com> | 2021-02-17 19:42:58 -0800 |
commit | 62b738da953e8b59f03660eeab592dc58e83ccb0 (patch) | |
tree | 7d99b00b468264cb5d275a6e7b19bdf6b1e4d387 | |
parent | e7c7f91a3fec224ca32459b950caaa25f73c3b1f (diff) | |
download | volse-hubzilla-62b738da953e8b59f03660eeab592dc58e83ccb0.tar.gz volse-hubzilla-62b738da953e8b59f03660eeab592dc58e83ccb0.tar.bz2 volse-hubzilla-62b738da953e8b59f03660eeab592dc58e83ccb0.zip |
migration testing
-rw-r--r-- | Zotlabs/Lib/Activity.php | 32 | ||||
-rw-r--r-- | include/channel.php | 23 | ||||
-rw-r--r-- | include/items.php | 25 |
3 files changed, 65 insertions, 15 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index d4d1cd28c..d286f35c2 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -423,7 +423,7 @@ class Activity { $ret['published'] = datetime_convert('UTC', 'UTC', $i['created'], ATOM_TIME); if ($i['created'] !== $i['edited']) $ret['updated'] = datetime_convert('UTC', 'UTC', $i['edited'], ATOM_TIME); - if ($i['expires'] <= NULL_DATE) { + if ($i['expires'] > NULL_DATE) { $ret['expires'] = datetime_convert('UTC', 'UTC', $i['expires'], ATOM_TIME); } @@ -450,7 +450,7 @@ class Activity { $ret['directMessage'] = true; } - if (array_key_exists('comments_closed', $i) && $i['comments_closed'] !== EMPTY_STR && $i['comments_closed'] !== NULL_DATE) { + if (array_key_exists('comments_closed', $i) && $i['comments_closed'] !== EMPTY_STR && $i['comments_closed'] > NULL_DATE) { if ($ret['commentPolicy']) { $ret['commentPolicy'] .= ' '; } @@ -1109,6 +1109,34 @@ class Activity { return $ret; } + static function encode_item_object($item, $elm = 'obj') { + $ret = []; + + if ($item[$elm]) { + if (! is_array($item[$elm])) { + $item[$elm] = json_decode($item[$elm],true); + } + if ($item[$elm]['type'] === ACTIVITY_OBJ_PHOTO) { + $item[$elm]['id'] = $item['mid']; + } + + $obj = self::encode_object($item[$elm]); + if ($obj) + return $obj; + else + return []; + } + else { + $obj = self::encode_item($item); + if ($obj) + return $obj; + else + return []; + } + + } + + static function activity_mapper($verb) { if (strpos($verb, '/') === false) { diff --git a/include/channel.php b/include/channel.php index cc5761162..fb9dcbc53 100644 --- a/include/channel.php +++ b/include/channel.php @@ -903,8 +903,20 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals $r = q("select * from profile where uid = %d", intval($channel_id) ); - if($r) + + if($r) { $ret['profile'] = $r; + if ($zap_compat) { + // zap only supports one profile + foreach ($r as $rv) { + if ($rv['is_default']) { + $ret['profile'] = [ $rv ]; + break; + } + } + } + } + $r = q("select mimetype, content, os_storage from photo where imgscale = 4 and photo_usage = %d and uid = %d limit 1", @@ -1092,15 +1104,20 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals // @fixme - Not totally certain how to handle $zot_compat for the event timezone which exists // in Hubzilla but is stored with the item and not the event. In Zap, stored information is // always UTC and localised on access as per standard conventions for working with global time data. + + // Older Zot (pre-Zot6) records aren't translated correctly w/r/t AS2 so only include events for the last year or so if + // migrating to Zap. - $r = q("select * from event where uid = %d", + $sqle = (($zap_compat) ? " and created > '2020-01-01 00:00:00' " : ''); + + $r = q("select * from event where uid = %d $sqle", intval($channel_id) ); if ($r) { $ret['event'] = $r; } - $r = q("select * from item where resource_type = 'event' and uid = %d", + $r = q("select * from item where resource_type = 'event' and uid = %d $sqle", intval($channel_id) ); if($r) { diff --git a/include/items.php b/include/items.php index 5b6dabde4..1eecfcb0b 100644 --- a/include/items.php +++ b/include/items.php @@ -1168,8 +1168,8 @@ function encode_item($item,$mirror = false,$zap_compat = false) { $x['body'] = $item['body']; $x['app'] = $item['app']; $x['verb'] = (($zap_compat) ? Activity::activity_mapper($item['verb']) : $item['verb']); - $x['object_type'] = (($zap_compat && $item['obj_type']) ? Activity::activity_object_mapper($item['obj_type']) : $item['obj_type']); - $x['target_type'] = (($zap_compat && $item['tgt_type']) ? Activity::activity_object_mapper($item['tgt_type']) : $item['tgt_type']); + $x['object_type'] = (($zap_compat && $item['obj_type']) ? Activity::activity_obj_mapper($item['obj_type']) : $item['obj_type']); + $x['target_type'] = (($zap_compat && $item['tgt_type']) ? Activity::activity_obj_mapper($item['tgt_type']) : $item['tgt_type']); $x['permalink'] = $item['plink']; $x['location'] = $item['location']; $x['longlat'] = $item['coord']; @@ -1178,13 +1178,18 @@ function encode_item($item,$mirror = false,$zap_compat = false) { $x['owner'] = encode_item_xchan($item['owner']); $x['author'] = encode_item_xchan($item['author']); - if($item['obj']) - $x['object'] = (($zap_compat) - ? Activity::encode_object(json_decode($item['obj'],true)) - : json_decode($item['obj'],true)) ; + if ($zap_compat) { + $x['object'] = Activity::encode_item_object($item,'obj'); + } + else { + if ($item['obj']) { + $x['object'] = json_decode($item['obj'],true); + } + } + if($item['target']) $x['target'] = (($zap_compat) - ? Activity::encode_object(json_decode($item['target'],true)) + ? Activity::encode_item_object($item,'target') : json_decode($item['target'],true)) ; if($item['attach']) $x['attach'] = json_decode($item['attach'],true); @@ -1206,9 +1211,9 @@ function encode_item($item,$mirror = false,$zap_compat = false) { if($item['iconfig']) { if ($zap_compat) { - for ($x = 0; $x < count($item['iconfig']); $x ++) { - if (preg_match('|^a:[0-9]+:{.*}$|s', $item['iconfig'][$x]['v'])) { - $item['iconfig'][$x]['v'] = serialise(unserialize($item['iconfig'][$x]['v'])); + for ($y = 0; $y < count($item['iconfig']); $y ++) { + if (preg_match('|^a:[0-9]+:{.*}$|s', $item['iconfig'][$y]['v'])) { + $item['iconfig'][$y]['v'] = serialise(unserialize($item['iconfig'][$y]['v'])); } } } |