]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Improved page info detection
[friendica.git] / include / api.php
index 5bec76554f43b12f62bc8118283180f8f1d3969a..9b9850f6facef2afe5a004a8544e8bd67f017735 100644 (file)
@@ -27,7 +27,6 @@ use Friendica\App;
 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;
@@ -50,8 +49,6 @@ use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Images;
 use Friendica\Util\Strings;
 
-require_once __DIR__ . '/../mod/item.php';
-
 $API = [];
 
 /**
@@ -411,9 +408,9 @@ function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $f
 
        $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'];
@@ -423,7 +420,7 @@ function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $f
        $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;
@@ -431,11 +428,7 @@ function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $f
        $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 . ']'
@@ -518,7 +511,7 @@ function prepare_photo_data($type, $scale, $photo_id, $uid)
 
        // 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.');
        }
@@ -1068,7 +1061,9 @@ function api_fr_photo_create_update($type)
        $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