mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 21:35:13 +00:00
Merge branch 'dev' of ../unfediverse.com into dev
This commit is contained in:
commit
a8cf23361f
9 changed files with 82 additions and 12 deletions
|
@ -591,7 +591,7 @@ class Activity
|
|||
if (isset($att['type']) && strpos($att['type'], 'image')) {
|
||||
$ret[] = ['type' => 'Image', 'url' => $att['href']];
|
||||
} else {
|
||||
$ret[] = ['type' => 'Link', 'mediaType' => isset($att['type']) ? $att['type'] : 'application/octet-stream', 'href' => $att['href']];
|
||||
$ret[] = ['type' => 'Link', 'mediaType' => isset($att['type']) ? $att['type'] : 'application/octet-stream', 'href' => isset($att['href']) ? $att['href'] : ''];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2817,7 +2817,7 @@ class Activity
|
|||
|
||||
if (array_key_exists('published', $act->data) && $act->data['published']) {
|
||||
$s['created'] = datetime_convert('UTC', 'UTC', $act->data['published']);
|
||||
} elseif (is_array($acct->obj) && array_key_exists('published', $act->obj) && $act->obj['published']) {
|
||||
} elseif (is_array($act->obj) && array_key_exists('published', $act->obj) && $act->obj['published']) {
|
||||
$s['created'] = datetime_convert('UTC', 'UTC', $act->obj['published']);
|
||||
}
|
||||
if (array_key_exists('updated', $act->data) && $act->data['updated']) {
|
||||
|
|
|
@ -375,6 +375,10 @@ class Libsync
|
|||
sync_xign($channel, $arr['xign']);
|
||||
}
|
||||
|
||||
if (array_key_exists('block_xchan', $arr) && $arr['block_xchan']) {
|
||||
import_xchans($arr['block_xchan']);
|
||||
}
|
||||
|
||||
if (array_key_exists('block', $arr) && $arr['block']) {
|
||||
sync_block($channel, $arr['block']);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ class Yaml
|
|||
|
||||
public static function decode($data)
|
||||
{
|
||||
$value = false;
|
||||
try {
|
||||
$value = Syaml::parse($data);
|
||||
} catch (ParseException $exception) {
|
||||
|
|
|
@ -459,8 +459,12 @@ class Connedit extends Controller
|
|||
);
|
||||
$sync = LibBlock::fetch_by_entity(local_channel(), $orig_record['abook_xchan']);
|
||||
}
|
||||
$r = q("select * from xchan where xchan_hash = '%s'",
|
||||
dbesc($orig_record['abook_xchan'])
|
||||
);
|
||||
|
||||
$ignored = ['uid' => local_channel(), 'xchan' => $orig_record['abook_xchan']];
|
||||
Libsync::build_sync_packet(0, ['xign' => [$ignored], 'block' => [$sync]]);
|
||||
Libsync::build_sync_packet(0, ['xign' => [$ignored], 'block' => [$sync], 'block_xchan' => $r]);
|
||||
$flag_result = abook_toggle_flag($orig_record, ABOOK_FLAG_BLOCKED);
|
||||
break;
|
||||
case 'ignore':
|
||||
|
|
|
@ -522,6 +522,9 @@ class Import extends Controller
|
|||
if (is_array($data['block'])) {
|
||||
import_block($channel, $data['block']);
|
||||
}
|
||||
if (is_array($data['block_xchan'])) {
|
||||
import_xchans($data['block_xchan']);
|
||||
}
|
||||
if (is_array($data['obj'])) {
|
||||
import_objs($channel, $data['obj']);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,8 @@ class Superblock extends Controller
|
|||
$sync = [];
|
||||
|
||||
$sync['block'] = [LibBlock::fetch_by_entity(local_channel(), $blocked)];
|
||||
|
||||
$sync['block_xchan'] = [$r];
|
||||
|
||||
if ($type === BLOCKTYPE_CHANNEL) {
|
||||
$z = q(
|
||||
"insert into xign ( uid, xchan ) values ( %d , '%s' ) ",
|
||||
|
|
|
@ -376,6 +376,38 @@ function import_profiles($channel, $profiles)
|
|||
}
|
||||
}
|
||||
|
||||
function import_xchans($xchans) {
|
||||
|
||||
// WARNING: this does not import xchan photos
|
||||
|
||||
if ($xchans) {
|
||||
foreach ($xchans as $xchan) {
|
||||
// Provide backward compatibility for zot11 based projects
|
||||
|
||||
if ($xchan['xchan_network'] === 'nomad' && version_compare(ZOT_REVISION, '10.0') <= 0) {
|
||||
$xchan['xchan_network'] = 'zot6';
|
||||
}
|
||||
|
||||
$hash = Libzot::make_xchan_hash($xchan['xchan_guid'], $xchan['xchan_pubkey']);
|
||||
|
||||
if (in_array($xchan['xchan_network'], ['nomad', 'zot6']) && $hash !== $xchan['xchan_hash']) {
|
||||
logger('forged xchan: ' . print_r($xchan, true));
|
||||
continue;
|
||||
}
|
||||
|
||||
$r = q(
|
||||
"select xchan_hash from xchan where xchan_hash = '%s' limit 1",
|
||||
dbesc($xchan['xchan_hash'])
|
||||
);
|
||||
if ($r) {
|
||||
continue;
|
||||
}
|
||||
xchan_store_lowlevel($xchan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Import hublocs.
|
||||
*
|
||||
|
@ -981,7 +1013,7 @@ function import_items($channel, $items, $sync = false, $relocate = null)
|
|||
if (! $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ($relocate && $item['mid'] === $item['parent_mid']) {
|
||||
item_url_replace($channel, $item, $relocate['url'], z_root(), $relocate['channel_address']);
|
||||
}
|
||||
|
|
|
@ -731,6 +731,7 @@ function get_item_elements($x,$allow_code = false) {
|
|||
}
|
||||
|
||||
$arr['attach'] = activity_sanitise($x['attach']);
|
||||
|
||||
$arr['replyto'] = activity_sanitise($x['replyto']);
|
||||
$arr['term'] = isset($x['tags']) ? decode_tags($x['tags']) : [];
|
||||
$arr['iconfig'] = decode_item_meta($x['meta']);
|
||||
|
@ -850,7 +851,6 @@ function get_item_elements($x,$allow_code = false) {
|
|||
$arr['postopts'] = $x['postopts'];
|
||||
$arr['resource_id'] = $x['resource_id'];
|
||||
$arr['resource_type'] = $x['resource_type'];
|
||||
$arr['attach'] = $x['attach'];
|
||||
$arr['item_origin'] = intval($x['item_origin']);
|
||||
$arr['item_unseen'] = intval($x['item_unseen']);
|
||||
$arr['item_starred'] = intval($x['item_starred']);
|
||||
|
@ -1674,8 +1674,7 @@ function item_store($arr, $allow_exec = false, $deliver = true, $linkid = true)
|
|||
if(x($arr,'attach')) {
|
||||
$arr['attach'] = item_json_encapsulate($arr,'attach');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$arr['aid'] = ((x($arr,'aid')) ? intval($arr['aid']) : 0);
|
||||
$arr['mid'] = ((x($arr,'mid')) ? notags(trim($arr['mid'])) : random_string());
|
||||
$arr['revision'] = ((x($arr,'revision') && intval($arr['revision']) > 0) ? intval($arr['revision']) : 0);
|
||||
|
@ -2179,6 +2178,7 @@ function item_store_update($arr, $allow_exec = false, $deliver = true, $linkid =
|
|||
$arr['attach'] = item_json_encapsulate($arr,'attach');
|
||||
}
|
||||
|
||||
|
||||
unset($arr['id']);
|
||||
unset($arr['uid']);
|
||||
unset($arr['aid']);
|
||||
|
@ -2248,6 +2248,7 @@ function item_store_update($arr, $allow_exec = false, $deliver = true, $linkid =
|
|||
|
||||
|
||||
$arr['attach'] = ((array_key_exists('attach',$arr)) ? notags(trim($arr['attach'])) : $orig[0]['attach']);
|
||||
|
||||
$arr['app'] = ((array_key_exists('app',$arr)) ? notags(trim($arr['app'])) : $orig[0]['app']);
|
||||
|
||||
$arr['item_origin'] = ((array_key_exists('item_origin',$arr)) ? intval($arr['item_origin']) : $orig[0]['item_origin'] );
|
||||
|
|
|
@ -3437,23 +3437,47 @@ function json_url_replace($old, $new, &$s)
|
|||
function item_url_replace($channel, &$item, $old, $new, $oldnick = '')
|
||||
{
|
||||
|
||||
if ($item['attach']) {
|
||||
if (isset($item['attach']) && $item['attach']) {
|
||||
$converted = false;
|
||||
if (is_array($item['attach'])) {
|
||||
$item['attach'] = item_json_encapsulate($item,'attach');
|
||||
$converted = true;
|
||||
}
|
||||
json_url_replace($old, $new, $item['attach']);
|
||||
if ($oldnick && ($oldnick !== $channel['channel_address'])) {
|
||||
json_url_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['attach']);
|
||||
}
|
||||
if ($converted) {
|
||||
$item['attach'] = json_decode($item['attach'],true);
|
||||
}
|
||||
}
|
||||
if ($item['object']) {
|
||||
json_url_replace($old, $new, $item['object']);
|
||||
if ($item['obj']) {
|
||||
$converted = false;
|
||||
if (is_array($item['obj'])) {
|
||||
$item['obj'] = item_json_encapsulate($item,'obj');
|
||||
$converted = true;
|
||||
}
|
||||
json_url_replace($old, $new, $item['obj']);
|
||||
if ($oldnick && ($oldnick !== $channel['channel_address'])) {
|
||||
json_url_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['object']);
|
||||
json_url_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['obj']);
|
||||
}
|
||||
if ($converted) {
|
||||
$item['obj'] = json_decode($item['obj'],true);
|
||||
}
|
||||
}
|
||||
if ($item['target']) {
|
||||
$converted = false;
|
||||
if (is_array($item['target'])) {
|
||||
$item['target'] = item_json_encapsulate($item,'target');
|
||||
$converted = true;
|
||||
}
|
||||
json_url_replace($old, $new, $item['target']);
|
||||
if ($oldnick && ($oldnick !== $channel['channel_address'])) {
|
||||
json_url_replace('/' . $oldnick . '/', '/' . $channel['channel_address'] . '/', $item['target']);
|
||||
}
|
||||
if ($converted) {
|
||||
$item['target'] = json_decode($item['target'],true);
|
||||
}
|
||||
}
|
||||
|
||||
$item['body'] = str_replace($old, $new, $item['body']);
|
||||
|
|
Loading…
Reference in a new issue