]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/DFRN.php
Merge remote-tracking branch 'upstream/develop' into term2tag
[friendica.git] / src / Protocol / DFRN.php
index cbd7574158da5ef45edf383c0f5190230ed2bbdc..57edfb02b70c9f26f09429598ad8708db569f70d 100644 (file)
@@ -24,9 +24,7 @@ namespace Friendica\Protocol;
 use DOMDocument;
 use DOMXPath;
 use Friendica\App\BaseURL;
-use Friendica\Content\OEmbed;
 use Friendica\Content\Text\BBCode;
-use Friendica\Content\Text\HTML;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
@@ -37,10 +35,12 @@ use Friendica\Model\Conversation;
 use Friendica\Model\Event;
 use Friendica\Model\GContact;
 use Friendica\Model\Item;
+use Friendica\Model\ItemURI;
 use Friendica\Model\Mail;
 use Friendica\Model\Notify\Type;
 use Friendica\Model\PermissionSet;
 use Friendica\Model\Profile;
+use Friendica\Model\Term;
 use Friendica\Model\User;
 use Friendica\Network\Probe;
 use Friendica\Util\Crypto;
@@ -49,8 +49,6 @@ use Friendica\Util\Images;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
 use Friendica\Util\XML;
-use HTMLPurifier;
-use HTMLPurifier_Config;
 
 /**
  * This class contain functions to create and send DFRN XML files
@@ -252,8 +250,8 @@ class DFRN
                        $sql_post_table = sprintf(
                                "INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
                                DBA::escape(Strings::protectSprintf($category)),
-                               intval(TERM_OBJ_POST),
-                               intval(TERM_CATEGORY),
+                               intval(Term::OBJECT_TYPE_POST),
+                               intval(Term::CATEGORY),
                                intval($owner_id)
                        );
                }
@@ -2407,6 +2405,8 @@ class DFRN
 
                $item["guid"] = XML::getFirstNodeValue($xpath, "dfrn:diaspora_guid/text()", $entry);
 
+               $item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
+
                // 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 != "") {
@@ -2460,6 +2460,27 @@ 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]);
                                        }
                                }
                        }