core changes to better support media migrations

This commit is contained in:
redmatrix 2016-06-16 20:16:39 -07:00
parent aa77b04860
commit f6d7628254
3 changed files with 33 additions and 8 deletions

View File

@ -423,6 +423,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$observer = array();
$dosync = ((array_key_exists('nosync',$arr) && $arr['nosync']) ? 0 : 1);
if($observer_hash) {
$x = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($observer_hash)
@ -829,6 +831,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
if($arr['description'])
$args['description'] = $arr['description'];
$args['deliver'] = $dosync;
$p = photo_upload($channel,$observer,$args);
if($p['success']) {
$ret['body'] = $p['body'];
@ -865,10 +869,12 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
call_hooks('photo_upload_end',$ret);
}
$sync = attach_export_data($channel,$hash);
if($dosync) {
$sync = attach_export_data($channel,$hash);
if($sync)
build_sync_packet($channel['channel_id'],array('file' => array($sync)));
if($sync)
build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
return $ret;
}

View File

@ -29,6 +29,8 @@ function get_capath() {
* * \b nobody => only return the header
* * \b filep => stream resource to write body to. header and body are not returned when using this option.
* * \b custom => custom request method: e.g. 'PUT', 'DELETE'
* * \b cookiejar => cookie file (write)
* * \B cookiefile => cookie file (read)
*
* @return array an associative array with:
* * \e int \b return_code => HTTP return code or 0 if timeout or failure
@ -60,6 +62,8 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
@curl_setopt($ch, CURLOPT_HEADER, $false);
}
if(x($opts,'headers'))
@curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['headers']);
@ -82,6 +86,11 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
@curl_setopt($ch, CURLOPT_USERPWD, $opts['http_auth']);
}
if(x($opts,'cookiejar'))
@curl_setopt($ch, CURLOPT_COOKIEJAR, $opts['cookiejar']);
if(x($opts,'cookiefile'))
@curl_setopt($ch, CURLOPT_COOKIEFILE, $opts['cookiefile']);
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
((x($opts,'novalidate') && intval($opts['novalidate'])) ? false : true));
@ -228,6 +237,12 @@ logger('headers: ' . print_r($opts['headers'],true) . 'redir: ' . $redirects);
@curl_setopt($ch, CURLOPT_USERPWD, $opts['http_auth']);
}
if(x($opts,'cookiejar'))
@curl_setopt($ch, CURLOPT_COOKIEJAR, $opts['cookiejar']);
if(x($opts,'cookiefile'))
@curl_setopt($ch, CURLOPT_COOKIEFILE, $opts['cookiefile']);
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,
((x($opts,'novalidate') && intval($opts['novalidate'])) ? false : true));

View File

@ -41,6 +41,10 @@ function photo_upload($channel, $observer, $args) {
else
$visible = 0;
$deliver = true;
if(array_key_exists('deliver',$args))
$deliver = intval($args['deliver']);
// Set to default channel permissions. If the parent directory (album) has permissions set,
// use those instead. If we have specific permissions supplied, they take precedence over
// all other settings. 'allow_cid' being passed from an external source takes priority over channel settings.
@ -330,7 +334,7 @@ function photo_upload($channel, $observer, $args) {
if($item['mid'] === $item['parent_mid']) {
$item['body'] = $args['body'];
$item['body'] = $summary;
$item['obj_type'] = ACTIVITY_OBJ_PHOTO;
$item['obj'] = json_encode($object);
@ -355,14 +359,14 @@ function photo_upload($channel, $observer, $args) {
if(($item['edited'] > $r[0]['edited']) || $force) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
item_store_update($item);
item_store_update($item,false,$deliver);
continue;
}
}
else {
$item['aid'] = $channel['channel_account_id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store($item);
$item_result = item_store($item,false,$deliver);
}
}
}
@ -414,10 +418,10 @@ function photo_upload($channel, $observer, $args) {
$result = item_store($arr);
$result = item_store($arr,false,$deliver);
$item_id = $result['item_id'];
if($visible)
if($visible && $deliver)
Zotlabs\Daemon\Master::Summon(array('Notifier', 'wall-new', $item_id));
}