use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Logger;
-use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Images;
use Friendica\Util\Strings;
-require_once __DIR__ . '/../mod/item.php';
-
$API = [];
/**
$arr = [];
$arr['guid'] = System::createUUID();
- $arr['uid'] = intval($uid);
+ $arr['uid'] = $uid;
$arr['uri'] = $uri;
- $arr['type'] = 'photo';
+ $arr['post-type'] = Item::PT_IMAGE;
$arr['wall'] = 1;
$arr['resource-id'] = $hash;
$arr['contact-id'] = $owner_record['id'];
$arr['author-name'] = $owner_record['name'];
$arr['author-link'] = $owner_record['url'];
$arr['author-avatar'] = $owner_record['thumb'];
- $arr['title'] = "";
+ $arr['title'] = '';
$arr['allow_cid'] = $allow_cid;
$arr['allow_gid'] = $allow_gid;
$arr['deny_cid'] = $deny_cid;
$arr['visible'] = $visibility;
$arr['origin'] = 1;
- $typetoext = [
- 'image/jpeg' => 'jpg',
- 'image/png' => 'png',
- 'image/gif' => 'gif'
- ];
+ $typetoext = Images::supportedTypes();
// adds link to the thumbnail scale photo
$arr['body'] = '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nick'] . '/image/' . $hash . ']'
// retrieve item element for getting activities (like, dislike etc.) related to photo
$condition = ['uid' => $uid, 'resource-id' => $photo_id];
- $item = Post::selectFirst(['id', 'uid', 'uri', 'parent', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid'], $condition);
+ $item = Post::selectFirst(['id', 'uid', 'uri', 'uri-id', 'parent', 'allow_cid', 'deny_cid', 'allow_gid', 'deny_gid'], $condition);
if (!DBA::isResult($item)) {
throw new NotFoundException('Photo-related item not found.');
}
$deny_cid = $_REQUEST['deny_cid' ] ?? null;
$allow_gid = $_REQUEST['allow_gid'] ?? null;
$deny_gid = $_REQUEST['deny_gid' ] ?? null;
- $visibility = !$allow_cid && !$deny_cid && !$allow_gid && !$deny_gid;
+ // Pictures uploaded via API never get posted as a visible status
+ // See https://github.com/friendica/friendica/issues/10990
+ $visibility = false;
// do several checks on input parameters
// we do not allow calls without album string