]> git.mxchange.org Git - friendica.git/commitdiff
Removed usage of "tag" field
authorMichael <heluecht@pirati.ca>
Tue, 5 May 2020 05:11:59 +0000 (05:11 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 5 May 2020 05:11:59 +0000 (05:11 +0000)
mod/photos.php
src/Model/Contact.php
src/Protocol/ActivityPub/Processor.php
src/Protocol/DFRN.php
src/Protocol/OStatus.php
src/Worker/Notifier.php

index 50210d686908dec53a7669df13419e629bbb1947..8f968d0c08d74f6f19eb142223cfb66d8137b3b0 100644 (file)
@@ -425,13 +425,11 @@ function photos_post(App $a)
                        $item = Item::selectFirst(['tag', 'inform', 'uri-id'], ['id' => $item_id, 'uid' => $page_owner_uid]);
 
                        if (DBA::isResult($item)) {
-                               $old_tag    = $item['tag'];
                                $old_inform = $item['inform'];
                        }
                }
 
                if (strlen($rawtags)) {
-                       $str_tags = '';
                        $inform   = '';
 
                        // if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
@@ -513,15 +511,10 @@ function photos_post(App $a)
                                                        if (!empty($contact)) {
                                                                $taginfo[] = [$newname, $profile, $notify, $contact, '@[url=' . str_replace(',', '%2c', $profile) . ']' . $newname . '[/url]'];
                                                        } else {
-                                                               $taginfo[] = [$newname, $profile, $notify, null, $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]'];
-                                                       }
-
-                                                       if (strlen($str_tags)) {
-                                                               $str_tags .= ',';
+                                                               $taginfo[] = [$newname, $profile, $notify, null, '@[url=' . $profile . ']' . $newname . '[/url]'];
                                                        }
 
                                                        $profile = str_replace(',', '%2c', $profile);
-                                                       $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]';
 
                                                        if (!empty($item['uri-id'])) {
                                                                Tag::store($item['uri-id'], Tag::MENTION, $newname, $profile);
@@ -529,7 +522,6 @@ function photos_post(App $a)
                                                }
                                        } elseif (strpos($tag, '#') === 0) {
                                                $tagname = substr($tag, 1);
-                                               $str_tags .= '#[url=' . DI::baseUrl() . "/search?tag=" . $tagname . ']' . $tagname . '[/url],';
                                                if (!empty($item['uri-id'])) {
                                                        Tag::store($item['uri-id'], Tag::HASHTAG, $tagname);
                                                }
@@ -537,19 +529,13 @@ function photos_post(App $a)
                                }
                        }
 
-                       $newtag = $old_tag ?? '';
-                       if (strlen($newtag) && strlen($str_tags)) {
-                               $newtag .= ',';
-                       }
-                       $newtag .= $str_tags;
-
                        $newinform = $old_inform ?? '';
                        if (strlen($newinform) && strlen($inform)) {
                                $newinform .= ',';
                        }
                        $newinform .= $inform;
 
-                       $fields = ['tag' => $newtag, 'inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
+                       $fields = ['inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
                        $condition = ['id' => $item_id];
                        Item::update($fields, $condition);
 
index becc80c0c3c6e09e557e77778aaf37cc59882b80..0d321189ffc2d12ad814e7c6240e8dca350e68ec 100644 (file)
@@ -847,7 +847,7 @@ class Contact
                        $item['body'] = '';
                        $item['title'] = '';
                        $item['guid'] = '';
-                       $item['tag'] = '';
+                       $item['uri-id'] = 0;
                        $item['attach'] = '';
                        $slap = OStatus::salmon($item, $user);
 
@@ -2457,7 +2457,7 @@ class Contact
                                $item['body'] = '';
                                $item['title'] = '';
                                $item['guid'] = '';
-                               $item['tag'] = '';
+                               $item['uri-id'] = 0;
                                $item['attach'] = '';
 
                                $slap = OStatus::salmon($item, $owner);
index 479d8d55c779913ddfdc7d7e524764ecab33409a..197fb2baa3e2791c46fd1ad75a661662ab94d52b 100644 (file)
@@ -79,35 +79,6 @@ class Processor
                return $body;
        }
 
-       /**
-        * Constructs a string with tags for a given tag array
-        *
-        * @param array   $tags
-        * @param boolean $sensitive
-        * @return string with tags
-        */
-       private static function constructTagString(array $tags = null, $sensitive = false)
-       {
-               if (empty($tags)) {
-                       return '';
-               }
-
-               $tag_text = '';
-               foreach ($tags as $tag) {
-                       if (in_array($tag['type'] ?? '', ['Mention', 'Hashtag'])) {
-                               if (!empty($tag_text)) {
-                                       $tag_text .= ',';
-                               }
-
-                               $tag_text .= substr($tag['name'], 0, 1) . '[url=' . $tag['href'] . ']' . substr($tag['name'], 1) . '[/url]';
-                       }
-               }
-
-               /// @todo add nsfw for $sensitive
-
-               return $tag_text;
-       }
-
        /**
         * Add attachment data to the item array
         *
@@ -263,16 +234,7 @@ class Processor
                        }
 
                        Tag::store($item['uri-id'], Tag::HASHTAG, $activity['object_content'], $activity['object_id']);
-
-                       // To-Do:
-                       // - Check if "blocktag" is set
-                       // - Check if actor is a contact
-
-                       if (!stristr($item['tag'], trim($activity['object_content']))) {
-                               $tag = $item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $activity['object_id'] . ']'. $activity['object_content'] . '[/url]';
-                               Item::update(['tag' => $tag], ['id' => $item['id']]);
-                               Logger::info('Tagged item', ['id' => $item['id'], 'tag' => $activity['object_content'], 'uri' => $activity['target_id'], 'actor' => $activity['actor']]);
-                       }
+                       Logger::info('Tagged item', ['id' => $item['id'], 'tag' => $activity['object_content'], 'uri' => $activity['target_id'], 'actor' => $activity['actor']]);
                }
        }
 
@@ -405,8 +367,6 @@ class Processor
                        $item['body'] = $content;
                }
 
-               $item['tag'] = self::constructTagString($activity['tags'], $activity['sensitive']);
-
                self::storeFromBody($item);
                self::storeTags($item['uri-id'], $activity['tags']);
 
index 5060a7d563e9bb0e159381b1b35d0424160f605e..74352906de6266f0248124d9b6608ebf0463e86e 100644 (file)
@@ -2001,7 +2001,7 @@ class DFRN
                        }
 
                        $fields = ['title' => $item['title'] ?? '', 'body' => $item['body'] ?? '',
-                                       'tag' => $item['tag'] ?? '', 'changed' => DateTimeFormat::utcNow(),
+                                       'changed' => DateTimeFormat::utcNow(),
                                        'edited' => DateTimeFormat::utc($item["edited"])];
 
                        $condition = ["`uri` = ? AND `uid` IN (0, ?)", $item["uri"], $importer["importer_uid"]];
index 8ab14c07816eae6db6626a624a251dee9fa38127..6eeadb46c373a1d3272ca3df9bd0d038cf2f4af2 100644 (file)
@@ -655,17 +655,8 @@ class OStatus
                        foreach ($categories as $category) {
                                foreach ($category->attributes as $attributes) {
                                        if ($attributes->name == 'term') {
-                                               $term = $attributes->textContent;
-                                               if (!empty($item['tag'])) {
-                                                       $item['tag'] .= ',';
-                                               } else {
-                                                       $item['tag'] = '';
-                                               }
-
-                                               $item['tag'] .= '#[url=' . DI::baseUrl() . '/search?tag=' . $term . ']' . $term . '[/url]';
-
                                                // Store the hashtag
-                                               Tag::store($item['uri-id'], Tag::HASHTAG, $term);
+                                               Tag::store($item['uri-id'], Tag::HASHTAG, $attributes->textContent);
                                        }
                                }
                        }
index 35a228fce1b1622d2fc548857fa1c6663a5c082c..09470c31851d3e37bbaf2b2829e36203853cacd9 100644 (file)
@@ -34,6 +34,7 @@ use Friendica\Model\Group;
 use Friendica\Model\Item;
 use Friendica\Model\ItemDeliveryData;
 use Friendica\Model\PushSubscriber;
+use Friendica\Model\Tag;
 use Friendica\Model\User;
 use Friendica\Network\Probe;
 use Friendica\Protocol\ActivityPub;
@@ -367,16 +368,11 @@ class Notifier
                                }
 
                                // Send a salmon notification to every person we mentioned in the post
-                               $arr = explode(',',$target_item['tag']);
-                               foreach ($arr as $x) {
-                                       //Logger::log('Checking tag '.$x, Logger::DEBUG);
-                                       $matches = null;
-                                       if (preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) {
-                                                       $probed_contact = Probe::uri($matches[1]);
-                                               if ($probed_contact["notify"] != "") {
-                                                       Logger::log('Notify mentioned user '.$probed_contact["url"].': '.$probed_contact["notify"]);
-                                                       $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
-                                               }
+                               foreach (Tag::getByURIId($target_item['uri-id'], [Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION]) as $tag) {
+                                       $probed_contact = Probe::uri($tag['url']);
+                                       if ($probed_contact["notify"] != "") {
+                                               Logger::log('Notify mentioned user '.$probed_contact["url"].': '.$probed_contact["notify"]);
+                                               $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
                                        }
                                }