Store tags for Diaspora - shorten tags when needed
This commit is contained in:
parent
67a67200a7
commit
6fa43ffa71
|
@ -609,6 +609,8 @@ class Processor
|
||||||
|
|
||||||
if (empty($fields['name'])) {
|
if (empty($fields['name'])) {
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
$fields['name'] = substr($fields['name'], 0, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($tag['href'] && ($tag['href'] != $tag['name']))) {
|
if (!empty($tag['href'] && ($tag['href'] != $tag['name']))) {
|
||||||
|
|
|
@ -1833,7 +1833,7 @@ class Diaspora
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = ['uri-id' => $uriid, 'name' => $person['addr'], 'url' => $person['url']];
|
$fields = ['uri-id' => $uriid, 'name' => substr($person['addr'], 0, 64), 'url' => $person['url']];
|
||||||
|
|
||||||
if ($match[1] == Term::TAG_CHARACTER[Term::MENTION]) {
|
if ($match[1] == Term::TAG_CHARACTER[Term::MENTION]) {
|
||||||
$fields['type'] = Term::MENTION;
|
$fields['type'] = Term::MENTION;
|
||||||
|
@ -1850,6 +1850,25 @@ class Diaspora
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function storeTags(int $uriid, string $body)
|
||||||
|
{
|
||||||
|
$tags = BBCode::getTags($body);
|
||||||
|
if (empty($tags)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
if ((substr($tag, 0, 1) != Term::TAG_CHARACTER[Term::HASHTAG]) || (strlen($tag) <= 1)) {
|
||||||
|
Logger::info('Skip tag', ['uriid' => $uriid, 'tag' => $tag]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields = ['uri-id' => $uriid, 'name' => substr($tag, 1, 64), 'type' => Term::HASHTAG];
|
||||||
|
DBA::insert('tag', $fields, true);
|
||||||
|
Logger::info('Stored tag', ['uriid' => $uriid, 'tag' => $tag, 'fields' => $fields]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes an incoming comment
|
* Processes an incoming comment
|
||||||
*
|
*
|
||||||
|
@ -1939,13 +1958,14 @@ class Diaspora
|
||||||
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
|
$datarray["changed"] = $datarray["created"] = $datarray["edited"] = $created_at;
|
||||||
|
|
||||||
$datarray["plink"] = self::plink($author, $guid, $parent_item['guid']);
|
$datarray["plink"] = self::plink($author, $guid, $parent_item['guid']);
|
||||||
|
|
||||||
self::storeMentions($datarray['uri-id'], $text);
|
|
||||||
|
|
||||||
$body = Markdown::toBBCode($text);
|
$body = Markdown::toBBCode($text);
|
||||||
|
|
||||||
$datarray["body"] = self::replacePeopleGuid($body, $person["url"]);
|
$datarray["body"] = self::replacePeopleGuid($body, $person["url"]);
|
||||||
|
|
||||||
|
self::storeMentions($datarray['uri-id'], $text);
|
||||||
|
self::storeTags($datarray['uri-id'], $datarray["body"]);
|
||||||
|
|
||||||
self::fetchGuid($datarray);
|
self::fetchGuid($datarray);
|
||||||
|
|
||||||
// If we are the origin of the parent we store the original data.
|
// If we are the origin of the parent we store the original data.
|
||||||
|
@ -3017,10 +3037,11 @@ class Diaspora
|
||||||
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
$datarray["protocol"] = Conversation::PARCEL_DIASPORA;
|
||||||
$datarray["source"] = $xml;
|
$datarray["source"] = $xml;
|
||||||
|
|
||||||
self::storeMentions($datarray['uri-id'], $text);
|
|
||||||
|
|
||||||
$datarray["body"] = self::replacePeopleGuid($body, $contact["url"]);
|
$datarray["body"] = self::replacePeopleGuid($body, $contact["url"]);
|
||||||
|
|
||||||
|
self::storeMentions($datarray['uri-id'], $text);
|
||||||
|
self::storeTags($datarray['uri-id'], $datarray["body"]);
|
||||||
|
|
||||||
if ($provider_display_name != "") {
|
if ($provider_display_name != "") {
|
||||||
$datarray["app"] = $provider_display_name;
|
$datarray["app"] = $provider_display_name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user