mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
container fixes for photo and file upload
This commit is contained in:
@@ -1941,6 +1941,12 @@ function attach_store_item($channel, $observer, $file) {
|
||||
|
||||
$mid = z_root() . '/item/' . $uuid;
|
||||
|
||||
$target = [
|
||||
'id' => z_root() . '/conversation/' . $uuid,
|
||||
'type' => 'Collection',
|
||||
'attributedTo' => channel_url($channel),
|
||||
];
|
||||
|
||||
$arr = []; // Initialize the array of parameters for the post
|
||||
$arr['aid'] = $channel['channel_account_id'];
|
||||
$arr['uuid'] = $uuid;
|
||||
@@ -1961,6 +1967,8 @@ function attach_store_item($channel, $observer, $file) {
|
||||
$arr['item_thread_top'] = 1;
|
||||
$arr['item_private'] = (($file['allow_cid'] || $file['allow_gid'] || $file['deny_cid'] || $file['deny_gid']) ? 1 : 0);
|
||||
$arr['verb'] = 'Create';
|
||||
$arr['target'] = $target;
|
||||
$arr['target_type'] = 'Collection';
|
||||
$arr['obj_type'] = $type;
|
||||
$arr['title'] = $file['filename'];
|
||||
|
||||
@@ -1978,7 +1986,7 @@ function attach_store_item($channel, $observer, $file) {
|
||||
}
|
||||
|
||||
$body_str = sprintf((($type === 'Image') ? t('%s shared an %s with you') : t('%s shared a %s with you')), '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]', '[zrl=' . $path . ']' . (($type === 'Image') ? t('image') : t('file')) . '[/zrl]');
|
||||
$arr['body'] .= $body_str;
|
||||
$arr['body'] .= "\r\n" . $body_str;
|
||||
|
||||
$meta = [
|
||||
'name' => $file['filename'],
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use Zotlabs\Access\PermissionLimits;
|
||||
use Zotlabs\Lib\Activity;
|
||||
use Zotlabs\Lib\Config;
|
||||
use Zotlabs\Daemon\Master;
|
||||
|
||||
require_once('include/permissions.php');
|
||||
require_once('include/items.php');
|
||||
@@ -438,13 +439,13 @@ function photo_upload($channel, $observer, $args) {
|
||||
else {
|
||||
$object['to'] = Activity::map_acl(array_merge($ac, ['item_private' => 1 - intval($public)]));
|
||||
}
|
||||
|
||||
/*
|
||||
$target = [
|
||||
'type' => 'orderedCollection',
|
||||
'name' => ((strlen($album)) ? $album : '/'),
|
||||
'id' => z_root() . '/album/' . $channel['channel_address'] . ((isset($args['directory']['hash'])) ? '/' . $args['directory']['hash'] : EMPTY_STR)
|
||||
];
|
||||
|
||||
*/
|
||||
// Create item container
|
||||
if (isset($args['item'])) {
|
||||
foreach ($args['item'] as $i) {
|
||||
@@ -453,6 +454,11 @@ function photo_upload($channel, $observer, $args) {
|
||||
$force = false;
|
||||
|
||||
if ($item['mid'] === $item['parent_mid']) {
|
||||
$target = [
|
||||
'id' => str_replace('/item/', '/conversation/', $item['mid']),
|
||||
'type' => 'Collection',
|
||||
'attributedTo' => channel_url($channel),
|
||||
];
|
||||
|
||||
$item['body'] = $summary;
|
||||
$item['mimetype'] = 'text/bbcode';
|
||||
@@ -462,7 +468,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
$object['diaspora:guid'] = $item['uuid'];
|
||||
$item['obj'] = json_encode($object);
|
||||
|
||||
$item['tgt_type'] = 'orderedCollection';
|
||||
$item['tgt_type'] = 'Collection';
|
||||
$item['target'] = json_encode($target);
|
||||
if ($post_tags) {
|
||||
$arr['term'] = $post_tags;
|
||||
@@ -477,15 +483,23 @@ 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, false, $deliver);
|
||||
$result = item_store_update($item, deliver: $deliver);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$item['aid'] = $channel['channel_account_id'];
|
||||
$item['uid'] = $channel['channel_id'];
|
||||
item_store($item, false, $deliver);
|
||||
$result = item_store($item, deliver: $deliver);
|
||||
}
|
||||
|
||||
if ($result['success'] && $visible && $deliver) {
|
||||
Master::Summon(['Notifier', 'wall-new', $result['item_id']]);
|
||||
if (!empty($result['approval_id'])) {
|
||||
Master::Summon(['Notifier', 'wall-new', $result['approval_id']]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -496,6 +510,12 @@ function photo_upload($channel, $observer, $args) {
|
||||
$object['id'] = $mid;
|
||||
$object['diaspora:guid'] = $uuid;
|
||||
|
||||
$target = [
|
||||
'id' => z_root() . '/conversation/' . $uuid,
|
||||
'type' => 'Collection',
|
||||
'attributedTo' => channel_url($channel),
|
||||
];
|
||||
|
||||
$arr = [
|
||||
'aid' => $account_id,
|
||||
'uid' => $channel_id,
|
||||
@@ -514,9 +534,9 @@ function photo_upload($channel, $observer, $args) {
|
||||
'deny_gid' => $ac['deny_gid'],
|
||||
'verb' => 'Create',
|
||||
'obj_type' => 'Image',
|
||||
'obj' => json_encode($object),
|
||||
'tgt_type' => 'orderedCollection',
|
||||
'target' => json_encode($target),
|
||||
'obj' => $object,
|
||||
'tgt_type' => 'Collection',
|
||||
'target' => $target,
|
||||
'item_wall' => $visible,
|
||||
'item_origin' => 1,
|
||||
'item_thread_top' => 1,
|
||||
@@ -546,9 +566,9 @@ function photo_upload($channel, $observer, $args) {
|
||||
$arr['item_private'] = 1;
|
||||
}
|
||||
|
||||
$result = item_store($arr, false, $deliver);
|
||||
$result = item_store($arr, deliver: $deliver);
|
||||
|
||||
if ($visible && $deliver) {
|
||||
if ($result['success'] && $visible && $deliver) {
|
||||
Master::Summon(['Notifier', 'wall-new', $result['item_id']]);
|
||||
if (!empty($result['approval_id'])) {
|
||||
Master::Summon(['Notifier', 'wall-new', $result['approval_id']]);
|
||||
|
||||
Reference in New Issue
Block a user