aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2024-11-10 11:40:56 +0100
committerMario Vavti <mario@mariovavti.com>2024-11-10 11:40:56 +0100
commite339fbcc464ee2cc2b6caa8e456ca59606828906 (patch)
tree4d6e5af8d8ea805b3fa6cb1b37db53b3ea1e8c67 /include
parentc9d4b068c254bd58e6da5d6349ab8b7ae96b6054 (diff)
downloadvolse-hubzilla-e339fbcc464ee2cc2b6caa8e456ca59606828906.tar.gz
volse-hubzilla-e339fbcc464ee2cc2b6caa8e456ca59606828906.tar.bz2
volse-hubzilla-e339fbcc464ee2cc2b6caa8e456ca59606828906.zip
container fixes for photo and file upload
Diffstat (limited to 'include')
-rw-r--r--include/attach.php10
-rw-r--r--include/photos.php40
2 files changed, 39 insertions, 11 deletions
diff --git a/include/attach.php b/include/attach.php
index c8fde0cb7..15594ced8 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -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'],
diff --git a/include/photos.php b/include/photos.php
index 511024107..fe1a500d6 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -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']]);