]> git.mxchange.org Git - friendica-addons.git/blobdiff - pumpio/pumpio.php
mathjax addon DE translation updated
[friendica-addons.git] / pumpio / pumpio.php
index b20b0f9496c601ed20fc2463a2ed927528ea1829..8e60f46d7e749f7fa304d0e1d2b5f551593be165 100644 (file)
@@ -18,6 +18,7 @@ use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Group;
 use Friendica\Model\Item;
+use Friendica\Model\Post;
 use Friendica\Model\User;
 use Friendica\Protocol\Activity;
 use Friendica\Protocol\ActivityNamespace;
@@ -388,7 +389,7 @@ function pumpio_hook_fork(App $a, array &$b)
 
         if (DI::pConfig()->get($post['uid'], 'pumpio', 'import')) {
                 // Don't fork if it isn't a reply to a pump.io post
-                if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
+                if (($post['parent'] != $post['id']) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
                         Logger::log('No pump.io parent found for item ' . $post['id']);
                         $b['execute'] = false;
                         return;
@@ -438,7 +439,7 @@ function pumpio_send(App $a, array &$b)
        if ($b['parent'] != $b['id']) {
                // Looking if its a reply to a pumpio post
                $condition = ['id' => $b['parent'], 'network' => Protocol::PUMPIO];
-               $orig_post = Item::selectFirst([], $condition);
+               $orig_post = Post::selectFirst([], $condition);
 
                if (!DBA::isResult($orig_post)) {
                        Logger::log("pumpio_send: no pumpio post ".$b["parent"]);
@@ -609,7 +610,7 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "")
        $hostname = DI::pConfig()->get($uid, 'pumpio', 'host');
        $username = DI::pConfig()->get($uid, "pumpio", "user");
 
-       $orig_post = Item::selectFirst([], ['uri' => $uri, 'uid' => $uid]);
+       $orig_post = Post::selectFirst([], ['uri' => $uri, 'uid' => $uid]);
 
        if (!DBA::isResult($orig_post)) {
                return;
@@ -872,9 +873,9 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id)
 {
        // Searching for the unliked post
        // Two queries for speed issues
-       $orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
+       $orig_post = Post::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
        if (!DBA::isResult($orig_post)) {
-               $orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
+               $orig_post = Post::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
                if (!DBA::isResult($orig_post)) {
                        return;
                }
@@ -917,9 +918,9 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
 
        // Searching for the liked post
        // Two queries for speed issues
-       $orig_post = Item::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
+       $orig_post = Post::selectFirst([], ['uri' => $post->object->id, 'uid' => $uid]);
        if (!DBA::isResult($orig_post)) {
-               $orig_post = Item::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
+               $orig_post = Post::selectFirst([], ['extid' => $post->object->id, 'uid' => $uid]);
                if (!DBA::isResult($orig_post)) {
                        return;
                }
@@ -953,7 +954,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
        }
 
        $condition = ['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']];
-       if (Item::exists($condition)) {
+       if (Post::exists($condition)) {
                Logger::log("pumpio_dolike: found existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']);
                return;
        }
@@ -1064,13 +1065,13 @@ function pumpio_dodelete(App $a, $uid, $self, $post, $own_id)
 {
        // Two queries for speed issues
        $condition = ['uri' => $post->object->id, 'uid' => $uid];
-       if (Item::exists($condition)) {
+       if (Post::exists($condition)) {
                Item::markForDeletion($condition);
                return true;
        }
 
        $condition = ['extid' => $post->object->id, 'uid' => $uid];
-       if (Item::exists($condition)) {
+       if (Post::exists($condition)) {
                Item::markForDeletion($condition);
                return true;
        }
@@ -1093,10 +1094,10 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
 
        if ($post->verb != "update") {
                // Two queries for speed issues
-               if (Item::exists(['uri' => $post->object->id, 'uid' => $uid])) {
+               if (Post::exists(['uri' => $post->object->id, 'uid' => $uid])) {
                        return false;
                }
-               if (Item::exists(['extid' => $post->object->id, 'uid' => $uid])) {
+               if (Post::exists(['extid' => $post->object->id, 'uid' => $uid])) {
                        return false;
                }
        }
@@ -1298,10 +1299,10 @@ function pumpio_fetchinbox(App $a, $uid)
        $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
                intval($uid));
 
-       $lastitems = q("SELECT `uri` FROM `thread`
-                       INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
-                       WHERE `thread`.`network` = '%s' AND `thread`.`uid` = %d AND `item`.`extid` != ''
-                       ORDER BY `thread`.`commented` DESC LIMIT 10",
+       $lastitems = q("SELECT `uri` FROM `post-thread-user`
+                       INNER JOIN `post-view` ON `post-view`.`id` = `post-thread-user`.`id`
+                       WHERE `post-thread-user`.`network` = '%s' AND `post-thread-user`.`uid` = %d AND `post-view`.`extid` != ''
+                       ORDER BY `post-thread-user`.`commented` DESC LIMIT 10",
                                DBA::escape(Protocol::PUMPIO),
                                intval($uid)
                        );
@@ -1503,7 +1504,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
 
        // Fetching the original post
        $condition = ["`uri` = ? AND `uid` = ? AND `extid` != ''", $id, $uid];
-       $original = Item::selectFirst(['extid'], $condition);
+       $original = Post::selectFirst(['extid'], $condition);
        if (!DBA::isResult($original)) {
                return false;
        }
@@ -1560,11 +1561,11 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
                }
 
                // Checking if the comment already exists - Two queries for speed issues
-               if (Item::exists(['uri' => $item->id, 'uid' => $uid])) {
+               if (Post::exists(['uri' => $item->id, 'uid' => $uid])) {
                        continue;
                }
 
-               if (Item::exists(['extid' => $item->id, 'uid' => $uid])) {
+               if (Post::exists(['extid' => $item->id, 'uid' => $uid])) {
                        continue;
                }