]> git.mxchange.org Git - friendica-addons.git/commitdiff
advancedcontentfilter: Abstraction for the item call
authorMichael <heluecht@pirati.ca>
Fri, 15 Jun 2018 22:31:16 +0000 (22:31 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 15 Jun 2018 22:31:16 +0000 (22:31 +0000)
advancedcontentfilter/advancedcontentfilter.php

index 47ace1c2bd98c9b56f73439676b27941b34e3a78..dd04e76930283923307417df3cf044636787605f 100644 (file)
@@ -42,6 +42,7 @@ use Friendica\Network\HTTPException;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use Symfony\Component\ExpressionLanguage;
+use Friendica\Model\Item;
 
 require_once 'boot.php';
 require_once 'include/conversation.php';
@@ -402,7 +403,9 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques
                throw new HTTPException\BadRequestException(L10n::t('Missing argument: guid.'));
        }
 
-       $item = dba::fetch_first(item_query() . " AND `item`.`guid` = ? AND (`item`.`uid` = ? OR `item`.`uid` = 0) ORDER BY `item`.`uid` DESC", $args['guid'], local_user());
+       $condition = ["`guid` = ? AND (`uid` = ? OR `uid` = 0)", $args['guid'], local_user()];
+       $params = ['order' => ['uid' => true]];
+       $item = Item::selectFirst(local_user(), [], $condition, $params);
 
        if (!\Friendica\Database\DBM::is_result($item)) {
                throw new HTTPException\NotFoundException(L10n::t('Unknown post with guid: %s', $args['guid']));
@@ -420,4 +423,4 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques
        }
 
        return json_encode(['variables' => str_replace('\\\'', '\'', var_export($return, true))]);
-}
\ No newline at end of file
+}