X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=pumpio%2Fpumpio.php;h=cd44b682e6ddf5e760cd65ade8e4ed152cee7252;hb=a0344101f122248c3069a5dcfa3ebfcb67215d5a;hp=c6c492d4757efc7e841ed106b0a85886b25241ab;hpb=65e4726718a10e1d15782d299b348add76377751;p=friendica-addons.git diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index c6c492d4..cd44b682 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -23,7 +23,6 @@ use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityNamespace; use Friendica\Util\ConfigFileLoader; use Friendica\Util\DateTimeFormat; -use Friendica\Util\Network; use Friendica\Util\Strings; use Friendica\Util\XML; @@ -46,19 +45,6 @@ function pumpio_install() Hook::register('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification'); } -function pumpio_uninstall() -{ - Hook::unregister('load_config', 'addon/pumpio/pumpio.php', 'pumpio_load_config'); - Hook::unregister('hook_fork', 'addon/pumpio/pumpio.php', 'pumpio_hook_fork'); - Hook::unregister('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local'); - Hook::unregister('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send'); - Hook::unregister('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets'); - Hook::unregister('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings'); - Hook::unregister('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post'); - Hook::unregister('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron'); - Hook::unregister('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification'); -} - function pumpio_module() {} function pumpio_content(App $a) @@ -159,8 +145,7 @@ function pumpio_connect(App $a) if (($consumer_key == "") || ($consumer_secret == "")) { Logger::log("pumpio_connect: ".sprintf("Unable to register the client at the pump.io server '%s'.", $hostname)); - $o .= DI::l10n()->t("Unable to register the client at the pump.io server '%s'.", $hostname); - return $o; + return DI::l10n()->t("Unable to register the client at the pump.io server '%s'.", $hostname); } // The callback URL is the script that gets called after the user authenticates with pumpio @@ -526,7 +511,7 @@ function pumpio_send(App $a, array &$b) if ($oauth_token && $oauth_token_secret) { $title = trim($b['title']); - $content = BBCode::convert($b['body'], false, 4); + $content = BBCode::convert($b['body'], false, BBCode::CONNECTORS); $params = []; @@ -672,7 +657,7 @@ function pumpio_action(App $a, $uid, $uri, $action, $content = "") if ($success) { Logger::log('pumpio_action '.$username.' '.$action.': success '.$uri); } else { - Logger::log('pumpio_action '.$username.' '.$action.': general error: '.$uri.' '.print_r($user, true)); + Logger::log('pumpio_action '.$username.' '.$action.': general error: '.$uri); Worker::defer(); } } @@ -914,7 +899,7 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id) } } - Item::delete(['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]); + Item::markForDeletion(['verb' => Activity::LIKE, 'uid' => $uid, 'contact-id' => $contactid, 'thr-parent' => $orig_post['uri']]); if (DBA::isResult($r)) { Logger::log("pumpio_dounlike: unliked existing like. User ".$own_id." ".$uid." Contact: ".$contactid." Url ".$orig_post['uri']); @@ -925,8 +910,6 @@ function pumpio_dounlike(App $a, $uid, $self, $post, $own_id) function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion = true) { - require_once('include/items.php'); - if (empty($post->object->id)) { Logger::log('Got empty like: '.print_r($post, true), Logger::DEBUG); return; @@ -1071,7 +1054,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) } if (!empty($contact->image->url)) { - Contact::updateAvatar($contact->image->url, $uid, $contact_id); + Contact::updateAvatar($contact_id, $contact->image->url); } return $contact_id; @@ -1082,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)) { - Item::delete($condition); + Item::markForDeletion($condition); return true; } $condition = ['extid' => $post->object->id, 'uid' => $uid]; if (Item::exists($condition)) { - Item::delete($condition); + Item::markForDeletion($condition); return true; } return false; @@ -1096,8 +1079,6 @@ function pumpio_dodelete(App $a, $uid, $self, $post, $own_id) function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcompletion = true) { - require_once('include/items.php'); - if (($post->verb == "like") || ($post->verb == "favorite")) { return pumpio_dolike($a, $uid, $self, $post, $own_id); } @@ -1277,9 +1258,8 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp $created = ''; } - $postarray['body'] = share_header($share_author, $post->object->author->url, - $post->object->author->image->url, "", - $created, $post->links->self->href). + $postarray['body'] = Friendica\Content\Text\BBCode::getShareOpeningTag($share_author, $post->object->author->url, + $post->object->author->image->url, $post->links->self->href, $created) . $postarray['body']."[/share]"; } @@ -1523,12 +1503,12 @@ function pumpio_fetchallcomments(App $a, $uid, $id) // Fetching the original post $condition = ["`uri` = ? AND `uid` = ? AND `extid` != ''", $id, $uid]; - $item = Item::selectFirst(['extid'], $condition); - if (!DBA::isResult($item)) { + $original = Item::selectFirst(['extid'], $condition); + if (!DBA::isResult($original)) { return false; } - $url = $item["extid"]; + $url = $original["extid"]; $client = new oauth_client_class; $client->oauth_version = '1.0a'; @@ -1610,7 +1590,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id) function pumpio_reachable($url) { - return Network::curl($url, false, ['timeout' => 10])->isSuccess(); + return DI::httpRequest()->get($url, ['timeout' => 10])->isSuccess(); } /*