mirror of
https://github.com/friendica/friendica
synced 2025-04-29 15:04:22 +02:00
API: photos are now directly stored as attached data and not in the body anymore
This commit is contained in:
parent
60f0af3daa
commit
4b12c54345
6 changed files with 89 additions and 54 deletions
|
@ -21,7 +21,6 @@
|
|||
|
||||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Content\PageInfo;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Hook;
|
||||
|
@ -960,7 +959,13 @@ class Item
|
|||
self::setOwnerforResharedItem($item);
|
||||
}
|
||||
|
||||
Post\Media::insertFromAttachmentData($item['uri-id'], $item['body']);
|
||||
if (isset($item['attachments'])) {
|
||||
foreach ($item['attachments'] as $attachment) {
|
||||
$attachment['uri-id'] = $item['uri-id'];
|
||||
Post\Media::insert($attachment);
|
||||
}
|
||||
unset($item['attachments']);
|
||||
}
|
||||
|
||||
// Remove all media attachments from the body and store them in the post-media table
|
||||
$item['raw-body'] = Post\Media::insertFromBody($item['uri-id'], $item['raw-body']);
|
||||
|
|
|
@ -726,18 +726,35 @@ class Photo
|
|||
* Then set the permissions to public.
|
||||
*/
|
||||
|
||||
$fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
|
||||
'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny,
|
||||
'accessible' => DI::pConfig()->get($uid, 'system', 'accessible-photos', false)];
|
||||
|
||||
$condition = ['resource-id' => $image_rid, 'uid' => $uid];
|
||||
Logger::info('Set permissions', ['condition' => $condition, 'permissions' => $fields]);
|
||||
Photo::update($fields, $condition);
|
||||
self::setPermissionForRessource($image_rid, $uid, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add permissions to photo ressource
|
||||
* @todo mix with previous photo permissions
|
||||
*
|
||||
* @param string $image_rid
|
||||
* @param integer $uid
|
||||
* @param string $str_contact_allow
|
||||
* @param string $str_group_allow
|
||||
* @param string $str_contact_deny
|
||||
* @param string $str_group_deny
|
||||
* @return void
|
||||
*/
|
||||
public static function setPermissionForRessource(string $image_rid, int $uid, string $str_contact_allow, string $str_group_allow, string $str_contact_deny, string $str_group_deny)
|
||||
{
|
||||
$fields = ['allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
|
||||
'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny,
|
||||
'accessible' => DI::pConfig()->get($uid, 'system', 'accessible-photos', false)];
|
||||
|
||||
$condition = ['resource-id' => $image_rid, 'uid' => $uid];
|
||||
Logger::info('Set permissions', ['condition' => $condition, 'permissions' => $fields]);
|
||||
Photo::update($fields, $condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips known picture extensions from picture links
|
||||
*
|
||||
|
|
|
@ -112,6 +112,10 @@ class Delayed
|
|||
*/
|
||||
public static function publish(array $item, int $notify = 0, array $taglist = [], array $attachments = [], bool $unprepared = false, string $uri = '')
|
||||
{
|
||||
if (!empty($attachments)) {
|
||||
$item['attachments'] = $attachments;
|
||||
}
|
||||
|
||||
if ($unprepared) {
|
||||
$_SESSION['authenticated'] = true;
|
||||
$_SESSION['uid'] = $item['uid'];
|
||||
|
@ -157,11 +161,6 @@ class Delayed
|
|||
foreach ($taglist as $tag) {
|
||||
Tag::store($feeditem['uri-id'], Tag::HASHTAG, $tag);
|
||||
}
|
||||
|
||||
foreach ($attachments as $attachment) {
|
||||
$attachment['uri-id'] = $feeditem['uri-id'];
|
||||
Media::insert($attachment);
|
||||
}
|
||||
}
|
||||
|
||||
return $id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue