]> git.mxchange.org Git - friendica-addons.git/commitdiff
Some notices had been removed / expiring of item related tables in twitter (#643)
authorMichael Vogel <icarus@dabo.de>
Sun, 15 Jul 2018 18:40:20 +0000 (20:40 +0200)
committerHypolite Petovan <mrpetovan@eml.cc>
Sun, 15 Jul 2018 18:40:20 +0000 (14:40 -0400)
* Some notices had been removed / expiring of item related tables in twitter

* Some more ...

buffer/buffer.php
leistungsschutzrecht/leistungsschutzrecht.php
pumpio/pumpio.php
statusnet/statusnet.php
tumblr/tumblr.php
twitter/twitter.php

index f41ecf97e07e95ab913ab3f223e0b6fd2af743b5..9d14fd83265420d6b07c573893b354eef13b2c56 100644 (file)
@@ -271,6 +271,7 @@ function buffer_send(App $a, &$b)
        $client_id = Config::get("buffer", "client_id");
        $client_secret = Config::get("buffer", "client_secret");
        $access_token = PConfig::get($b['uid'], "buffer","access_token");
+       $callback_url = "";
 
        if ($access_token) {
                $buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token);
index 6cfe95fea21a6cf1fa96d34e7b607a5c0fe7cf1e..e608409ba38fcff6611387dbc27016076ffb939f 100644 (file)
@@ -142,6 +142,10 @@ function leistungsschutzrecht_is_member_site($url) {
                return false;
        }
 
+       if (count($hostname) <= 2) {
+               return false;
+       }
+
        $site = $hostname[sizeof($hostname) - 2].".".$hostname[sizeof($hostname) - 1];
 
        return (isset($sites[$site]));
index 9e02a74d459f1e503a64b64b36bdb5258116303f..5c28a8f4a78bff21d8b0c5126f3b62e679d11060 100644 (file)
@@ -983,10 +983,24 @@ function pumpio_dolike(&$a, $uid, $self, $post, $own_id, $threadcompletion = tru
 
 function pumpio_get_contact($uid, $contact, $no_insert = false)
 {
-       GContact::update(["url" => $contact->url, "network" => NETWORK_PUMPIO, "generation" => 2,
-                       "photo" => $contact->image->url, "name" => $contact->displayName,  "hide" => true,
-                       "nick" => $contact->preferredUsername, "location" => $contact->location->displayName,
-                       "about" => $contact->summary, "addr" => str_replace("acct:", "", $contact->id)]);
+       $gcontact = ["url" => $contact->url, "network" => NETWORK_PUMPIO, "generation" => 2,
+               "name" => $contact->displayName,  "hide" => true,
+               "nick" => $contact->preferredUsername,
+               "addr" => str_replace("acct:", "", $contact->id)];
+
+       if (!empty($contact->location->displayName)) {
+               $gcontact["location"] = $contact->location->displayName;
+       }
+
+       if (!empty($contact->summary)) {
+               $gcontact["about"] = $contact->summary;
+       }
+
+       if (!empty($contact->image->url)) {
+               $gcontact["photo"] = $contact->image->url;
+       }
+
+       GContact::update($gcontact);
        $cid = Contact::getIdForURL($contact->url, $uid);
 
        if ($no_insert) {
@@ -1047,7 +1061,9 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
                */
        }
 
-       Contact::updateAvatar($contact->image->url, $uid, $contact_id);
+       if (!empty($contact->image->url)) {
+               Contact::updateAvatar($contact->image->url, $uid, $contact_id);
+       }
 
        return $contact_id;
 }
@@ -1109,6 +1125,8 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
                $receiptians = array_merge($receiptians, $post->to);
        }
 
+       $public = false;
+
        foreach ($receiptians AS $receiver) {
                if (is_string($receiver->objectType) && ($receiver->id == "http://activityschema.org/collection/public")) {
                        $public = true;
index 6fc5b8a906d8f5b69b47f92504cbcb51d499dbe2..62c3f41b3a9f77942bcad6affdfa5278dfbce5c1 100644 (file)
@@ -586,11 +586,11 @@ function statusnet_post_hook(App $a, &$b)
                        logger('statusnet_post send, result: ' . print_r($result, true) .
                                "\nmessage: " . $msg, LOGGER_DEBUG . "\nOriginal post: " . print_r($b, true) . "\nPost Data: " . print_r($postdata, true));
 
-                       if ($result->source) {
+                       if (!empty($result->source)) {
                                PConfig::set($b["uid"], "statusnet", "application_name", strip_tags($result->source));
                        }
 
-                       if ($result->error) {
+                       if (!empty($result->error)) {
                                logger('Send to GNU Social failed: "' . $result->error . '"');
                        } elseif ($iscomment) {
                                logger('statusnet_post: Update extid ' . $result->id . " for post id " . $b['id']);
@@ -819,7 +819,7 @@ function statusnet_fetchtimeline(App $a, $uid)
                                continue;
                        }
 
-                       if (is_object($post->retweeted_status)) {
+                       if (!empty($post->retweeted_status)) {
                                continue;
                        }
 
@@ -1554,12 +1554,12 @@ function statusnet_is_retweet(App $a, $uid, $body)
 
        $link = "";
        preg_match("/link='(.*?)'/ism", $attributes, $matches);
-       if ($matches[1] != "") {
+       if (!empty($matches[1])) {
                $link = $matches[1];
        }
 
        preg_match('/link="(.*?)"/ism', $attributes, $matches);
-       if ($matches[1] != "") {
+       if (!empty($matches[1])) {
                $link = $matches[1];
        }
 
index b2dec5b544a3735c35fc74fc785f011b66abb372..9617a3a0783c4f0506454aaebd94b26846779e8f 100644 (file)
@@ -412,7 +412,7 @@ function tumblr_send(&$a,&$b) {
                        $params['caption'] = '<h1>'.$title."</h1>".
                                                "<p>".$params['caption']."</p>";
 
-               if (trim($params['caption']) == "")
+               if (empty($params['caption']))
                        $params['caption'] = BBCode::convert("[quote]" . $siteinfo["description"] . "[/quote]", false, 4);
 
                $consumer_key = Config::get('tumblr','consumer_key');
index d9baf1bdf62792eabb55a823dddaecf836969d75..e843124167bc29665c52728e37049e39cc24b4b1 100644 (file)
@@ -605,11 +605,11 @@ function twitter_post_hook(App $a, &$b)
                $result = $connection->post($url, $post);
                logger('twitter_post send, result: ' . print_r($result, true), LOGGER_DEBUG);
 
-               if ($result->source) {
+               if (!empty($result->source)) {
                        Config::set("twitter", "application_name", strip_tags($result->source));
                }
 
-               if ($result->errors) {
+               if (!empty($result->errors)) {
                        logger('Send to Twitter failed: "' . print_r($result->errors, true) . '"');
 
                        $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($b['uid']));
@@ -725,9 +725,15 @@ function twitter_expire(App $a, $b)
                return;
        }
 
-       $r = dba::select('item', ['id'], ['deleted' => true, 'network' => NETWORK_TWITTER]);
+       $r = dba::select('item', ['id', 'iaid', 'icid'], ['deleted' => true, 'network' => NETWORK_TWITTER]);
        while ($row = dba::fetch($r)) {
                dba::delete('item', ['id' => $row['id']]);
+               if (!empty($row['iaid']) && !dba::exists('item', ['iaid' => $row['iaid']])) {
+                       dba::delete('item-activity', ['id' => $row['iaid']]);
+               }
+               if (!empty($row['icid']) && !dba::exists('item', ['icid' => $row['icid']])) {
+                       dba::delete('item-content', ['id' => $row['icid']]);
+               }
        }
        dba::close($r);
 
@@ -1772,12 +1778,12 @@ function twitter_is_retweet(App $a, $uid, $body)
 
        $link = "";
        preg_match("/link='(.*?)'/ism", $attributes, $matches);
-       if ($matches[1] != "") {
+       if (!empty($matches[1])) {
                $link = $matches[1];
        }
 
        preg_match('/link="(.*?)"/ism', $attributes, $matches);
-       if ($matches[1] != "") {
+       if (!empty($matches[1])) {
                $link = $matches[1];
        }