]> git.mxchange.org Git - friendica.git/blobdiff - mod/subthread.php
Curl Response Refactoring
[friendica.git] / mod / subthread.php
index a624cd9a60be2715721da9b89c92ea71e72195bd..105cf60feb7f1e3d3a3ba458c3b37625a149f29c 100644 (file)
@@ -6,7 +6,7 @@ use Friendica\App;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\System;
-use Friendica\Database\DBM;
+use Friendica\Database\DBA;
 use Friendica\Model\Item;
 
 require_once 'include/security.php';
@@ -25,7 +25,7 @@ function subthread_content(App $a) {
        $condition = ["`parent` = ? OR `parent-uri` = ? AND `parent` = `id`", $item_id, $item_id];
        $item = Item::selectFirst([], $condition);
 
-       if (empty($item_id) || !DBM::is_result($item)) {
+       if (empty($item_id) || !DBA::isResult($item)) {
                logger('subthread: no item ' . $item_id);
                return;
        }
@@ -40,15 +40,12 @@ function subthread_content(App $a) {
 
        if (!$item['wall']) {
                // The top level post may have been written by somebody on another system
-               $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
-                       intval($item['contact-id']),
-                       intval($item['uid'])
-               );
-               if (!DBM::is_result($r)) {
+               $contact = DBA::selectFirst('contact', [], ['id' => $item['contact-id'], 'uid' => $item['uid']]);
+               if (!DBA::isResult($contact)) {
                        return;
                }
-               if (!$r[0]['self']) {
-                       $remote_owner = $r[0];
+               if (!$contact['self']) {
+                       $remote_owner = $contact;
                }
        }
 
@@ -60,7 +57,7 @@ function subthread_content(App $a) {
                intval($owner_uid)
        );
 
-       if (DBM::is_result($r)) {
+       if (DBA::isResult($r)) {
                $owner = $r[0];
        }
 
@@ -79,18 +76,11 @@ function subthread_content(App $a) {
        if (local_user() && (local_user() == $owner_uid)) {
                $contact = $owner;
        } else {
-               $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
-                       intval($_SESSION['visitor_id']),
-                       intval($owner_uid)
-               );
-
-               if (DBM::is_result($r)) {
-                       $contact = $r[0];
+               $contact = DBA::selectFirst('contact', [], ['id' => $_SESSION['visitor_id'], 'uid' => $owner_uid]);
+               if (!DBA::isResult($contact)) {
+                       return;
                }
        }
-       if (!$contact) {
-               return;
-       }
 
        $uri = Item::newURI($owner_uid);
 
@@ -118,11 +108,10 @@ EOT;
 
        $arr = [];
 
-       $arr['guid'] = System::createGUID(32);
+       $arr['guid'] = System::createUUID();
        $arr['uri'] = $uri;
        $arr['uid'] = $owner_uid;
        $arr['contact-id'] = $contact['id'];
-       $arr['type'] = 'activity';
        $arr['wall'] = $item['wall'];
        $arr['origin'] = 1;
        $arr['gravity'] = GRAVITY_ACTIVITY;