diff --git a/advancedcontentfilter/advancedcontentfilter.php b/advancedcontentfilter/advancedcontentfilter.php index dd04e7693..eebec4b0e 100644 --- a/advancedcontentfilter/advancedcontentfilter.php +++ b/advancedcontentfilter/advancedcontentfilter.php @@ -405,7 +405,7 @@ function advancedcontentfilter_get_variables_guid(ServerRequestInterface $reques $condition = ["`guid` = ? AND (`uid` = ? OR `uid` = 0)", $args['guid'], local_user()]; $params = ['order' => ['uid' => true]]; - $item = Item::selectFirst(local_user(), [], $condition, $params); + $item = Item::selectFirstForUser(local_user(), [], $condition, $params); if (!\Friendica\Database\DBM::is_result($item)) { throw new HTTPException\NotFoundException(L10n::t('Unknown post with guid: %s', $args['guid'])); diff --git a/mailstream/mailstream.php b/mailstream/mailstream.php index 6c057b21b..cf2fcc848 100644 --- a/mailstream/mailstream.php +++ b/mailstream/mailstream.php @@ -13,6 +13,7 @@ use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Database\DBM; use Friendica\Util\Network; +use Friendica\Model\Item; function mailstream_install() { Addon::registerHook('addon_settings', 'addon/mailstream/mailstream.php', 'mailstream_addon_settings'); @@ -335,8 +336,7 @@ function mailstream_cron($a, $b) { if (!$ms_item_id['message-id'] || !strlen($ms_item_id['message-id'])) { logger('mailstream_cron: Item ' . $ms_item_id['id'] . ' URI ' . $ms_item_id['uri'] . ' has no message-id', LOGGER_NORMAL); } - $items = q('SELECT * FROM `item` WHERE `id` = %d', $ms_item_id['id']); - $item = $items[0]; + $item = Item::selectFirst([], ['id' => $ms_item_id['id']]); $users = q("SELECT * FROM `user` WHERE `uid` = %d", intval($item['uid'])); $user = $users[0]; if ($user && $item) { diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index cf659225d..d57f1485a 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -1217,14 +1217,6 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet DateTimeFormat::utc($post->object->created), $post->links->self->href). $postarray['body']."[/share]"; - - /* - $postarray['body'] = "[share author='".$share_author. - "' profile='".$post->object->author->url. - "' avatar='".$post->object->author->image->url. - "' posted='".DateTimeFormat::convert($post->object->created, 'UTC', 'UTC', ). - "' link='".$post->links->self->href."']".$postarray['body']."[/share]"; - */ } else { // Let shares look like wall-to-wall posts $postarray['author-name'] = $post->object->author->displayName; @@ -1249,59 +1241,6 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet if ($threadcompletion) pumpio_fetchallcomments($a, $uid, $postarray['parent-uri']); - - $user = q("SELECT * FROM `user` WHERE `uid` = %d AND `account_expired` = 0 LIMIT 1", - intval($uid) - ); - - if(!count($user)) - return $top_item; - - $importer_url = $a->get_baseurl() . '/profile/' . $user[0]['nickname']; - - if (link_compare($own_id, $postarray['author-link'])) - return $top_item; - - if (!function_exists("check_item_notification")) { - $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0", - dbesc($postarray['parent-uri']), - intval($uid) - ); - - if(count($myconv)) { - - foreach($myconv as $conv) { - // now if we find a match, it means we're in this conversation - - if(!link_compare($conv['author-link'],$importer_url) && !link_compare($conv['author-link'],$own_id)) - continue; - - require_once('include/enotify.php'); - - $conv_parent = $conv['parent']; - - notification([ - 'type' => NOTIFY_COMMENT, - 'notify_flags' => $user[0]['notify-flags'], - 'language' => $user[0]['language'], - 'to_name' => $user[0]['username'], - 'to_email' => $user[0]['email'], - 'uid' => $user[0]['uid'], - 'item' => $postarray, - 'link' => $a->get_baseurl().'/display/'.urlencode(Item::getGuidById($top_item)), - 'source_name' => $postarray['author-name'], - 'source_link' => $postarray['author-link'], - 'source_photo' => $postarray['author-avatar'], - 'verb' => ACTIVITY_POST, - 'otype' => 'item', - 'parent' => $conv_parent, - ]); - - // only send one notification - break; - } - } - } } return $top_item; diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index a297baeb1..43f5d400f 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -55,6 +55,7 @@ use Friendica\Model\Photo; use Friendica\Model\User; use Friendica\Util\DateTimeFormat; use Friendica\Util\Network; +use Friendica\Database\DBM; function statusnet_install() { @@ -461,21 +462,15 @@ function statusnet_post_hook(App $a, &$b) return; } - $r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick - FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - WHERE `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1", dbesc($b["thr-parent"]), intval($b["uid"])); - - if (!count($r)) { + $condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]]; + $orig_post = Item::selectFirst(['author-link', 'uri'], $condition); + if (!DBM::is_result($orig_post)) { logger("statusnet_post_hook: no parent found " . $b["thr-parent"]); return; } else { $iscomment = true; - $orig_post = $r[0]; } - //$nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]"; - //$nicknameplain = "@".$orig_post["contact_nick"]; - $nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]"; @@ -688,17 +683,9 @@ function statusnet_prepare_body(App $a, &$b) $item = $b["item"]; $item["plink"] = $a->get_baseurl() . "/display/" . $a->user["nickname"] . "/" . $item["parent"]; - $r = q("SELECT `item`.`author-link`, `item`.`uri`, `contact`.`nick` AS contact_nick - FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - WHERE `item`.`uri` = '%s' AND `item`.`uid` = %d LIMIT 1", - dbesc($item["thr-parent"]), - intval(local_user())); - - if (count($r)) { - $orig_post = $r[0]; - //$nickname = "@[url=".$orig_post["author-link"]."]".$orig_post["contact_nick"]."[/url]"; - //$nicknameplain = "@".$orig_post["contact_nick"]; - + $condition = ['uri' => $item["thr-parent"], 'uid' => local_user()]; + $orig_post = Item::selectFirst(['author-link', 'uri'], $condition); + if (DBM::is_result($orig_post)) { $nick = preg_replace("=https?://(.*)/(.*)=ism", "$2", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nick . "[/url]"; @@ -743,7 +730,7 @@ function statusnet_cron(App $a, $b) logger('statusnet: cron_start'); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'mirror_posts' AND `v` = '1' ORDER BY RAND() "); - if (count($r)) { + if (DBM::is_result($r)) { foreach ($r as $rr) { logger('statusnet: fetching for user ' . $rr['uid']); statusnet_fetchtimeline($a, $rr['uid']); @@ -758,11 +745,11 @@ function statusnet_cron(App $a, $b) $abandon_limit = date(DateTimeFormat::MYSQL, time() - $abandon_days * 86400); $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` ORDER BY RAND()"); - if (count($r)) { + if (DBM::is_result($r)) { foreach ($r as $rr) { if ($abandon_days != 0) { $user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit); - if (!count($user)) { + if (!DBM::is_result($user)) { logger('abandoned account: timeline from user ' . $rr['uid'] . ' will not be imported'); continue; } @@ -915,16 +902,16 @@ function statusnet_fetch_contact($uid, $contact, $create_user) $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' AND `network` = '%s'LIMIT 1", intval($uid), dbesc(normalise_link($contact->statusnet_profile_url)), dbesc(NETWORK_STATUSNET)); - if (!count($r) && !$create_user) { + if (!DBM::is_result($r) && !$create_user) { return 0; } - if (count($r) && ($r[0]["readonly"] || $r[0]["blocked"])) { + if (DBM::is_result($r) && ($r[0]["readonly"] || $r[0]["blocked"])) { logger("statusnet_fetch_contact: Contact '" . $r[0]["nick"] . "' is blocked or readonly.", LOGGER_DEBUG); return -1; } - if (!count($r)) { + if (!DBM::is_result($r)) { // create contact record q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`, @@ -954,7 +941,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) intval($uid), dbesc(NETWORK_STATUSNET)); - if (!count($r)) { + if (!DBM::is_result($r)) { return false; } @@ -1038,7 +1025,7 @@ function statusnet_fetchuser(App $a, $uid, $screen_name = "", $user_id = "") $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid)); - if (count($r)) { + if (DBM::is_result($r)) { $self = $r[0]; } else { return; @@ -1093,7 +1080,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex intval($uid) ); - if (count($r)) { + if (DBM::is_result($r)) { return []; } @@ -1107,7 +1094,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex dbesc($parent), intval($uid) ); - if (count($r)) { + if (DBM::is_result($r)) { $postarray['thr-parent'] = $r[0]["uri"]; $postarray['parent-uri'] = $r[0]["parent-uri"]; $postarray['parent'] = $r[0]["parent"]; @@ -1117,7 +1104,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex dbesc($parent), intval($uid) ); - if (count($r)) { + if (DBM::is_result($r)) { $postarray['thr-parent'] = $r[0]['uri']; $postarray['parent-uri'] = $r[0]['parent-uri']; $postarray['parent'] = $r[0]['parent']; @@ -1136,7 +1123,7 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid)); - if (count($r)) { + if (DBM::is_result($r)) { $contactid = $r[0]["id"]; $postarray['owner-name'] = $r[0]["name"]; @@ -1214,75 +1201,6 @@ function statusnet_createpost(App $a, $uid, $post, $self, $create_user, $only_ex return $postarray; } -function statusnet_checknotification(App $a, $uid, $own_url, $top_item, $postarray) -{ - // This function necer worked and need cleanup - $user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", - intval($uid) - ); - - if (!count($user)) { - return; - } - - // Is it me? - if (link_compare($user[0]["url"], $postarray['author-link'])) { - return; - } - - $own_user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1", - intval($uid), - dbesc($own_url) - ); - - if (!count($own_user)) { - return; - } - - // Is it me from GNU Social? - if (link_compare($own_user[0]["url"], $postarray['author-link'])) { - return; - } - - $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0", - dbesc($postarray['parent-uri']), - intval($uid) - ); - - if (count($myconv)) { - foreach ($myconv as $conv) { - // now if we find a match, it means we're in this conversation - if (!link_compare($conv['author-link'], $user[0]["url"]) && !link_compare($conv['author-link'], $own_user[0]["url"])) { - continue; - } - - require_once 'include/enotify.php'; - - $conv_parent = $conv['parent']; - - notification([ - 'type' => NOTIFY_COMMENT, - 'notify_flags' => $user[0]['notify-flags'], - 'language' => $user[0]['language'], - 'to_name' => $user[0]['username'], - 'to_email' => $user[0]['email'], - 'uid' => $user[0]['uid'], - 'item' => $postarray, - 'link' => $a->get_baseurl() . '/display/' . urlencode(Item::getGuidById($top_item)), - 'source_name' => $postarray['author-name'], - 'source_link' => $postarray['author-link'], - 'source_photo' => $postarray['author-avatar'], - 'verb' => ACTIVITY_POST, - 'otype' => 'item', - 'parent' => $conv_parent, - ]); - - // only send one notification - break; - } - } -} - function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) { $conversations = []; @@ -1309,7 +1227,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) intval($own_contact), intval($uid)); - if (count($r)) { + if (DBM::is_result($r)) { $nick = $r[0]["nick"]; } else { logger("statusnet_fetchhometimeline: Own GNU Social contact not found for user " . $uid, LOGGER_DEBUG); @@ -1319,7 +1237,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid)); - if (count($r)) { + if (DBM::is_result($r)) { $self = $r[0]; } else { logger("statusnet_fetchhometimeline: Own contact not found for user " . $uid, LOGGER_DEBUG); @@ -1328,7 +1246,7 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) $u = q("SELECT * FROM user WHERE uid = %d LIMIT 1", intval($uid)); - if (!count($u)) { + if (!DBM::is_result($u)) { logger("statusnet_fetchhometimeline: Own user not found for user " . $uid, LOGGER_DEBUG); return; } @@ -1395,10 +1313,6 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) $postarray["id"] = $item; logger('statusnet_fetchhometimeline: User ' . $self["nick"] . ' posted home timeline item ' . $item); - - if ($item && !function_exists("check_item_notification")) { - statusnet_checknotification($a, $uid, $nick, $item, $postarray); - } } } } @@ -1447,42 +1361,8 @@ function statusnet_fetchhometimeline(App $a, $uid, $mode = 1) } $item = Item::insert($postarray); - $postarray["id"] = $item; logger('statusnet_fetchhometimeline: User ' . $self["nick"] . ' posted mention timeline item ' . $item); - - if ($item && function_exists("check_item_notification")) { - check_item_notification($item, $uid, NOTIFY_TAGSELF); - } - } - - $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", - dbesc($postarray['uri']), - intval($uid) - ); - if (count($r)) { - $item = $r[0]['id']; - $parent_id = $r[0]['parent']; - } - - if (($item != 0) && !function_exists("check_item_notification")) { - require_once 'include/enotify.php'; - notification([ - 'type' => NOTIFY_TAGSELF, - 'notify_flags' => $u[0]['notify-flags'], - 'language' => $u[0]['language'], - 'to_name' => $u[0]['username'], - 'to_email' => $u[0]['email'], - 'uid' => $u[0]['uid'], - 'item' => $postarray, - 'link' => $a->get_baseurl() . '/display/' . urlencode(Item::getGuidById($item)), - 'source_name' => $postarray['author-name'], - 'source_link' => $postarray['author-link'], - 'source_photo' => $postarray['author-avatar'], - 'verb' => ACTIVITY_TAG, - 'otype' => 'item', - 'parent' => $parent_id, - ]); } } } @@ -1518,10 +1398,6 @@ function statusnet_complete_conversation(App $a, $uid, $self, $create_user, $nic $postarray["id"] = $item; logger('statusnet_complete_conversation: User ' . $self["nick"] . ' posted home timeline item ' . $item); - - if ($item && !function_exists("check_item_notification")) { - statusnet_checknotification($a, $uid, $nick, $item, $postarray); - } } } } @@ -1660,7 +1536,7 @@ function statusnet_fetch_own_contact(App $a, $uid) } else { $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1", intval($uid), dbesc($own_url)); - if (count($r)) { + if (DBM::is_result($r)) { $contact_id = $r[0]["id"]; } else { PConfig::delete($uid, 'statusnet', 'own_url'); diff --git a/twitter/twitter.php b/twitter/twitter.php index 51e87335b..3e2d90d72 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -453,16 +453,13 @@ function twitter_post_hook(App $a, &$b) return; } - $r = q("SELECT * FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1", - dbesc($b["thr-parent"]), - intval($b["uid"])); - - if (!DBM::is_result($r)) { + $condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]]; + $orig_post = Item::selectFirst([], $condition); + if (!DBM::is_result($orig_post)) { logger("twitter_post_hook: no parent found " . $b["thr-parent"]); return; } else { $iscomment = true; - $orig_post = $r[0]; } @@ -760,13 +757,9 @@ function twitter_prepare_body(App $a, &$b) $item = $b["item"]; $item["plink"] = $a->get_baseurl() . "/display/" . $a->user["nickname"] . "/" . $item["parent"]; - $r = q("SELECT `author-link` FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1", - dbesc($item["thr-parent"]), - intval(local_user())); - - if (DBM::is_result($r)) { - $orig_post = $r[0]; - + $condition = ['uri' => $item["thr-parent"], 'uid' => local_user()]; + $orig_post = Item::selectFirst(['author-link'], $condition); + if (DBM::is_result($orig_post)) { $nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]"; $nicknameplain = "@" . $nicknameplain; @@ -807,7 +800,7 @@ function twitter_do_mirrorpost(App $a, $uid, $post) $datarray["profile_uid"] = $uid; $datarray["extid"] = NETWORK_TWITTER; $datarray['message_id'] = Item::newURI($uid, NETWORK_TWITTER . ":" . $post->id); - $datarray['object'] = json_encode($post); + // $datarray['object'] = json_encode($post); // Activate for debugging $datarray["title"] = ""; if (is_object($post->retweeted_status)) { @@ -1326,7 +1319,7 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis $postarray['uid'] = $uid; $postarray['wall'] = 0; $postarray['uri'] = "twitter::" . $post->id_str; - $postarray['object'] = json_encode($post); + // $postarray['object'] = json_encode($post); // Activate for debugging // Don't import our own comments $r = q("SELECT * FROM `item` WHERE `extid` = '%s' AND `uid` = %d LIMIT 1", @@ -1492,75 +1485,6 @@ function twitter_createpost(App $a, $uid, $post, $self, $create_user, $only_exis return $postarray; } -function twitter_checknotification(App $a, $uid, $own_id, $top_item, $postarray) -{ - /// TODO: this whole function doesn't seem to work. Needs complete check - $user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", - intval($uid) - ); - - if (!DBM::is_result($user)) { - return; - } - - // Is it me? - if (link_compare($user[0]["url"], $postarray['author-link'])) { - return; - } - - $own_user = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1", - intval($uid), - dbesc("twitter::".$own_id) - ); - - if (!DBM::is_result($own_user)) { - return; - } - - // Is it me from twitter? - if (link_compare($own_user[0]["url"], $postarray['author-link'])) { - return; - } - - $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0", - dbesc($postarray['parent-uri']), - intval($uid) - ); - - if (DBM::is_result($myconv)) { - foreach ($myconv as $conv) { - // now if we find a match, it means we're in this conversation - if (!link_compare($conv['author-link'], $user[0]["url"]) && !link_compare($conv['author-link'], $own_user[0]["url"])) { - continue; - } - - require_once 'include/enotify.php'; - - $conv_parent = $conv['parent']; - - notification([ - 'type' => NOTIFY_COMMENT, - 'notify_flags' => $user[0]['notify-flags'], - 'language' => $user[0]['language'], - 'to_name' => $user[0]['username'], - 'to_email' => $user[0]['email'], - 'uid' => $user[0]['uid'], - 'item' => $postarray, - 'link' => $a->get_baseurl() . '/display/' . urlencode(Item::getGuidById($top_item)), - 'source_name' => $postarray['author-name'], - 'source_link' => $postarray['author-link'], - 'source_photo' => $postarray['author-avatar'], - 'verb' => ACTIVITY_POST, - 'otype' => 'item', - 'parent' => $conv_parent, - ]); - - // only send one notification - break; - } - } -} - function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, $self, $own_id) { logger("twitter_fetchparentposts: Fetching for user " . $uid . " and post " . $post->id_str, LOGGER_DEBUG); @@ -1615,10 +1539,6 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, $postarray["id"] = $item; logger('twitter_fetchparentpost: User ' . $self["nick"] . ' posted parent timeline item ' . $item); - - if ($item && !function_exists("check_item_notification")) { - twitter_checknotification($a, $uid, $own_id, $item, $postarray); - } } } } @@ -1750,10 +1670,6 @@ function twitter_fetchhometimeline(App $a, $uid) $postarray["id"] = $item; logger('twitter_fetchhometimeline: User ' . $self["nick"] . ' posted home timeline item ' . $item); - - if ($item && !function_exists("check_item_notification")) { - twitter_checknotification($a, $uid, $own_id, $item, $postarray); - } } } PConfig::set($uid, 'twitter', 'lasthometimelineid', $lastid); @@ -1804,50 +1720,8 @@ function twitter_fetchhometimeline(App $a, $uid) } $item = Item::insert($postarray); - $postarray["id"] = $item; - - if ($item && function_exists("check_item_notification")) { - check_item_notification($item, $uid, NOTIFY_TAGSELF); - } - - if (!isset($postarray["parent"]) || ($postarray["parent"] == 0)) { - $postarray["parent"] = $item; - } logger('twitter_fetchhometimeline: User ' . $self["nick"] . ' posted mention timeline item ' . $item); - - if ($item == 0) { - $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", - dbesc($postarray['uri']), - intval($uid) - ); - if (DBM::is_result($r)) { - $item = $r[0]['id']; - $parent_id = $r[0]['parent']; - } - } else { - $parent_id = $postarray['parent']; - } - - if (($item != 0) && !function_exists("check_item_notification")) { - require_once 'include/enotify.php'; - notification([ - 'type' => NOTIFY_TAGSELF, - 'notify_flags' => $u[0]['notify-flags'], - 'language' => $u[0]['language'], - 'to_name' => $u[0]['username'], - 'to_email' => $u[0]['email'], - 'uid' => $u[0]['uid'], - 'item' => $postarray, - 'link' => $a->get_baseurl() . '/display/' . urlencode(Item::getGuidById($item)), - 'source_name' => $postarray['author-name'], - 'source_link' => $postarray['author-link'], - 'source_photo' => $postarray['author-avatar'], - 'verb' => ACTIVITY_TAG, - 'otype' => 'item', - 'parent' => $parent_id - ]); - } } } diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index 3aaf1d309..dd461ea49 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -33,6 +33,7 @@ use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Model\User; +use Friendica\Model\Item; function windowsphonepush_install() { @@ -196,19 +197,19 @@ function windowsphonepush_cron() $senditemtext = PConfig::get($rr['uid'], 'windowsphonepush', 'senditemtext'); if ($senditemtext == 1) { // load item with the max id - $item = q("SELECT `author-name` as author, `body` as body FROM `item` where `id` = %d", intval($count[0]['max'])); + $item = Item::selectFirst(['author-name', 'body'], ['id' => $count[0]['max']]); // as user allows to send the item, we want to show the sender of the item in the toast // toasts are limited to one line, therefore place is limited - author shall be in // max. 15 chars (incl. dots); author is displayed in bold font - $author = $item[0]['author']; + $author = $item['author-name']; $author = ((strlen($author) > 12) ? substr($author, 0, 12) . "..." : $author); // normally we show the body of the item, however if it is an url or an image we cannot // show this in the toast (only test), therefore changing to an alternate text // Otherwise BBcode-Tags will be eliminated and plain text cutted to 140 chars (incl. dots) // BTW: information only possible in English - $body = $item[0]['body']; + $body = $item['body']; if (substr($body, 0, 4) == "[url") { $body = "URL/Image ..."; } else {