sync categories

This commit is contained in:
Mario
2020-12-14 21:38:49 +00:00
parent 78c0926a64
commit e58e27ce22
2 changed files with 31 additions and 2 deletions

View File

@@ -2306,6 +2306,18 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
$r[0]['content'] = dbunescbin($r[0]['content']);
$hash_ptr = $r[0]['folder'];
$r[0]['term'] = [];
$term = q("SELECT * FROM term WHERE uid = %d AND oid = %d AND otype = %d",
intval($channel['channel_id']),
intval($r[0]['id']),
intval(TERM_OBJ_FILE)
);
if ($term)
$r[0]['term'] = array_reverse($term);
$paths[] = $r[0];
} while($hash_ptr);
@@ -2314,7 +2326,6 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
$ret['attach'] = $paths;
if($attach_ptr['is_photo']) {
// This query could potentially result in a few megabytes of data use.

View File

@@ -1352,7 +1352,6 @@ function sync_files($channel, $files) {
}
$redirects = 0;
$headers = [];
$headers['Accept'] = 'application/x-zot+json' ;
$headers['Sigtoken'] = random_string();
@@ -1363,6 +1362,25 @@ function sync_files($channel, $files) {
if($x['success']) {
$attachment_stored = true;
$a = q("SELECT id FROM attach WHERE hash = '%s' AND uid = %d LIMIT 1",
dbesc($att['hash']),
intval($channel['channel_id'])
);
if($a) {
q("DELETE FROM term WHERE uid = %d AND oid = %d AND otype = %d",
intval($channel['channel_id']),
intval($a[0]['id']),
intval(TERM_OBJ_FILE)
);
if($att['term']) {
foreach($att['term'] as $t) {
if(array_key_exists('type',$t))
$t['ttype'] = $t['type'];
store_item_tag($channel['channel_id'], $a[0]['id'], TERM_OBJ_FILE, $t['ttype'], escape_tags($t['term']), escape_tags($t['url']));
}
}
}
}
continue;
}