Improved body scanning, increased length
This commit is contained in:
parent
060503eb44
commit
3ce9386cb1
4 changed files with 14 additions and 19 deletions
|
@ -69,7 +69,7 @@ class Tag
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['name' => substr($name, 0, 64), 'type' => $type];
|
$fields = ['name' => substr($name, 0, 96), 'type' => $type];
|
||||||
|
|
||||||
if (!empty($url) && ($url != $name)) {
|
if (!empty($url) && ($url != $name)) {
|
||||||
$fields['url'] = strtolower($url);
|
$fields['url'] = strtolower($url);
|
||||||
|
@ -119,25 +119,20 @@ class Tag
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store tags from the body
|
* Store tags and mentions from the body
|
||||||
*
|
*
|
||||||
* @param integer $uriid
|
* @param integer $uriid URI-Id
|
||||||
* @param string $body
|
* @param string $body Body of the post
|
||||||
|
* @param string $tags Accepted tags
|
||||||
*/
|
*/
|
||||||
public static function storeFromBody(int $uriid, string $body)
|
public static function storeFromBody(int $uriid, string $body, string $tags = '#@!')
|
||||||
{
|
{
|
||||||
$tags = BBCode::getTags($body);
|
if (!preg_match_all("/([" . $tags . "])\[url\=(.*?)\](.*?)\[\/url\]/ism", $body, $result, PREG_SET_ORDER)) {
|
||||||
if (empty($tags)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($tags as $tag) {
|
foreach ($result as $tag) {
|
||||||
if ((substr($tag, 0, 1) != self::TAG_CHARACTER[self::HASHTAG]) || (strlen($tag) <= 1)) {
|
self::storeByHash($uriid, $tag[1], $tag[3], $tag[2]);
|
||||||
Logger::info('Skip tag', ['uriid' => $uriid, 'tag' => $tag]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
self::storeByHash($uriid, '#', $tag);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2410,7 +2410,7 @@ class DFRN
|
||||||
|
|
||||||
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
|
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
|
||||||
|
|
||||||
Tag::storeFromBody($item['uri-id'], $item["body"]);
|
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"
|
// 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));
|
$dsprsig = XML::unescape(XML::getFirstNodeValue($xpath, "dfrn:diaspora_signature/text()", $entry));
|
||||||
|
|
|
@ -1938,7 +1938,7 @@ class Diaspora
|
||||||
$datarray["body"] = self::replacePeopleGuid($body, $person["url"]);
|
$datarray["body"] = self::replacePeopleGuid($body, $person["url"]);
|
||||||
|
|
||||||
self::storeMentions($datarray['uri-id'], $text);
|
self::storeMentions($datarray['uri-id'], $text);
|
||||||
Tag::storeFromBody($datarray['uri-id'], $datarray["body"]);
|
Tag::storeFromBody($datarray['uri-id'], $datarray["body"], '#');
|
||||||
|
|
||||||
self::fetchGuid($datarray);
|
self::fetchGuid($datarray);
|
||||||
|
|
||||||
|
@ -3013,7 +3013,7 @@ class Diaspora
|
||||||
$datarray["body"] = self::replacePeopleGuid($body, $contact["url"]);
|
$datarray["body"] = self::replacePeopleGuid($body, $contact["url"]);
|
||||||
|
|
||||||
self::storeMentions($datarray['uri-id'], $text);
|
self::storeMentions($datarray['uri-id'], $text);
|
||||||
Tag::storeFromBody($datarray['uri-id'], $datarray["body"]);
|
Tag::storeFromBody($datarray['uri-id'], $datarray["body"], '#');
|
||||||
|
|
||||||
if ($provider_display_name != "") {
|
if ($provider_display_name != "") {
|
||||||
$datarray["app"] = $provider_display_name;
|
$datarray["app"] = $provider_display_name;
|
||||||
|
|
|
@ -1297,7 +1297,7 @@ return [
|
||||||
"fields" => [
|
"fields" => [
|
||||||
"id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
|
"id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => ""],
|
||||||
"type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
|
"type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""],
|
||||||
"name" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => ""],
|
"name" => ["type" => "varchar(96)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
"url" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""]
|
"url" => ["type" => "varbinary(255)", "not null" => "1", "default" => "", "comment" => ""]
|
||||||
],
|
],
|
||||||
"indexes" => [
|
"indexes" => [
|
||||||
|
|
Loading…
Reference in a new issue