]> git.mxchange.org Git - friendica-addons.git/blobdiff - ifttt/ifttt.php
audon/audon.php aktualisiert
[friendica-addons.git] / ifttt / ifttt.php
index a5db28bda70579633423ec2e228bdf347a070f44..6d4f402c5c49c203924be7b3756105739de15ca6 100644 (file)
@@ -10,13 +10,10 @@ use Friendica\App;
 use Friendica\Content\PageInfo;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
-use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
-use Friendica\Core\Session;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
-use Friendica\Model\Item;
 use Friendica\Model\Post;
 use Friendica\Util\Strings;
 
@@ -35,16 +32,16 @@ function ifttt_module() {}
 
 function ifttt_content() {}
 
-function ifttt_settings(App $a, array &$data)
+function ifttt_settings(array &$data)
 {
-       if (!Session::getLocalUser()) {
+       if (!DI::userSession()->getLocalUserId()) {
                return;
        }
 
-       $key = DI::pConfig()->get(Session::getLocalUser(), 'ifttt', 'key');
+       $key = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'ifttt', 'key');
        if (!$key) {
                $key = Strings::getRandomHex(20);
-               DI::pConfig()->set(Session::getLocalUser(), 'ifttt', 'key', $key);
+               DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'ifttt', 'key', $key);
        }
 
        $t    = Renderer::getMarkupTemplate('connector_settings.tpl', 'addon/ifttt/');
@@ -58,7 +55,7 @@ function ifttt_settings(App $a, array &$data)
                        'new_photo_upload_body'   => DI::l10n()->t('Body for "new photo upload"'),
                        'new_link_post_body'      => DI::l10n()->t('Body for "new link post"'),
                ],
-               '$url'                     => DI::baseUrl()->get() . '/ifttt/' . $a->getLoggedInUserNickname(),
+               '$url'                     => DI::baseUrl() . '/ifttt/' . DI::userSession()->getLocalUserNickname(),
                '$new_status_message_body' => 'key=' . $key . '&type=status&msg=<<<{{Message}}>>>&date=<<<{{UpdatedAt}}>>>&url=<<<{{PageUrl}}>>>',
                '$new_photo_upload_body'   => 'key=' . $key . '&type=photo&link=<<<{{Link}}>>>&image=<<<{{ImageSource}}>>>&msg=<<<{{Caption}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>',
                '$new_link_post_body'      => 'key=' . $key . '&type=link&link=<<<{{Link}}>>>&title=<<<{{Title}}>>>&msg=<<<{{Message}}>>>&description=<<<{{Description}}>>>&date=<<<{{CreatedAt}}>>>&url=<<<{{PageUrl}}>>>',
@@ -76,11 +73,11 @@ function ifttt_settings(App $a, array &$data)
 function ifttt_settings_post()
 {
        if (!empty($_POST['ifttt-submit'])) {
-               DI::pConfig()->delete(Session::getLocalUser(), 'ifttt', 'key');
+               DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'ifttt', 'key');
        }
 }
 
-function ifttt_post(App $a)
+function ifttt_post()
 {
        if (DI::args()->getArgc() != 2) {
                return;
@@ -153,8 +150,6 @@ function ifttt_post(App $a)
 
 function ifttt_message($uid, $item)
 {
-       $a = DI::app();
-
        $post = [];
        $post['uid'] = $uid;
        $post['app'] = 'IFTTT';
@@ -185,5 +180,5 @@ function ifttt_message($uid, $item)
                $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);
 }