X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=ifttt%2Fifttt.php;h=a0cc1ae806af1ad818d948cf263c867f338d8fc3;hb=f4f61aa1518857247f012f27e28e45a9d0813090;hp=5021a63ed60cdd5482d7600e0505a27113bc2254;hpb=73b505563be38da1f93c2c86371ce3fc15a809e5;p=friendica-addons.git diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php index 5021a63e..a0cc1ae8 100644 --- a/ifttt/ifttt.php +++ b/ifttt/ifttt.php @@ -6,7 +6,6 @@ * Version: 0.1 * Author: Michael Vogel */ -require_once 'mod/item.php'; use Friendica\App; use Friendica\Content\PageInfo; use Friendica\Core\Hook; @@ -15,6 +14,7 @@ use Friendica\Core\Protocol; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Item; +use Friendica\Model\Post; use Friendica\Util\Strings; function ifttt_install() @@ -161,25 +161,16 @@ function ifttt_message($uid, $item) { $a = DI::app(); - $_SESSION['authenticated'] = true; - $_SESSION['uid'] = $uid; - - unset($_REQUEST); - $_REQUEST['api_source'] = true; - $_REQUEST['profile_uid'] = $uid; - $_REQUEST['source'] = 'IFTTT'; - $_REQUEST['title'] = ''; - $_REQUEST['body'] = $item['msg']; - //$_REQUEST['date'] = $item['date']; - //$_REQUEST['uri'] = $item['url']; - - if (!empty($item['url']) && strstr($item['url'], 'facebook.com')) { - $hash = hash('ripemd128', $item['url']); - $_REQUEST['extid'] = Protocol::FACEBOOK; - $_REQUEST['message_id'] = Item::newURI($uid, Protocol::FACEBOOK . ':' . $hash); - } + $post = []; + $post['uid'] = $uid; + $post['app'] = 'IFTTT'; + $post['title'] = ''; + $post['body'] = $item['msg']; + //$post['date'] = $item['date']; + //$post['uri'] = $item['url']; if ($item['type'] == 'link') { + $link = $item['link']; $data = PageInfo::queryUrl($item['link']); if (isset($item['title']) && (trim($item['title']) != '')) { @@ -190,10 +181,15 @@ function ifttt_message($uid, $item) $data['text'] = $item['description']; } - $_REQUEST['body'] .= "\n" . PageInfo::getFooterFromData($data); + $post['body'] .= "\n" . PageInfo::getFooterFromData($data); } elseif (($item['type'] == 'photo') && ($item['image'] != '')) { - $_REQUEST['body'] .= "\n\n[img]" . $item['image'] . "[/img]\n"; + $link = $item['image']; + $post['body'] .= "\n\n[img]" . $item['image'] . "[/img]\n"; + } elseif (!empty($item['url'])) { + $link = $item['url']; + } else { + $link = hash('ripemd128', $item['msg']); } - item_post($a); + Post\Delayed::add($link, $post, PRIORITY_MEDIUM, true); }