Tags are now transmitted as expected

This commit is contained in:
Michael 2018-10-03 18:27:01 +00:00
parent a9a1ac808b
commit 221e197658

View file

@ -35,7 +35,6 @@ use Friendica\Object\Image;
* - Undo Announce * - Undo Announce
* *
* General: * General:
* - nsfw (sensitive)
* - Queueing unsucessful deliveries * - Queueing unsucessful deliveries
*/ */
class Transmitter class Transmitter
@ -582,16 +581,20 @@ class Transmitter
{ {
$tags = []; $tags = [];
$terms = Term::tagArrayFromItemId($item['id'], TERM_MENTION); $terms = Term::tagArrayFromItemId($item['id']);
foreach ($terms as $term) { foreach ($terms as $term) {
$contact = Contact::getDetailsByURL($term['url']); if ($term['type'] == TERM_HASHTAG) {
if (!empty($contact['addr'])) { $tags[] = ['type' => 'Hashtag', 'href' => $term['url'], 'name' => '#' . $term['term']];
$mention = '@' . $contact['addr']; } elseif ($term['type'] == TERM_MENTION) {
} else { $contact = Contact::getDetailsByURL($term['url']);
$mention = '@' . $term['url']; if (!empty($contact['addr'])) {
} $mention = '@' . $contact['addr'];
} else {
$mention = '@' . $term['url'];
}
$tags[] = ['type' => 'Mention', 'href' => $term['url'], 'name' => $mention]; $tags[] = ['type' => 'Mention', 'href' => $term['url'], 'name' => $mention];
}
} }
return $tags; return $tags;
} }
@ -684,6 +687,12 @@ class Transmitter
return $context_uri; return $context_uri;
} }
private static function fetchSensitive($item_id)
{
$condition = ['otype' => TERM_OBJ_POST, 'oid' => $item_id, 'type' => TERM_HASHTAG, 'term' => 'nsfw'];
return DBA::exists('term', $condition);
}
/** /**
* @brief Creates a note/article object array * @brief Creates a note/article object array
* *
@ -729,7 +738,7 @@ class Transmitter
$data['url'] = $item['plink']; $data['url'] = $item['plink'];
$data['attributedTo'] = $item['author-link']; $data['attributedTo'] = $item['author-link'];
$data['actor'] = $item['author-link']; $data['actor'] = $item['author-link'];
$data['sensitive'] = false; // - Query NSFW $data['sensitive'] = self::fetchSensitive($item['id']);
$data['context'] = self::fetchContextURLForItem($item); $data['context'] = self::fetchContextURLForItem($item);
if (!empty($item['title'])) { if (!empty($item['title'])) {