]> git.mxchange.org Git - friendica-addons.git/commitdiff
Rewrite: (#680)
authorRoland Häder <Quix0r@users.noreply.github.com>
Sat, 11 Aug 2018 20:40:48 +0000 (22:40 +0200)
committerHypolite Petovan <mrpetovan@eml.cc>
Sat, 11 Aug 2018 20:40:48 +0000 (22:40 +0200)
- replace usage of deprecated NETWORK_* with Protocol::*

buffer/buffer.php
diaspora/diaspora.php
fromgplus/fromgplus.php
ifttt/ifttt.php
jappixmini/jappixmini.php
pumpio/pumpio.php
statusnet/statusnet.php
twitter/twitter.php

index 3ccfcf9160d19136a1dbf64d5d58ab4128b08514..4fc45c857f1fa9816a7863ec58359126b4168db4 100644 (file)
@@ -13,6 +13,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\ItemContent;
 use Friendica\Util\Proxy as ProxyUtils;
@@ -307,7 +308,7 @@ function buffer_send(App $a, array &$b)
 
                                switch ($profile->service) {
                                        case 'facebook':
-                                               $send = ($b["extid"] != NETWORK_FACEBOOK);
+                                               $send = ($b["extid"] != Protocol::FACEBOOK);
                                                $limit = 0;
                                                $markup = false;
                                                $includedlinks = false;
@@ -315,7 +316,7 @@ function buffer_send(App $a, array &$b)
                                                break;
 
                                        case 'google':
-                                               $send = ($b["extid"] != NETWORK_GPLUS);
+                                               $send = ($b["extid"] != Protocol::GPLUS);
                                                $limit = 0;
                                                $markup = true;
                                                $includedlinks = false;
@@ -323,7 +324,7 @@ function buffer_send(App $a, array &$b)
                                                break;
 
                                        case 'twitter':
-                                               $send = ($b["extid"] != NETWORK_TWITTER);
+                                               $send = ($b["extid"] != Protocol::TWITTER);
                                                $limit = 280;
                                                $markup = false;
                                                $includedlinks = true;
@@ -331,7 +332,7 @@ function buffer_send(App $a, array &$b)
                                                break;
 
                                        case 'linkedin':
-                                               $send = ($b["extid"] != NETWORK_LINKEDIN);
+                                               $send = ($b["extid"] != Protocol::LINKEDIN);
                                                $limit = 700;
                                                $markup = false;
                                                $includedlinks = true;
index 338e0fa51aa9aaf09748bcf852b3a7d8e41d0e2c..a547255821144c0e5adf133b338ede76a79e700b 100644 (file)
@@ -14,6 +14,7 @@ use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\Queue;
 
@@ -59,7 +60,7 @@ function diaspora_queue_hook(App $a, &$b) {
        $hostname = $a->get_hostname();
 
        $qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
-               DBA::escape(NETWORK_DIASPORA2)
+               DBA::escape(Protocol::DIASPORA2)
        );
 
        if (!DBA::isResult($qi)) {
@@ -67,7 +68,7 @@ function diaspora_queue_hook(App $a, &$b) {
        }
 
        foreach ($qi as $x) {
-               if ($x['network'] !== NETWORK_DIASPORA2) {
+               if ($x['network'] !== Protocol::DIASPORA2) {
                        continue;
                }
 
@@ -383,7 +384,7 @@ function diaspora_send(App $a, array &$b)
 
                        $s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $body]);
 
-                       Queue::add($a->contact, NETWORK_DIASPORA2, $s);
+                       Queue::add($a->contact, Protocol::DIASPORA2, $s);
                        notice(L10n::t('Diaspora post failed. Queued for retry.').EOL);
                }
        }
index ac433526a020b033b68188c5471225f6b4058a4d..990a5855bf3b6c8530b005cbbdbf697306d1d84e 100644 (file)
@@ -13,6 +13,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Object\Image;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
@@ -173,10 +174,10 @@ function fromgplus_post($a, $uid, $source, $body, $location, $coord, $id) {
 
        $_REQUEST['profile_uid'] = $uid;
        $_REQUEST['source'] = $source;
-       $_REQUEST['extid'] = NETWORK_GPLUS;
+       $_REQUEST['extid'] = Protocol::GPLUS;
 
        if (isset($id)) {
-               $_REQUEST['message_id'] = Item::newURI($uid, NETWORK_GPLUS.':'.$id);
+               $_REQUEST['message_id'] = Item::newURI($uid, Protocol::GPLUS.':'.$id);
        }
 
        // $_REQUEST['verb']
index 14add12a28a4adadf18ec7a589bd5120ab018b28..d12381fd004fab212ad539ba98d96950f76916b1 100644 (file)
@@ -14,6 +14,7 @@ use Friendica\App;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\Item;
 
@@ -181,8 +182,8 @@ function ifttt_message($uid, $item)
 
        if (strstr($item['url'], 'facebook.com')) {
                $hash = hash('ripemd128', item['url']);
-               $_REQUEST['extid'] = NETWORK_FACEBOOK;
-               $_REQUEST['message_id'] = Item::newURI($uid, NETWORK_FACEBOOK . ':' . $hash);
+               $_REQUEST['extid'] = Protocol::FACEBOOK;
+               $_REQUEST['message_id'] = Item::newURI($uid, Protocol::FACEBOOK . ':' . $hash);
        }
 
        if ($item['type'] == 'link') {
index 7b4a9cb6477ee300a66507dc3c7d468ea584bc87..ad25b6f94fa4ac3525f44ec7a470df7fb450e078 100644 (file)
@@ -67,6 +67,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\User;
 use Friendica\Util\Network;
@@ -594,7 +595,7 @@ function jappixmini_cron(App $a, $d)
 
                // for each user, go through list of contacts
                $contacts = q("SELECT * FROM `contact` WHERE `uid`=%d AND ((LENGTH(`dfrn-id`) AND LENGTH(`pubkey`)) OR (LENGTH(`issued-id`) AND LENGTH(`prvkey`))) AND `network` = '%s'",
-                       intval($uid), DBA::escape(NETWORK_DFRN));
+                       intval($uid), DBA::escape(Protocol::DFRN));
                foreach ($contacts as $contact_row) {
                        $request = $contact_row["request"];
                        if (!$request) {
index 3bc03efa06d4f50d6604719e6059881bcfe74e87..d68c107156e7af1f862545161ef3ec43a1ca2af6 100644 (file)
@@ -13,6 +13,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -417,7 +418,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' => NETWORK_PUMPIO];
+               $condition = ['id' => $b['parent'], 'network' => Protocol::PUMPIO];
                $orig_post = Item::selectFirst([], $condition);
 
                if (!DBA::isResult($orig_post)) {
@@ -578,7 +579,7 @@ function pumpio_send(App $a, array &$b)
 
                        $s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $params]);
 
-                       Queue::add($a->contact, NETWORK_PUMPIO, $s);
+                       Queue::add($a->contact, Protocol::PUMPIO, $s);
                        notice(L10n::t('Pump.io post failed. Queued for retry.').EOL);
                }
        }
@@ -655,7 +656,7 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "")
 
                $s = serialize(['url' => $url, 'item' => $orig_post["id"], 'post' => $params]);
 
-               Queue::add($a->contact, NETWORK_PUMPIO, $s);
+               Queue::add($a->contact, Protocol::PUMPIO, $s);
                notice(L10n::t('Pump.io like failed. Queued for retry.').EOL);
        }
 }
@@ -831,7 +832,7 @@ function pumpio_fetchtimeline(App $a, $uid)
                                $_REQUEST["source"] = "pump.io";
 
                                if (isset($post->object->id)) {
-                                       $_REQUEST['message_id'] = NETWORK_PUMPIO.":".$post->object->id;
+                                       $_REQUEST['message_id'] = Protocol::PUMPIO.":".$post->object->id;
                                }
 
                                if ($post->object->displayName != "") {
@@ -964,7 +965,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
        $likedata['gravity'] = GRAVITY_ACTIVITY;
        $likedata['uid'] = $uid;
        $likedata['wall'] = 0;
-       $likedata['network'] = NETWORK_PUMPIO;
+       $likedata['network'] = Protocol::PUMPIO;
        $likedata['uri'] = Item::newURI($uid);
        $likedata['parent-uri'] = $orig_post["uri"];
        $likedata['contact-id'] = $contactid;
@@ -993,7 +994,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
 
 function pumpio_get_contact($uid, $contact, $no_insert = false)
 {
-       $gcontact = ["url" => $contact->url, "network" => NETWORK_PUMPIO, "generation" => 2,
+       $gcontact = ["url" => $contact->url, "network" => Protocol::PUMPIO, "generation" => 2,
                "name" => $contact->displayName,  "hide" => true,
                "nick" => $contact->preferredUsername,
                "addr" => str_replace("acct:", "", $contact->id)];
@@ -1037,7 +1038,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false)
                        DBA::escape($contact->displayName),
                        DBA::escape($contact->preferredUsername),
                        DBA::escape($contact->image->url),
-                       DBA::escape(NETWORK_PUMPIO),
+                       DBA::escape(Protocol::PUMPIO),
                        intval(Contact::FRIEND),
                        intval(1),
                        DBA::escape($contact->location->displayName),
@@ -1144,7 +1145,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
        }
 
        $postarray = [];
-       $postarray['network'] = NETWORK_PUMPIO;
+       $postarray['network'] = Protocol::PUMPIO;
        $postarray['uid'] = $uid;
        $postarray['wall'] = 0;
        $postarray['uri'] = $post->object->id;
@@ -1310,7 +1311,7 @@ function pumpio_fetchinbox(App $a, $uid)
                        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",
-                               DBA::escape(NETWORK_PUMPIO),
+                               DBA::escape(Protocol::PUMPIO),
                                intval($uid)
                        );
 
@@ -1411,7 +1412,7 @@ function pumpio_getallusers(App &$a, $uid)
 function pumpio_queue_hook(App $a, array &$b)
 {
        $qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
-               DBA::escape(NETWORK_PUMPIO)
+               DBA::escape(Protocol::PUMPIO)
        );
 
        if (!DBA::isResult($qi)) {
@@ -1419,7 +1420,7 @@ function pumpio_queue_hook(App $a, array &$b)
        }
 
        foreach ($qi as $x) {
-               if ($x['network'] !== NETWORK_PUMPIO) {
+               if ($x['network'] !== Protocol::PUMPIO) {
                        continue;
                }
 
@@ -1518,7 +1519,7 @@ function pumpio_getreceiver(App $a, array $b)
                        $r = q("SELECT `name`, `nick`, `url` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `network` = '%s' AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
                                intval($cid),
                                intval($b["uid"]),
-                               DBA::escape(NETWORK_PUMPIO)
+                               DBA::escape(Protocol::PUMPIO)
                                );
 
                        if (DBA::isResult($r)) {
@@ -1536,7 +1537,7 @@ function pumpio_getreceiver(App $a, array $b)
                                "FROM `group_member`, `contact` WHERE `group_member`.`gid` = %d ".
                                "AND `contact`.`id` = `group_member`.`contact-id` AND `contact`.`network` = '%s'",
                                        intval($gid),
-                                       DBA::escape(NETWORK_PUMPIO)
+                                       DBA::escape(Protocol::PUMPIO)
                                );
 
                        foreach ($r AS $row)
@@ -1561,7 +1562,7 @@ function pumpio_getreceiver(App $a, array $b)
                        $r = q("SELECT `name`, `nick`, `url` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `network` = '%s' AND `blocked` = 0 AND `readonly` = 0 LIMIT 1",
                                intval($cid),
                                intval($b["uid"]),
-                               DBA::escape(NETWORK_PUMPIO)
+                               DBA::escape(Protocol::PUMPIO)
                                );
 
                        if (DBA::isResult($r)) {
index e6655f8c5a53aa263de69499f4cc49ca28c2d43d..a1c9a24a6e6b6cb637fa684b72d608a1f9cf1b8b 100644 (file)
@@ -47,6 +47,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\GContact;
@@ -520,7 +521,7 @@ function statusnet_post_hook(App $a, &$b)
        }
 
        // if posts comes from GNU Social don't send it back
-       if ($b['extid'] == NETWORK_STATUSNET) {
+       if ($b['extid'] == Protocol::STATUSNET) {
                return;
        }
 
@@ -675,7 +676,7 @@ function statusnet_addon_admin(App $a, &$o)
 
 function statusnet_prepare_body(App $a, &$b)
 {
-       if ($b["item"]["network"] != NETWORK_STATUSNET) {
+       if ($b["item"]["network"] != Protocol::STATUSNET) {
                return;
        }
 
@@ -841,10 +842,10 @@ function statusnet_fetchtimeline(App $a, $uid)
                                $_REQUEST["profile_uid"] = $uid;
                                //$_REQUEST["source"] = "StatusNet";
                                $_REQUEST["source"] = $post->source;
-                               $_REQUEST["extid"] = NETWORK_STATUSNET;
+                               $_REQUEST["extid"] = Protocol::STATUSNET;
 
                                if (isset($post->id)) {
-                                       $_REQUEST['message_id'] = Item::newURI($uid, NETWORK_STATUSNET . ":" . $post->id);
+                                       $_REQUEST['message_id'] = Item::newURI($uid, Protocol::STATUSNET . ":" . $post->id);
                                }
 
                                //$_REQUEST["date"] = $post->created_at;
@@ -899,12 +900,12 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
        }
 
        GContact::update(["url" => $contact->statusnet_profile_url,
-               "network" => NETWORK_STATUSNET, "photo" => $contact->profile_image_url,
+               "network" => Protocol::STATUSNET, "photo" => $contact->profile_image_url,
                "name" => $contact->name, "nick" => $contact->screen_name,
                "location" => $contact->location, "about" => $contact->description,
                "addr" => statusnet_address($contact), "generation" => 3]);
 
-       $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), DBA::escape(normalise_link($contact->statusnet_profile_url)), DBA::escape(NETWORK_STATUSNET));
+       $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), DBA::escape(normalise_link($contact->statusnet_profile_url)), DBA::escape(Protocol::STATUSNET));
 
        if (!DBA::isResult($r) && !$create_user) {
                return 0;
@@ -932,7 +933,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
                        DBA::escape($contact->name),
                        DBA::escape($contact->screen_name),
                        DBA::escape($contact->profile_image_url),
-                       DBA::escape(NETWORK_STATUSNET),
+                       DBA::escape(Protocol::STATUSNET),
                        intval(Contact::FRIEND),
                        intval(1),
                        DBA::escape($contact->location),
@@ -943,7 +944,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user)
                $r = q("SELECT * FROM `contact` WHERE `alias` = '%s' AND `uid` = %d AND `network` = '%s' LIMIT 1",
                        DBA::escape($contact->statusnet_profile_url),
                        intval($uid),
-                       DBA::escape(NETWORK_STATUSNET));
+                       DBA::escape(Protocol::STATUSNET));
 
                if (!DBA::isResult($r)) {
                        return false;
@@ -1065,7 +1066,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex
        $hostname = preg_replace("=https?://([\w\.]*)/.*=ism", "$1", $api);
 
        $postarray = [];
-       $postarray['network'] = NETWORK_STATUSNET;
+       $postarray['network'] = Protocol::STATUSNET;
        $postarray['uid'] = $uid;
        $postarray['wall'] = 0;
 
index d95a1a7af3667f2267c1b5e1a95196fa21fb5bdb..92cc6a370c827291042b02c8bfb88ea631159266 100644 (file)
@@ -70,6 +70,7 @@ use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
@@ -521,7 +522,7 @@ function twitter_post_hook(App $a, array &$b)
        }
 
        // if post comes from twitter don't send it back
-       if ($b['extid'] == NETWORK_TWITTER) {
+       if ($b['extid'] == Protocol::TWITTER) {
                return;
        }
 
@@ -628,7 +629,7 @@ function twitter_post_hook(App $a, array &$b)
 
                        $s = serialize(['url' => $url, 'item' => $b['id'], 'post' => $post]);
 
-                       Queue::add($a->contact, NETWORK_TWITTER, $s);
+                       Queue::add($a->contact, Protocol::TWITTER, $s);
                        notice(L10n::t('Twitter post failed. Queued for retry.') . EOL);
                } elseif ($iscomment) {
                        logger('twitter_post: Update extid ' . $result->id_str . " for post id " . $b['id']);
@@ -734,7 +735,7 @@ function twitter_expire(App $a)
                return;
        }
 
-       $r = DBA::select('item', ['id', 'iaid', 'icid'], ['deleted' => true, 'network' => NETWORK_TWITTER]);
+       $r = DBA::select('item', ['id', 'iaid', 'icid'], ['deleted' => true, 'network' => Protocol::TWITTER]);
        while ($row = DBA::fetch($r)) {
                DBA::delete('item', ['id' => $row['id']]);
                if (!empty($row['iaid']) && !DBA::exists('item', ['iaid' => $row['iaid']])) {
@@ -754,7 +755,7 @@ function twitter_expire(App $a)
        if (DBA::isResult($r)) {
                foreach ($r as $rr) {
                        logger('twitter_expire: user ' . $rr['uid']);
-                       Item::expire($rr['uid'], $days, NETWORK_TWITTER, true);
+                       Item::expire($rr['uid'], $days, Protocol::TWITTER, true);
                }
        }
 
@@ -763,7 +764,7 @@ function twitter_expire(App $a)
 
 function twitter_prepare_body(App $a, array &$b)
 {
-       if ($b["item"]["network"] != NETWORK_TWITTER) {
+       if ($b["item"]["network"] != Protocol::TWITTER) {
                return;
        }
 
@@ -812,8 +813,8 @@ function twitter_do_mirrorpost(App $a, $uid, $post)
 {
        $datarray['api_source'] = true;
        $datarray['profile_uid'] = $uid;
-       $datarray['extid'] = NETWORK_TWITTER;
-       $datarray['message_id'] = Item::newURI($uid, NETWORK_TWITTER . ':' . $post->id);
+       $datarray['extid'] = Protocol::TWITTER;
+       $datarray['message_id'] = Item::newURI($uid, Protocol::TWITTER . ':' . $post->id);
        $datarray['protocol'] = Conversation::PARCEL_TWITTER;
        $datarray['source'] = json_encode($post);
        $datarray['title'] = '';
@@ -924,14 +925,14 @@ function twitter_fetchtimeline(App $a, $uid)
 function twitter_queue_hook(App $a)
 {
        $qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
-               DBA::escape(NETWORK_TWITTER)
+               DBA::escape(Protocol::TWITTER)
        );
        if (!DBA::isResult($qi)) {
                return;
        }
 
        foreach ($qi as $x) {
-               if ($x['network'] !== NETWORK_TWITTER) {
+               if ($x['network'] !== Protocol::TWITTER) {
                        continue;
                }
 
@@ -1003,13 +1004,13 @@ function twitter_fetch_contact($uid, $data, $create_user)
        $url = "https://twitter.com/" . $data->screen_name;
        $addr = $data->screen_name . "@twitter.com";
 
-       GContact::update(["url" => $url, "network" => NETWORK_TWITTER,
+       GContact::update(["url" => $url, "network" => Protocol::TWITTER,
                "photo" => $avatar, "hide" => true,
                "name" => $data->name, "nick" => $data->screen_name,
                "location" => $data->location, "about" => $data->description,
                "addr" => $addr, "generation" => 2]);
 
-       $fields = ['url' => $url, 'network' => NETWORK_TWITTER,
+       $fields = ['url' => $url, 'network' => Protocol::TWITTER,
                'name' => $data->name, 'nick' => $data->screen_name, 'addr' => $addr,
                 'location' => $data->location, 'about' => $data->description];
 
@@ -1343,7 +1344,7 @@ function twitter_media_entities($post, array &$postarray)
 function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $only_existing_contact, $noquote)
 {
        $postarray = [];
-       $postarray['network'] = NETWORK_TWITTER;
+       $postarray['network'] = Protocol::TWITTER;
        $postarray['uid'] = $uid;
        $postarray['wall'] = 0;
        $postarray['uri'] = "twitter::" . $post->id_str;