mirror of
https://github.com/friendica/friendica
synced 2025-04-26 19:10:11 +00:00
Improved support for Mastodon style content warnings
This commit is contained in:
parent
e351122cc5
commit
903bc9b679
4 changed files with 78 additions and 55 deletions
|
@ -891,22 +891,26 @@ class Post
|
|||
|
||||
$owner = User::getOwnerDataById($a->getLoggedInUserId());
|
||||
|
||||
if (!Feature::isEnabled(local_user(), 'explicit_mentions')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$item = PostModel::selectFirst(['author-addr', 'uri-id', 'network', 'gravity'], ['id' => $this->getId()]);
|
||||
$item = PostModel::selectFirst(['author-addr', 'uri-id', 'network', 'gravity', 'content-warning'], ['id' => $this->getId()]);
|
||||
if (!DBA::isResult($item) || empty($item['author-addr'])) {
|
||||
// Should not happen
|
||||
return '';
|
||||
}
|
||||
|
||||
if (($item['author-addr'] != $owner['addr']) && (($item['gravity'] != GRAVITY_PARENT) || !in_array($item['network'], [Protocol::DIASPORA]))) {
|
||||
$text = '@' . $item['author-addr'] . ' ';
|
||||
if (!empty($item['content-warning']) && Feature::isEnabled(local_user(), 'add_abstract')) {
|
||||
$text = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $item['content-warning'] . "[/abstract]\n";
|
||||
} else {
|
||||
$text = '';
|
||||
}
|
||||
|
||||
if (!Feature::isEnabled(local_user(), 'explicit_mentions')) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
if (($item['author-addr'] != $owner['addr']) && (($item['gravity'] != GRAVITY_PARENT) || !in_array($item['network'], [Protocol::DIASPORA]))) {
|
||||
$text .= '@' . $item['author-addr'] . ' ';
|
||||
}
|
||||
|
||||
$terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
|
||||
foreach ($terms as $term) {
|
||||
if (!$term['url']) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue