mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-25 16:03:15 +00:00
Merge pull request #1318 from annando/no-mod-item
Calls to "item_post" are replaced
This commit is contained in:
commit
30329df0dd
4 changed files with 21 additions and 49 deletions
|
@ -10,12 +10,10 @@ use Friendica\App;
|
||||||
use Friendica\Content\PageInfo;
|
use Friendica\Content\PageInfo;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Item;
|
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
|
|
||||||
|
@ -152,8 +150,6 @@ function ifttt_post(App $a)
|
||||||
|
|
||||||
function ifttt_message($uid, $item)
|
function ifttt_message($uid, $item)
|
||||||
{
|
{
|
||||||
$a = DI::app();
|
|
||||||
|
|
||||||
$post = [];
|
$post = [];
|
||||||
$post['uid'] = $uid;
|
$post['uid'] = $uid;
|
||||||
$post['app'] = 'IFTTT';
|
$post['app'] = 'IFTTT';
|
||||||
|
@ -184,5 +180,5 @@ function ifttt_message($uid, $item)
|
||||||
$link = hash('ripemd128', $item['msg']);
|
$link = hash('ripemd128', $item['msg']);
|
||||||
}
|
}
|
||||||
|
|
||||||
Post\Delayed::add($link, $post, Worker::PRIORITY_MEDIUM, Post\Delayed::UNPREPARED);
|
Post\Delayed::add($link, $post, Worker::PRIORITY_MEDIUM, Post\Delayed::PREPARED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -780,40 +780,30 @@ function pumpio_fetchtimeline(App $a, int $uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($public && !stristr($post->generator->displayName, $application_name)) {
|
if ($public && !stristr($post->generator->displayName, $application_name)) {
|
||||||
$_SESSION['authenticated'] = true;
|
$postarray['uid'] = $uid;
|
||||||
$_SESSION['uid'] = $uid;
|
$postarray['app'] = 'pump.io';
|
||||||
|
|
||||||
unset($_REQUEST);
|
|
||||||
$_REQUEST['api_source'] = true;
|
|
||||||
$_REQUEST['profile_uid'] = $uid;
|
|
||||||
$_REQUEST['source'] = 'pump.io';
|
|
||||||
|
|
||||||
if (isset($post->object->id)) {
|
|
||||||
$_REQUEST['message_id'] = Protocol::PUMPIO . ':' . $post->object->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($post->object->displayName != '') {
|
if ($post->object->displayName != '') {
|
||||||
$_REQUEST['title'] = HTML::toBBCode($post->object->displayName);
|
$postarray['title'] = HTML::toBBCode($post->object->displayName);
|
||||||
} else {
|
} else {
|
||||||
$_REQUEST['title'] = '';
|
$postarray['title'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$_REQUEST['body'] = HTML::toBBCode($post->object->content);
|
$postarray['body'] = HTML::toBBCode($post->object->content);
|
||||||
|
|
||||||
// To-Do: Picture has to be cached and stored locally
|
// To-Do: Picture has to be cached and stored locally
|
||||||
if ($post->object->fullImage->url != '') {
|
if ($post->object->fullImage->url != '') {
|
||||||
if ($post->object->fullImage->pump_io->proxyURL != '') {
|
if ($post->object->fullImage->pump_io->proxyURL != '') {
|
||||||
$_REQUEST['body'] = '[url=' . $post->object->fullImage->pump_io->proxyURL . '][img]' . $post->object->image->pump_io->proxyURL . "[/img][/url]\n" . $_REQUEST['body'];
|
$postarray['body'] = '[url=' . $post->object->fullImage->pump_io->proxyURL . '][img]' . $post->object->image->pump_io->proxyURL . "[/img][/url]\n" . $postarray['body'];
|
||||||
} else {
|
} else {
|
||||||
$_REQUEST['body'] = '[url=' . $post->object->fullImage->url . '][img]' . $post->object->image->url . "[/img][/url]\n" . $_REQUEST['body'];
|
$postarray['body'] = '[url=' . $post->object->fullImage->url . '][img]' . $post->object->image->url . "[/img][/url]\n" . $postarray['body'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::notice('pumpio: posting for user ' . $uid);
|
Logger::notice('pumpio: posting for user ' . $uid);
|
||||||
|
|
||||||
require_once 'mod/item.php';
|
Item::insert($postarray, true);
|
||||||
|
|
||||||
item_post($a);
|
|
||||||
Logger::notice('pumpio: posting done - user ' . $uid);
|
Logger::notice('pumpio: posting done - user ' . $uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -762,7 +762,6 @@ function statusnet_fetchtimeline(App $a, int $uid)
|
||||||
$osecret = DI::pConfig()->get($uid, 'statusnet', 'oauthsecret');
|
$osecret = DI::pConfig()->get($uid, 'statusnet', 'oauthsecret');
|
||||||
$lastid = DI::pConfig()->get($uid, 'statusnet', 'lastid');
|
$lastid = DI::pConfig()->get($uid, 'statusnet', 'lastid');
|
||||||
|
|
||||||
require_once 'mod/item.php';
|
|
||||||
// get the application name for the SN app
|
// get the application name for the SN app
|
||||||
// 1st try personal config, then system config and fallback to the
|
// 1st try personal config, then system config and fallback to the
|
||||||
// hostname of the node if neither one is set.
|
// hostname of the node if neither one is set.
|
||||||
|
@ -819,46 +818,33 @@ function statusnet_fetchtimeline(App $a, int $uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stristr($post->source, $application_name)) {
|
if (!stristr($post->source, $application_name)) {
|
||||||
$_SESSION['authenticated'] = true;
|
$postarray['uid'] = $uid;
|
||||||
$_SESSION['uid'] = $uid;
|
$postarray['app'] = $post->source;
|
||||||
|
$postarray['extid'] = Protocol::STATUSNET;
|
||||||
|
|
||||||
unset($_REQUEST);
|
$postarray['title'] = '';
|
||||||
$_REQUEST['api_source'] = true;
|
|
||||||
$_REQUEST['profile_uid'] = $uid;
|
|
||||||
//$_REQUEST['source'] = 'StatusNet';
|
|
||||||
$_REQUEST['source'] = $post->source;
|
|
||||||
$_REQUEST['extid'] = Protocol::STATUSNET;
|
|
||||||
|
|
||||||
if (isset($post->id)) {
|
$postarray['body'] = $post->text;
|
||||||
$_REQUEST['message_id'] = Item::newURI(Protocol::STATUSNET . ':' . $post->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
//$_REQUEST['date'] = $post->created_at;
|
|
||||||
|
|
||||||
$_REQUEST['title'] = '';
|
|
||||||
|
|
||||||
$_REQUEST['body'] = $post->text;
|
|
||||||
if (is_string($post->place->name)) {
|
if (is_string($post->place->name)) {
|
||||||
$_REQUEST['location'] = $post->place->name;
|
$postarray['location'] = $post->place->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($post->place->full_name)) {
|
if (is_string($post->place->full_name)) {
|
||||||
$_REQUEST['location'] = $post->place->full_name;
|
$postarray['location'] = $post->place->full_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($post->geo->coordinates)) {
|
if (is_array($post->geo->coordinates)) {
|
||||||
$_REQUEST['coord'] = $post->geo->coordinates[0] . ' ' . $post->geo->coordinates[1];
|
$postarray['coord'] = $post->geo->coordinates[0] . ' ' . $post->geo->coordinates[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($post->coordinates->coordinates)) {
|
if (is_array($post->coordinates->coordinates)) {
|
||||||
$_REQUEST['coord'] = $post->coordinates->coordinates[1] . ' ' . $post->coordinates->coordinates[0];
|
$postarray['coord'] = $post->coordinates->coordinates[1] . ' ' . $post->coordinates->coordinates[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
//print_r($_REQUEST);
|
if ($postarray['body'] != '') {
|
||||||
if ($_REQUEST['body'] != '') {
|
|
||||||
Logger::notice('statusnet: posting for user ' . $uid);
|
Logger::notice('statusnet: posting for user ' . $uid);
|
||||||
|
|
||||||
item_post($a);
|
Item::insert($postarray, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1339,7 +1339,7 @@ function twitter_fetchtimeline(App $a, int $uid): void
|
||||||
|
|
||||||
Logger::info('Posting mirror post', ['twitter-id' => $post->id_str, 'uid' => $uid]);
|
Logger::info('Posting mirror post', ['twitter-id' => $post->id_str, 'uid' => $uid]);
|
||||||
|
|
||||||
Post\Delayed::add($mirrorpost['extid'], $mirrorpost, Worker::PRIORITY_MEDIUM, Post\Delayed::UNPREPARED);
|
Post\Delayed::add($mirrorpost['extid'], $mirrorpost, Worker::PRIORITY_MEDIUM, Post\Delayed::PREPARED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DI::pConfig()->set($uid, 'twitter', 'lastid', $lastid);
|
DI::pConfig()->set($uid, 'twitter', 'lastid', $lastid);
|
||||||
|
|
Loading…
Reference in a new issue