]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/DFRN.php
Code standards
[friendica.git] / src / Protocol / DFRN.php
index 57edfb02b70c9f26f09429598ad8708db569f70d..83010f811e073901851b8ddd8af7c42db7b71cdc 100644 (file)
@@ -40,6 +40,7 @@ use Friendica\Model\Mail;
 use Friendica\Model\Notify\Type;
 use Friendica\Model\PermissionSet;
 use Friendica\Model\Profile;
+use Friendica\Model\Tag;
 use Friendica\Model\Term;
 use Friendica\Model\User;
 use Friendica\Network\Probe;
@@ -2242,7 +2243,7 @@ class DFRN
                                $xt = XML::parseString($item["target"], false);
 
                                if ($xt->type == Activity\ObjectType::NOTE) {
-                                       $item_tag = Item::selectFirst(['id', 'tag'], ['uri' => $xt->id, 'uid' => $importer["importer_uid"]]);
+                                       $item_tag = Item::selectFirst(['id', 'uri-id', 'tag'], ['uri' => $xt->id, 'uid' => $importer["importer_uid"]]);
 
                                        if (!DBA::isResult($item_tag)) {
                                                Logger::log("Query failed to execute, no result returned in " . __FUNCTION__);
@@ -2251,6 +2252,8 @@ class DFRN
 
                                        // extract tag, if not duplicate, add to parent item
                                        if ($xo->content) {
+                                               Tag::store($item_tag['uri-id'], Tag::HASHTAG, $xo->content);
+
                                                if (!stristr($item_tag["tag"], trim($xo->content))) {
                                                        $tag = $item_tag["tag"] . (strlen($item_tag["tag"]) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]';
                                                        Item::update(['tag' => $tag], ['id' => $item_tag["id"]]);
@@ -2407,6 +2410,8 @@ class DFRN
 
                $item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
 
+               Tag::storeFromBody($item['uri-id'], $item["body"]);
+
                // We store the data from "dfrn:diaspora_signature" in a different table, this is done in "Item::insert"
                $dsprsig = XML::unescape(XML::getFirstNodeValue($xpath, "dfrn:diaspora_signature/text()", $entry));
                if ($dsprsig != "") {
@@ -2461,26 +2466,7 @@ class DFRN
 
                                                $item["tag"] .= $termhash . "[url=" . $termurl . "]" . $term . "[/url]";
 
-                                               // Store the hashtag/mention
-                                               $fields = ['uri-id' => $item['uri-id'], 'name' => substr($term, 0, 64)];
-
-                                               if ($termhash == Term::TAG_CHARACTER[Term::MENTION]) {
-                                                       $fields['type'] = Term::MENTION;
-                                               } elseif ($termhash == Term::TAG_CHARACTER[Term::EXCLUSIVE_MENTION]) {
-                                                       $fields['type'] = Term::EXCLUSIVE_MENTION;
-                                               } elseif ($termhash == Term::TAG_CHARACTER[Term::IMPLICIT_MENTION]) {
-                                                       $fields['type'] = Term::IMPLICIT_MENTION;
-                                               } elseif ($termhash == Term::TAG_CHARACTER[Term::HASHTAG]) {
-                                                       $fields['type'] = Term::HASHTAG;
-                                               }
-
-                                               if (!empty($termurl)) {
-                                                       $fields['url'] = $termurl;
-                                               }
-
-                                               DBA::insert('tag', $fields, true);
-
-                                               Logger::info('Stored tag/mention', ['uri-id' => $item['uri-id'], 'tag' => $term, 'url' => $termurl, 'hash' => $termhash, 'fields' => $fields]);
+                                               Tag::store($item['uri-id'], Tag::IMPLICIT_MENTION, $term, $termurl);
                                        }
                                }
                        }