X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=pumpio%2Fpumpio.php;h=357f17433b1bf495eb1868760b8fc00ae124b264;hb=7777f080475df3218c851bd48ab609bcc54a071d;hp=68f3e8d774f7862c9396ab3aae7e98edac688299;hpb=ea3a9052d83f8ea99cee8438022be0b022a24cc1;p=friendica-addons.git
diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php
index 68f3e8d7..357f1743 100644
--- a/pumpio/pumpio.php
+++ b/pumpio/pumpio.php
@@ -9,11 +9,8 @@
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
-use Friendica\Core\Config;
use Friendica\Core\Hook;
-use Friendica\Core\L10n;
use Friendica\Core\Logger;
-use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
@@ -21,12 +18,12 @@ 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;
use Friendica\Util\ConfigFileLoader;
use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Network;
use Friendica\Util\Strings;
use Friendica\Util\XML;
@@ -49,25 +46,12 @@ 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)
{
if (!local_user()) {
- notice(L10n::t('Permission denied.') . EOL);
+ notice(DI::l10n()->t('Permission denied.') . EOL);
return '';
}
@@ -103,13 +87,13 @@ function pumpio_registerclient(App $a, $host)
$params = [];
- $application_name = Config::get('pumpio', 'application_name');
+ $application_name = DI::config()->get('pumpio', 'application_name');
if ($application_name == "") {
$application_name = DI::baseUrl()->getHostname();
}
- $adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
+ $adminlist = explode(",", str_replace(" ", "", DI::config()->get('config', 'admin_email')));
$params["type"] = "client_associate";
$params["contacts"] = $adminlist[0];
@@ -150,8 +134,8 @@ function pumpio_connect(App $a)
if ((($consumer_key == "") || ($consumer_secret == "")) && ($hostname != "")) {
Logger::log("pumpio_connect: register client");
$clientdata = pumpio_registerclient($a, $hostname);
- PConfig::set(local_user(), 'pumpio', 'consumer_key', $clientdata->client_id);
- PConfig::set(local_user(), 'pumpio', 'consumer_secret', $clientdata->client_secret);
+ DI::pConfig()->set(local_user(), 'pumpio', 'consumer_key', $clientdata->client_id);
+ DI::pConfig()->set(local_user(), 'pumpio', 'consumer_secret', $clientdata->client_secret);
$consumer_key = DI::pConfig()->get(local_user(), 'pumpio', 'consumer_key');
$consumer_secret = DI::pConfig()->get(local_user(), 'pumpio', 'consumer_secret');
@@ -162,8 +146,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 .= 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
@@ -191,8 +174,8 @@ function pumpio_connect(App $a)
if (($success = $client->Process())) {
if (strlen($client->access_token)) {
Logger::log("pumpio_connect: otoken: ".$client->access_token." osecrect: ".$client->access_token_secret, Logger::DEBUG);
- PConfig::set(local_user(), "pumpio", "oauth_token", $client->access_token);
- PConfig::set(local_user(), "pumpio", "oauth_token_secret", $client->access_token_secret);
+ DI::pConfig()->set(local_user(), "pumpio", "oauth_token", $client->access_token);
+ DI::pConfig()->set(local_user(), "pumpio", "oauth_token_secret", $client->access_token_secret);
}
}
$success = $client->Finalize($success);
@@ -203,8 +186,8 @@ function pumpio_connect(App $a)
if ($success) {
Logger::log("pumpio_connect: authenticated");
- $o = L10n::t("You are now authenticated to pumpio.");
- $o .= '
'.L10n::t("return to the connector page").'';
+ $o = DI::l10n()->t("You are now authenticated to pumpio.");
+ $o .= '
'.DI::l10n()->t("return to the connector page").'';
} else {
Logger::log("pumpio_connect: could not connect");
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
@@ -224,7 +207,7 @@ function pumpio_jot_nets(App $a, array &$jotnets_fields)
'type' => 'checkbox',
'field' => [
'pumpio_enable',
- L10n::t('Post to pumpio'),
+ DI::l10n()->t('Post to pumpio'),
DI::pConfig()->get(local_user(), 'pumpio', 'post_by_default')
]
];
@@ -265,20 +248,20 @@ function pumpio_settings(App $a, &$s)
/* Add some HTML to the existing form */
$s .= '';
- $s .= ''. L10n::t('Pump.io Import/Export/Mirror').'
';
+ $s .= ''. DI::l10n()->t('Pump.io Import/Export/Mirror').'
';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= ''. L10n::t('Pump.io Import/Export/Mirror').'
';
+ $s .= ''. DI::l10n()->t('Pump.io Import/Export/Mirror').'
';
$s .= '';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
@@ -289,36 +272,36 @@ function pumpio_settings(App $a, &$s)
$s .= '
';
if (($oauth_token == "") || ($oauth_token_secret == "")) {
$s .= '
';
} else {
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
$s .= '
';
- $s .= '';
+ $s .= '';
$s .= '';
$s .= '
';
}
@@ -328,26 +311,26 @@ function pumpio_settings(App $a, &$s)
/* provide a submit button */
- $s .= '
';
+ $s .= '
';
}
function pumpio_settings_post(App $a, array &$b)
{
if (!empty($_POST['pumpio-submit'])) {
if (!empty($_POST['pumpio_delete'])) {
- PConfig::set(local_user(), 'pumpio', 'consumer_key' , '');
- PConfig::set(local_user(), 'pumpio', 'consumer_secret' , '');
- PConfig::set(local_user(), 'pumpio', 'oauth_token' , '');
- PConfig::set(local_user(), 'pumpio', 'oauth_token_secret', '');
- PConfig::set(local_user(), 'pumpio', 'post' , false);
- PConfig::set(local_user(), 'pumpio', 'import' , false);
- PConfig::set(local_user(), 'pumpio', 'host' , '');
- PConfig::set(local_user(), 'pumpio', 'user' , '');
- PConfig::set(local_user(), 'pumpio', 'public' , false);
- PConfig::set(local_user(), 'pumpio', 'mirror' , false);
- PConfig::set(local_user(), 'pumpio', 'post_by_default' , false);
- PConfig::set(local_user(), 'pumpio', 'lastdate' , 0);
- PConfig::set(local_user(), 'pumpio', 'last_id' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'consumer_key' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'consumer_secret' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'oauth_token' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'oauth_token_secret', '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'post' , false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'import' , false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'host' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'user' , '');
+ DI::pConfig()->set(local_user(), 'pumpio', 'public' , false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'mirror' , false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'post_by_default' , false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'lastdate' , 0);
+ DI::pConfig()->set(local_user(), 'pumpio', 'last_id' , '');
} else {
// filtering the username if it is filled wrong
$user = $_POST['pumpio_user'];
@@ -364,16 +347,16 @@ function pumpio_settings_post(App $a, array &$b)
$host = trim($host);
$host = str_replace(["https://", "http://"], ["", ""], $host);
- PConfig::set(local_user(), 'pumpio', 'post' , $_POST['pumpio'] ?? false);
- PConfig::set(local_user(), 'pumpio', 'import' , $_POST['pumpio_import'] ?? false);
- PConfig::set(local_user(), 'pumpio', 'host' , $host);
- PConfig::set(local_user(), 'pumpio', 'user' , $user);
- PConfig::set(local_user(), 'pumpio', 'public' , $_POST['pumpio_public'] ?? false);
- PConfig::set(local_user(), 'pumpio', 'mirror' , $_POST['pumpio_mirror'] ?? false);
- PConfig::set(local_user(), 'pumpio', 'post_by_default', $_POST['pumpio_bydefault'] ?? false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'post' , $_POST['pumpio'] ?? false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'import' , $_POST['pumpio_import'] ?? false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'host' , $host);
+ DI::pConfig()->set(local_user(), 'pumpio', 'user' , $user);
+ DI::pConfig()->set(local_user(), 'pumpio', 'public' , $_POST['pumpio_public'] ?? false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'mirror' , $_POST['pumpio_mirror'] ?? false);
+ DI::pConfig()->set(local_user(), 'pumpio', 'post_by_default', $_POST['pumpio_bydefault'] ?? false);
if (!empty($_POST['pumpio_mirror'])) {
- PConfig::delete(local_user(), 'pumpio', 'lastdate');
+ DI::pConfig()->delete(local_user(), 'pumpio', 'lastdate');
}
}
}
@@ -406,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;
@@ -456,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"]);
@@ -529,7 +512,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 = [];
@@ -597,7 +580,7 @@ function pumpio_send(App $a, array &$b)
if ($success) {
if ($user->generator->displayName) {
- PConfig::set($b["uid"], "pumpio", "application_name", $user->generator->displayName);
+ DI::pConfig()->set($b["uid"], "pumpio", "application_name", $user->generator->displayName);
}
$post_id = $user->object->id;
@@ -627,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;
@@ -675,7 +658,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();
}
}
@@ -688,9 +671,9 @@ function pumpio_sync(App $a)
return;
}
- $last = Config::get('pumpio', 'last_poll');
+ $last = DI::config()->get('pumpio', 'last_poll');
- $poll_interval = intval(Config::get('pumpio', 'poll_interval', PUMPIO_DEFAULT_POLL_INTERVAL));
+ $poll_interval = intval(DI::config()->get('pumpio', 'poll_interval', PUMPIO_DEFAULT_POLL_INTERVAL));
if ($last) {
$next = $last + ($poll_interval * 60);
@@ -709,7 +692,7 @@ function pumpio_sync(App $a)
}
}
- $abandon_days = intval(Config::get('system', 'account_abandon_days'));
+ $abandon_days = intval(DI::config()->get('system', 'account_abandon_days'));
if ($abandon_days < 1) {
$abandon_days = 0;
}
@@ -740,14 +723,14 @@ function pumpio_sync(App $a)
if ($next_contact_check <= time()) {
pumpio_getallusers($a, $rr["uid"]);
- PConfig::set($rr['uid'], 'pumpio', 'contact_check', time());
+ DI::pConfig()->set($rr['uid'], 'pumpio', 'contact_check', time());
}
}
}
Logger::log('pumpio: cron_end');
- Config::set('pumpio', 'last_poll', time());
+ DI::config()->set('pumpio', 'last_poll', time());
}
function pumpio_cron(App $a, $b)
@@ -770,7 +753,7 @@ function pumpio_fetchtimeline(App $a, $uid)
// hostname of the node if neither one is set.
$application_name = DI::pConfig()->get($uid, 'pumpio', 'application_name');
if ($application_name == "") {
- $application_name = Config::get('pumpio', 'application_name');
+ $application_name = DI::config()->get('pumpio', 'application_name');
}
if ($application_name == "") {
$application_name = DI::baseUrl()->getHostname();
@@ -882,7 +865,7 @@ function pumpio_fetchtimeline(App $a, $uid)
}
if ($lastdate != 0) {
- PConfig::set($uid, 'pumpio', 'lastdate', $lastdate);
+ DI::pConfig()->set($uid, 'pumpio', 'lastdate', $lastdate);
}
}
@@ -890,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,7 +900,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']);
@@ -928,8 +911,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;
@@ -937,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;
}
@@ -973,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;
}
@@ -986,7 +967,7 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
$likedata['wall'] = 0;
$likedata['network'] = Protocol::PUMPIO;
$likedata['uri'] = Item::newURI($uid);
- $likedata['parent-uri'] = $orig_post["uri"];
+ $likedata['thr-parent'] = $orig_post['uri'];
$likedata['contact-id'] = $contactid;
$likedata['app'] = $post->generator->displayName;
$likedata['author-name'] = $post->actor->displayName;
@@ -997,11 +978,11 @@ function pumpio_dolike(App $a, $uid, $self, $post, $own_id, $threadcompletion =
$author = '[url=' . $likedata['author-link'] . ']' . $likedata['author-name'] . '[/url]';
$objauthor = '[url=' . $orig_post['author-link'] . ']' . $orig_post['author-name'] . '[/url]';
- $post_type = L10n::t('status');
+ $post_type = DI::l10n()->t('status');
$plink = '[url=' . $orig_post['plink'] . ']' . $post_type . '[/url]';
$likedata['object-type'] = Activity\ObjectType::NOTE;
- $likedata['body'] = L10n::t('%1$s likes %2$s\'s %3$s', $author, $objauthor, $plink);
+ $likedata['body'] = DI::l10n()->t('%1$s likes %2$s\'s %3$s', $author, $objauthor, $plink);
$likedata['object'] = '';
@@ -1074,7 +1055,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;
@@ -1084,14 +1065,14 @@ 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);
+ if (Post::exists($condition)) {
+ Item::markForDeletion($condition);
return true;
}
$condition = ['extid' => $post->object->id, 'uid' => $uid];
- if (Item::exists($condition)) {
- Item::delete($condition);
+ if (Post::exists($condition)) {
+ Item::markForDeletion($condition);
return true;
}
return false;
@@ -1099,8 +1080,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);
}
@@ -1115,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;
}
}
@@ -1159,7 +1138,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
$contact_id = $self[0]['id'];
}
- $postarray['parent-uri'] = $post->object->id;
+ $postarray['thr-parent'] = $post->object->id;
if (!$public) {
$postarray['private'] = 1;
@@ -1220,7 +1199,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
$reply->url = $post->object->inReplyTo->url;
pumpio_dopost($a, $client, $uid, $self, $reply, $own_id, false);
- $postarray['parent-uri'] = $post->object->inReplyTo->id;
+ $postarray['thr-parent'] = $post->object->inReplyTo->id;
}
// When there is no content there is no need to continue
@@ -1280,9 +1259,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]";
}
@@ -1300,7 +1278,7 @@ function pumpio_dopost(App $a, $client, $uid, $self, $post, $own_id, $threadcomp
}
if (($post->object->objectType == "comment") && $threadcompletion) {
- pumpio_fetchallcomments($a, $uid, $postarray['parent-uri']);
+ pumpio_fetchallcomments($a, $uid, $postarray['thr-parent']);
}
return $top_item;
@@ -1321,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`.`iid`
+ 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)
);
@@ -1372,7 +1350,7 @@ function pumpio_fetchinbox(App $a, $uid)
pumpio_fetchallcomments($a, $uid, $item["uri"]);
}
- PConfig::set($uid, 'pumpio', 'last_id', $last_id);
+ DI::pConfig()->set($uid, 'pumpio', 'last_id', $last_id);
}
function pumpio_getallusers(App &$a, $uid)
@@ -1526,12 +1504,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 = Post::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';
@@ -1583,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;
}
@@ -1613,7 +1591,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();
}
/*