Improved support for Mastodon style content warnings

This commit is contained in:
Michael 2022-03-06 11:49:55 +00:00
parent e351122cc5
commit 903bc9b679
4 changed files with 78 additions and 55 deletions

View file

@ -1076,6 +1076,13 @@ class Item
unset($item['causer-id']);
}
if (in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN])) {
$content_warning = BBCode::getAbstract($item['body'], Protocol::ACTIVITYPUB);
if (!empty($content_warning) && empty($item['content-warning'])) {
$item['content-warning'] = $content_warning;
}
}
Post::insert($item['uri-id'], $item);
if ($item['gravity'] == GRAVITY_PARENT) {
@ -1238,7 +1245,7 @@ class Item
$self_contact = Contact::selectFirst(['id'], ['uid' => $item['uid'], 'self' => true]);
$self = !empty($self_contact) ? $self_contact['id'] : 0;
$cid = Contact::getIdForURL($author['url'], $item['uid']);
if (empty($cid) || (!Contact::isSharing($cid, $item['uid']) && ($cid != $self))) {
Logger::info('The resharer is not a following contact: quit', ['resharer' => $author['url'], 'uid' => $item['uid'], 'cid' => $cid]);