X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=twitter%2Ftwitter.php;h=e1265d5d3cb5b5b8c311b7ee888eb5904dfa078f;hb=61d95f53021ac9ccb73cba0c89107cc6bac7f14b;hp=68ca7faf7b42f97f517239f8a8226d219584b0c2;hpb=6a4dd6ed4b4dcb3fee1ca193eb81ac3b5398e77a;p=friendica-addons.git diff --git a/twitter/twitter.php b/twitter/twitter.php index 68ca7faf..e1265d5d 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -81,7 +81,6 @@ use Friendica\Model\Contact; use Friendica\Model\Conversation; use Friendica\Model\Group; use Friendica\Model\Item; -use Friendica\Model\ItemContent; use Friendica\Model\ItemURI; use Friendica\Model\Post; use Friendica\Model\Tag; @@ -411,7 +410,7 @@ function twitter_hook_fork(App $a, array &$b) if (DI::pConfig()->get($post['uid'], 'twitter', 'import')) { // Don't fork if it isn't a reply to a twitter post - if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::TWITTER])) { + if (($post['parent'] != $post['id']) && !Post::exists(['id' => $post['parent'], 'network' => Protocol::TWITTER])) { Logger::notice('No twitter parent found', ['item' => $post['id']]); $b['execute'] = false; return; @@ -559,7 +558,7 @@ function twitter_post_hook(App $a, array &$b) } $condition = ['uri' => $b["thr-parent"], 'uid' => $b["uid"]]; - $thr_parent = Item::selectFirst(['uri', 'extid', 'author-link', 'author-nick', 'author-network'], $condition); + $thr_parent = Post::selectFirst(['uri', 'extid', 'author-link', 'author-nick', 'author-network'], $condition); if (!DBA::isResult($thr_parent)) { Logger::warning('No parent found', ['thr-parent' => $b["thr-parent"]]); return; @@ -666,7 +665,7 @@ function twitter_post_hook(App $a, array &$b) $b['body'] = twitter_update_mentions($b['body']); - $msgarr = ItemContent::getPlaintextPost($b, $max_char, true, BBCode::TWITTER); + $msgarr = Plaintext::getPost($b, $max_char, true, BBCode::TWITTER); Logger::info('Got plaintext', ['id' => $b['id'], 'message' => $msgarr]); $msg = $msgarr["text"]; @@ -851,8 +850,8 @@ function twitter_expire(App $a) Logger::notice('Start deleting expired posts'); - $r = Item::select(['id', 'guid'], ['deleted' => true, 'network' => Protocol::TWITTER]); - while ($row = DBA::fetch($r)) { + $r = Post::select(['id', 'guid'], ['deleted' => true, 'network' => Protocol::TWITTER]); + while ($row = Post::fetch($r)) { Logger::info('[twitter] Delete expired item', ['id' => $row['id'], 'guid' => $row['guid'], 'callstack' => \Friendica\Core\System::callstack()]); DBA::delete('item', ['id' => $row['id']]); } @@ -885,7 +884,7 @@ function twitter_prepare_body(App $a, array &$b) $item["plink"] = DI::baseUrl()->get() . "/display/" . $item["guid"]; $condition = ['uri' => $item["thr-parent"], 'uid' => local_user()]; - $orig_post = Item::selectFirst(['author-link'], $condition); + $orig_post = Post::selectFirst(['author-link'], $condition); if (DBA::isResult($orig_post)) { $nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]); $nickname = "@[url=" . $orig_post["author-link"] . "]" . $nicknameplain . "[/url]"; @@ -896,7 +895,7 @@ function twitter_prepare_body(App $a, array &$b) } } - $msgarr = ItemContent::getPlaintextPost($item, $max_char, true, BBCode::TWITTER); + $msgarr = Plaintext::getPost($item, $max_char, true, BBCode::TWITTER); $msg = $msgarr["text"]; if (isset($msgarr["url"]) && ($msgarr["type"] != "photo")) { @@ -1584,13 +1583,14 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl $postarray['uri'] = "twitter::" . $post->id_str; $postarray['protocol'] = Conversation::PARCEL_TWITTER; $postarray['source'] = json_encode($post); + $postarray['direction'] = Conversation::PULL; if (empty($uriid)) { $uriid = $postarray['uri-id'] = ItemURI::insert(['uri' => $postarray['uri']]); } // Don't import our own comments - if (Item::exists(['extid' => $postarray['uri'], 'uid' => $uid])) { + if (Post::exists(['extid' => $postarray['uri'], 'uid' => $uid])) { Logger::info('Item found', ['extid' => $postarray['uri']]); return []; } @@ -1600,9 +1600,9 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl if ($post->in_reply_to_status_id_str != "") { $thr_parent = "twitter::" . $post->in_reply_to_status_id_str; - $item = Item::selectFirst(['uri'], ['uri' => $thr_parent, 'uid' => $uid]); + $item = Post::selectFirst(['uri'], ['uri' => $thr_parent, 'uid' => $uid]); if (!DBA::isResult($item)) { - $item = Item::selectFirst(['uri'], ['extid' => $thr_parent, 'uid' => $uid]); + $item = Post::selectFirst(['uri'], ['extid' => $thr_parent, 'uid' => $uid]); } if (DBA::isResult($item)) { @@ -1724,6 +1724,7 @@ function twitter_createpost(App $a, $uid, $post, array $self, $create_user, $onl $postarray['thr-parent'] = $retweet['uri']; } else { $retweet['source'] = $postarray['source']; + $retweet['direction'] = $postarray['direction']; $retweet['private'] = $postarray['private']; $retweet['allow_cid'] = $postarray['allow_cid']; $retweet['contact-id'] = $postarray['contact-id']; @@ -1800,7 +1801,7 @@ function twitter_fetchparentposts(App $a, $uid, $post, TwitterOAuth $connection, break; } - if (Item::exists(['uri' => 'twitter::' . $post->id_str, 'uid' => $uid])) { + if (Post::exists(['uri' => 'twitter::' . $post->id_str, 'uid' => $uid])) { break; }