Merge branch 'no-term3' into no-term2

This commit is contained in:
Michael 2020-05-05 16:09:50 +00:00
commit 3d4ace7a9d
6 changed files with 13 additions and 80 deletions

View 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']);

View file

@ -1996,7 +1996,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"]];

View 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);
}
}
}