]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Tag.php
Use the cached activity function
[friendica.git] / src / Model / Tag.php
index 538cedfb6b29b639890555816ec7dbef004dc383..435dfda7cbf2711c3775e83321a4e474b92c177f 100644 (file)
@@ -156,7 +156,7 @@ class Tag
 
                DBA::insert('post-tag', $fields, Database::INSERT_IGNORE);
 
-               Logger::info('Stored tag/mention', ['uri-id' => $uriId, 'tag-id' => $tagid, 'contact-id' => $cid, 'name' => $name, 'type' => $type, 'callstack' => System::callstack(8)]);
+               Logger::debug('Stored tag/mention', ['uri-id' => $uriId, 'tag-id' => $tagid, 'contact-id' => $cid, 'name' => $name, 'type' => $type, 'callstack' => System::callstack(8)]);
        }
 
        /**
@@ -243,9 +243,8 @@ class Tag
                        return $tid;
                }
 
-               // Also log type and tag id
+               // Also log type
                $fields['type'] = $type;
-               $fields['tid'] = $tid;
 
                Logger::error('No tag id created', $fields);
                return 0;
@@ -390,7 +389,7 @@ class Tag
                        return;
                }
 
-               Logger::info('Removing tag/mention', ['uri-id' => $uriId, 'tid' => $tag['tid'], 'name' => $name, 'url' => $url, 'callstack' => System::callstack(8)]);
+               Logger::debug('Removing tag/mention', ['uri-id' => $uriId, 'tid' => $tag['tid'], 'name' => $name, 'url' => $url, 'callstack' => System::callstack(8)]);
                DBA::delete('post-tag', ['uri-id' => $uriId, 'type' => $type, 'tid' => $tag['tid'], 'cid' => $tag['cid']]);
        }
 
@@ -472,6 +471,26 @@ class Tag
                return DBA::selectToArray('tag-view', ['type', 'name', 'url', 'tag-type'], $condition);
        }
 
+       /**
+        * Checks if the given url is mentioned in the post
+        *
+        * @param integer $uriId
+        * @param string $url
+        * @param array $type
+        *
+        * @return boolean
+        */
+       public static function isMentioned(int $uriId, string $url, array $type = [self::MENTION, self::EXCLUSIVE_MENTION]): bool
+       {
+               $tags = self::getByURIId($uriId, $type);
+               foreach ($tags as $tag) {
+                       if (Strings::compareLink($url, $tag['url'])) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
        /**
         * Return a string with all tags and mentions
         *
@@ -546,7 +565,7 @@ class Tag
                                        break;
 
                                default:
-                                       Logger:warning('Unknown tag type found', $tag);
+                                       Logger::warning('Unknown tag type found', $tag);
                        }
                }
                DBA::close($taglist);