From e74ccf35c9ce5a894fa5764c2839187a0eedd851 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 15 Jul 2018 20:40:20 +0200 Subject: [PATCH] Some notices had been removed / expiring of item related tables in twitter (#643) * Some notices had been removed / expiring of item related tables in twitter * Some more ... --- buffer/buffer.php | 1 + leistungsschutzrecht/leistungsschutzrecht.php | 4 +++ pumpio/pumpio.php | 28 +++++++++++++++---- statusnet/statusnet.php | 10 +++---- tumblr/tumblr.php | 2 +- twitter/twitter.php | 16 +++++++---- 6 files changed, 45 insertions(+), 16 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index f41ecf97..9d14fd83 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -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); diff --git a/leistungsschutzrecht/leistungsschutzrecht.php b/leistungsschutzrecht/leistungsschutzrecht.php index 6cfe95fe..e608409b 100644 --- a/leistungsschutzrecht/leistungsschutzrecht.php +++ b/leistungsschutzrecht/leistungsschutzrecht.php @@ -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])); diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index 9e02a74d..5c28a8f4 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -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; diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 6fc5b8a9..62c3f41b 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -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]; } diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php index b2dec5b5..9617a3a0 100644 --- a/tumblr/tumblr.php +++ b/tumblr/tumblr.php @@ -412,7 +412,7 @@ function tumblr_send(&$a,&$b) { $params['caption'] = '

'.$title."

". "

".$params['caption']."

"; - 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'); diff --git a/twitter/twitter.php b/twitter/twitter.php index d9baf1bd..e8431241 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -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]; }