Remove the queue from the addons
parent
5d0760f285
commit
f034f97f8a
|
@ -17,7 +17,6 @@ use Friendica\Core\Logger;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Model\Queue;
|
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
|
|
||||||
function diaspora_install()
|
function diaspora_install()
|
||||||
|
@ -28,7 +27,6 @@ function diaspora_install()
|
||||||
Hook::register('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
Hook::register('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
||||||
Hook::register('connector_settings', 'addon/diaspora/diaspora.php', 'diaspora_settings');
|
Hook::register('connector_settings', 'addon/diaspora/diaspora.php', 'diaspora_settings');
|
||||||
Hook::register('connector_settings_post', 'addon/diaspora/diaspora.php', 'diaspora_settings_post');
|
Hook::register('connector_settings_post', 'addon/diaspora/diaspora.php', 'diaspora_settings_post');
|
||||||
Hook::register('queue_predeliver', 'addon/diaspora/diaspora.php', 'diaspora_queue_hook');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function diaspora_uninstall()
|
function diaspora_uninstall()
|
||||||
|
@ -39,7 +37,6 @@ function diaspora_uninstall()
|
||||||
Hook::unregister('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
Hook::unregister('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
||||||
Hook::unregister('connector_settings', 'addon/diaspora/diaspora.php', 'diaspora_settings');
|
Hook::unregister('connector_settings', 'addon/diaspora/diaspora.php', 'diaspora_settings');
|
||||||
Hook::unregister('connector_settings_post', 'addon/diaspora/diaspora.php', 'diaspora_settings_post');
|
Hook::unregister('connector_settings_post', 'addon/diaspora/diaspora.php', 'diaspora_settings_post');
|
||||||
Hook::unregister('queue_predeliver', 'addon/diaspora/diaspora.php', 'diaspora_queue_hook');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function diaspora_jot_nets(App $a, array &$jotnets_fields)
|
function diaspora_jot_nets(App $a, array &$jotnets_fields)
|
||||||
|
@ -60,78 +57,6 @@ function diaspora_jot_nets(App $a, array &$jotnets_fields)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function diaspora_queue_hook(App $a, &$b) {
|
|
||||||
$hostname = $a->getHostName();
|
|
||||||
|
|
||||||
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
|
||||||
DBA::escape(Protocol::DIASPORA2)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!DBA::isResult($qi)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($qi as $x) {
|
|
||||||
if ($x['network'] !== Protocol::DIASPORA2) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger::log('diaspora_queue: run');
|
|
||||||
|
|
||||||
$r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid`
|
|
||||||
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
|
||||||
intval($x['cid'])
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!DBA::isResult($r)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$userdata = $r[0];
|
|
||||||
|
|
||||||
$handle = PConfig::get($userdata['uid'], 'diaspora', 'handle');
|
|
||||||
$password = PConfig::get($userdata['uid'], 'diaspora', 'password');
|
|
||||||
$aspect = PConfig::get($userdata['uid'], 'diaspora', 'aspect');
|
|
||||||
|
|
||||||
$success = false;
|
|
||||||
|
|
||||||
if ($handle && $password) {
|
|
||||||
Logger::log('diaspora_queue: able to post for user '.$handle);
|
|
||||||
|
|
||||||
$z = unserialize($x['content']);
|
|
||||||
|
|
||||||
$post = $z['post'];
|
|
||||||
|
|
||||||
Logger::log('diaspora_queue: post: '.$post, Logger::DATA);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Logger::log('diaspora_queue: prepare', Logger::DEBUG);
|
|
||||||
$conn = new Diaspora_Connection($handle, $password);
|
|
||||||
Logger::log('diaspora_queue: try to log in '.$handle, Logger::DEBUG);
|
|
||||||
$conn->logIn();
|
|
||||||
Logger::log('diaspora_queue: try to send '.$body, Logger::DEBUG);
|
|
||||||
$conn->provider = $hostname;
|
|
||||||
$conn->postStatusMessage($post, $aspect);
|
|
||||||
|
|
||||||
Logger::log('diaspora_queue: send '.$userdata['uid'].' success', Logger::DEBUG);
|
|
||||||
|
|
||||||
$success = true;
|
|
||||||
|
|
||||||
Queue::removeItem($x['id']);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
Logger::log("diaspora_queue: Send ".$userdata['uid']." failed: ".$e->getMessage(), Logger::DEBUG);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Logger::log('diaspora_queue: send '.$userdata['uid'].' missing username or password', Logger::DEBUG);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$success) {
|
|
||||||
Logger::log('diaspora_queue: delayed');
|
|
||||||
Queue::updateTime($x['id']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function diaspora_settings(App $a, &$s)
|
function diaspora_settings(App $a, &$s)
|
||||||
{
|
{
|
||||||
if (! local_user()) {
|
if (! local_user()) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ use Friendica\Model\Contact;
|
||||||
use Friendica\Model\GContact;
|
use Friendica\Model\GContact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Queue;
|
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Util\Config\ConfigFileLoader;
|
use Friendica\Util\Config\ConfigFileLoader;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
@ -45,7 +44,6 @@ function pumpio_install()
|
||||||
Hook::register('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
Hook::register('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
||||||
Hook::register('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
Hook::register('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
||||||
Hook::register('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
Hook::register('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
||||||
Hook::register('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
|
||||||
Hook::register('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification');
|
Hook::register('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +57,6 @@ function pumpio_uninstall()
|
||||||
Hook::unregister('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
Hook::unregister('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
||||||
Hook::unregister('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
Hook::unregister('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
||||||
Hook::unregister('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
Hook::unregister('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
||||||
Hook::unregister('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
|
||||||
Hook::unregister('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification');
|
Hook::unregister('check_item_notification', 'addon/pumpio/pumpio.php', 'pumpio_check_item_notification');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1442,90 +1439,6 @@ function pumpio_getallusers(App &$a, $uid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_queue_hook(App $a, array &$b)
|
|
||||||
{
|
|
||||||
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
|
||||||
DBA::escape(Protocol::PUMPIO)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!DBA::isResult($qi)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($qi as $x) {
|
|
||||||
if ($x['network'] !== Protocol::PUMPIO) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger::log('pumpio_queue: run');
|
|
||||||
|
|
||||||
$r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
|
|
||||||
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
|
||||||
intval($x['cid'])
|
|
||||||
);
|
|
||||||
if (!DBA::isResult($r)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$userdata = $r[0];
|
|
||||||
|
|
||||||
//Logger::log('pumpio_queue: fetching userdata '.print_r($userdata, true));
|
|
||||||
|
|
||||||
$oauth_token = PConfig::get($userdata['uid'], "pumpio", "oauth_token");
|
|
||||||
$oauth_token_secret = PConfig::get($userdata['uid'], "pumpio", "oauth_token_secret");
|
|
||||||
$consumer_key = PConfig::get($userdata['uid'], "pumpio", "consumer_key");
|
|
||||||
$consumer_secret = PConfig::get($userdata['uid'], "pumpio", "consumer_secret");
|
|
||||||
|
|
||||||
$host = PConfig::get($userdata['uid'], "pumpio", "host");
|
|
||||||
$user = PConfig::get($userdata['uid'], "pumpio", "user");
|
|
||||||
|
|
||||||
$success = false;
|
|
||||||
|
|
||||||
if ($oauth_token && $oauth_token_secret &&
|
|
||||||
$consumer_key && $consumer_secret) {
|
|
||||||
$username = $user.'@'.$host;
|
|
||||||
|
|
||||||
Logger::log('pumpio_queue: able to post for user '.$username);
|
|
||||||
|
|
||||||
$z = unserialize($x['content']);
|
|
||||||
|
|
||||||
$client = new oauth_client_class;
|
|
||||||
$client->oauth_version = '1.0a';
|
|
||||||
$client->url_parameters = false;
|
|
||||||
$client->authorization_header = true;
|
|
||||||
$client->access_token = $oauth_token;
|
|
||||||
$client->access_token_secret = $oauth_token_secret;
|
|
||||||
$client->client_id = $consumer_key;
|
|
||||||
$client->client_secret = $consumer_secret;
|
|
||||||
|
|
||||||
if (pumpio_reachable($z['url'])) {
|
|
||||||
$success = $client->CallAPI($z['url'], 'POST', $z['post'], ['FailOnAccessError'=>true, 'RequestContentType'=>'application/json'], $user);
|
|
||||||
} else {
|
|
||||||
$success = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($success) {
|
|
||||||
$post_id = $user->object->id;
|
|
||||||
Logger::log('pumpio_queue: send '.$username.': success '.$post_id);
|
|
||||||
if ($post_id && $iscomment) {
|
|
||||||
Logger::log('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']);
|
|
||||||
Item::update(['extid' => $post_id], ['id' => $z['item']]);
|
|
||||||
}
|
|
||||||
Queue::removeItem($x['id']);
|
|
||||||
} else {
|
|
||||||
Logger::log('pumpio_queue: send '.$username.': '.$z['url'].' general error: ' . print_r($user, true));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Logger::log("pumpio_queue: Error getting tokens for user ".$userdata['uid']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$success) {
|
|
||||||
Logger::log('pumpio_queue: delayed');
|
|
||||||
Queue::updateTime($x['id']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function pumpio_getreceiver(App $a, array $b)
|
function pumpio_getreceiver(App $a, array $b)
|
||||||
{
|
{
|
||||||
$receiver = [];
|
$receiver = [];
|
||||||
|
|
|
@ -83,7 +83,6 @@ use Friendica\Model\GContact;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\ItemContent;
|
use Friendica\Model\ItemContent;
|
||||||
use Friendica\Model\Queue;
|
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
use Friendica\Util\Config\ConfigFileLoader;
|
use Friendica\Util\Config\ConfigFileLoader;
|
||||||
|
@ -106,7 +105,6 @@ function twitter_install()
|
||||||
Hook::register('notifier_normal' , __FILE__, 'twitter_post_hook');
|
Hook::register('notifier_normal' , __FILE__, 'twitter_post_hook');
|
||||||
Hook::register('jot_networks' , __FILE__, 'twitter_jot_nets');
|
Hook::register('jot_networks' , __FILE__, 'twitter_jot_nets');
|
||||||
Hook::register('cron' , __FILE__, 'twitter_cron');
|
Hook::register('cron' , __FILE__, 'twitter_cron');
|
||||||
Hook::register('queue_predeliver' , __FILE__, 'twitter_queue_hook');
|
|
||||||
Hook::register('follow' , __FILE__, 'twitter_follow');
|
Hook::register('follow' , __FILE__, 'twitter_follow');
|
||||||
Hook::register('expire' , __FILE__, 'twitter_expire');
|
Hook::register('expire' , __FILE__, 'twitter_expire');
|
||||||
Hook::register('prepare_body' , __FILE__, 'twitter_prepare_body');
|
Hook::register('prepare_body' , __FILE__, 'twitter_prepare_body');
|
||||||
|
@ -124,7 +122,6 @@ function twitter_uninstall()
|
||||||
Hook::unregister('notifier_normal' , __FILE__, 'twitter_post_hook');
|
Hook::unregister('notifier_normal' , __FILE__, 'twitter_post_hook');
|
||||||
Hook::unregister('jot_networks' , __FILE__, 'twitter_jot_nets');
|
Hook::unregister('jot_networks' , __FILE__, 'twitter_jot_nets');
|
||||||
Hook::unregister('cron' , __FILE__, 'twitter_cron');
|
Hook::unregister('cron' , __FILE__, 'twitter_cron');
|
||||||
Hook::unregister('queue_predeliver' , __FILE__, 'twitter_queue_hook');
|
|
||||||
Hook::unregister('follow' , __FILE__, 'twitter_follow');
|
Hook::unregister('follow' , __FILE__, 'twitter_follow');
|
||||||
Hook::unregister('expire' , __FILE__, 'twitter_expire');
|
Hook::unregister('expire' , __FILE__, 'twitter_expire');
|
||||||
Hook::unregister('prepare_body' , __FILE__, 'twitter_prepare_body');
|
Hook::unregister('prepare_body' , __FILE__, 'twitter_prepare_body');
|
||||||
|
@ -985,66 +982,6 @@ function twitter_fetchtimeline(App $a, $uid)
|
||||||
Logger::log('Last ID for user ' . $uid . ' is now ' . $lastid, Logger::DEBUG);
|
Logger::log('Last ID for user ' . $uid . ' is now ' . $lastid, Logger::DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
function twitter_queue_hook(App $a)
|
|
||||||
{
|
|
||||||
$qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
|
|
||||||
DBA::escape(Protocol::TWITTER)
|
|
||||||
);
|
|
||||||
if (!DBA::isResult($qi)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($qi as $x) {
|
|
||||||
if ($x['network'] !== Protocol::TWITTER) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger::log('twitter_queue: run');
|
|
||||||
|
|
||||||
$r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid`
|
|
||||||
WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
|
|
||||||
intval($x['cid'])
|
|
||||||
);
|
|
||||||
if (!DBA::isResult($r)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = $r[0];
|
|
||||||
|
|
||||||
$ckey = Config::get('twitter', 'consumerkey');
|
|
||||||
$csecret = Config::get('twitter', 'consumersecret');
|
|
||||||
$otoken = PConfig::get($user['uid'], 'twitter', 'oauthtoken');
|
|
||||||
$osecret = PConfig::get($user['uid'], 'twitter', 'oauthsecret');
|
|
||||||
|
|
||||||
$success = false;
|
|
||||||
|
|
||||||
if ($ckey && $csecret && $otoken && $osecret) {
|
|
||||||
Logger::log('twitter_queue: able to post');
|
|
||||||
|
|
||||||
$z = unserialize($x['content']);
|
|
||||||
|
|
||||||
$connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
|
|
||||||
$result = $connection->post($z['url'], $z['post']);
|
|
||||||
|
|
||||||
Logger::log('twitter_queue: post result: ' . print_r($result, true), Logger::DEBUG);
|
|
||||||
|
|
||||||
if ($result->errors) {
|
|
||||||
Logger::log('twitter_queue: Send to Twitter failed: "' . print_r($result->errors, true) . '"');
|
|
||||||
} else {
|
|
||||||
$success = true;
|
|
||||||
Queue::removeItem($x['id']);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Logger::log("twitter_queue: Error getting tokens for user " . $user['uid']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$success) {
|
|
||||||
Logger::log('twitter_queue: delayed');
|
|
||||||
Queue::updateTime($x['id']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function twitter_fix_avatar($avatar)
|
function twitter_fix_avatar($avatar)
|
||||||
{
|
{
|
||||||
$new_avatar = str_replace("_normal.", ".", $avatar);
|
$new_avatar = str_replace("_normal.", ".", $avatar);
|
||||||
|
|
Loading…
Reference in New Issue