use the more portable encoded_item format for exported items - but with added attributes so we can use it as a reasonably complete item backup. The encoded_item format gives us extended author and owner information in case we need to probe them to bring the entry back. It also contains taxonomy entries. Importing and/or recovering will best be accomplished in chunks. It could take some time and some memory to chew through this.
This commit is contained in:
parent
b2f2424b52
commit
a1b66f56f0
@ -489,18 +489,12 @@ function identity_basic_export($channel_id, $items = false) {
|
|||||||
intval($channel_id)
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
if($r) {
|
if($r) {
|
||||||
for($x = 0; $x < count($r); $x ++) {
|
$ret['item'] = array();
|
||||||
if($r[$x]['diaspora_meta'])
|
xchan_query($r);
|
||||||
$r[$x]['diaspora_meta'] = crypto_unencapsulate(json_decode($r[$x]['diaspora_meta'],true),$key);
|
$r = fetch_post_tags($r,true);
|
||||||
if($r[$x]['item_flags'] & ITEM_OBSCURED) {
|
foreach($r as $rr)
|
||||||
$r[$x]['item_flags'] = $r[$x]['item_flags'] ^ ITEM_OBSCURED;
|
$ret['item'][] = encode_item($rr,true);
|
||||||
if($r[$x]['title'])
|
|
||||||
$r[$x]['title'] = crypto_unencapsulate(json_decode($r[$x]['title'],true),$key);
|
|
||||||
if($r[$x]['body'])
|
|
||||||
$r[$x]['body'] = crypto_unencapsulate(json_decode($r[$x]['body'],true),$key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$ret['item'] = $r;
|
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
|
@ -1007,8 +1007,7 @@ function import_author_unknown($x) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function encode_item($item,$mirror = false) {
|
||||||
function encode_item($item) {
|
|
||||||
$x = array();
|
$x = array();
|
||||||
$x['type'] = 'activity';
|
$x['type'] = 'activity';
|
||||||
$x['encoding'] = 'zot';
|
$x['encoding'] = 'zot';
|
||||||
@ -1030,14 +1029,37 @@ function encode_item($item) {
|
|||||||
|
|
||||||
$c_scope = map_scope($comment_scope);
|
$c_scope = map_scope($comment_scope);
|
||||||
|
|
||||||
|
$key = get_config('system','prvkey');
|
||||||
|
|
||||||
if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
|
if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
|
||||||
$key = get_config('system','prvkey');
|
|
||||||
if($item['title'])
|
if($item['title'])
|
||||||
$item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
|
$item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
|
||||||
if($item['body'])
|
if($item['body'])
|
||||||
$item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
|
$item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're trying to backup an item so that it's recoverable or for export/imprt,
|
||||||
|
// add all the attributes we need to recover it
|
||||||
|
|
||||||
|
if($mirror) {
|
||||||
|
$x['id'] = $item['id'];
|
||||||
|
$x['parent'] = $item['parent'];
|
||||||
|
$x['uid'] = $item['uid'];
|
||||||
|
$x['allow_cid'] = $item['allow_cid'];
|
||||||
|
$x['allow_gid'] = $item['allow_gid'];
|
||||||
|
$x['deny_cid'] = $item['deny_cid'];
|
||||||
|
$x['deny_gid'] = $item['deny_gid'];
|
||||||
|
$x['revision'] = $item['revision'];
|
||||||
|
$x['layout_mid'] = $item['layout_mid'];
|
||||||
|
$x['postopts'] = $item['postopts'];
|
||||||
|
$x['resource_id'] = $item['resource_id'];
|
||||||
|
$x['resource_type'] = $item['resource_type'];
|
||||||
|
$x['item_restrict'] = $item['item_restrict'];
|
||||||
|
$x['item_flags'] = $item['item_flags'];
|
||||||
|
$x['diaspora_meta'] = crypto_unencapsulate(json_decode($item['diaspora_meta'],true),$key);
|
||||||
|
$x['attach'] = $item['attach'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$x['message_id'] = $item['mid'];
|
$x['message_id'] = $item['mid'];
|
||||||
$x['message_top'] = $item['parent_mid'];
|
$x['message_top'] = $item['parent_mid'];
|
||||||
|
@ -1 +1 @@
|
|||||||
2014-09-15.799
|
2014-09-16.800
|
||||||
|
Reference in New Issue
Block a user