There is now a "content-warning" field
This commit is contained in:
parent
6352aa112b
commit
5bd519efff
2
boot.php
2
boot.php
|
@ -39,7 +39,7 @@ define('FRIENDICA_PLATFORM', 'Friendica');
|
||||||
define('FRIENDICA_CODENAME', 'Asparagus');
|
define('FRIENDICA_CODENAME', 'Asparagus');
|
||||||
define('FRIENDICA_VERSION', '3.6-rc');
|
define('FRIENDICA_VERSION', '3.6-rc');
|
||||||
define('DFRN_PROTOCOL_VERSION', '2.23');
|
define('DFRN_PROTOCOL_VERSION', '2.23');
|
||||||
define('DB_UPDATE_VERSION', 1255);
|
define('DB_UPDATE_VERSION', 1256);
|
||||||
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 3.6-dev (Asparagus)
|
-- Friendica 3.6-rc (Asparagus)
|
||||||
-- DB_UPDATE_VERSION 1255
|
-- DB_UPDATE_VERSION 1256
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -466,6 +466,7 @@ CREATE TABLE IF NOT EXISTS `item` (
|
||||||
`author-link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`author-link` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`author-avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`author-avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
|
`content-warning` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`body` mediumtext COMMENT '',
|
`body` mediumtext COMMENT '',
|
||||||
`app` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
`app` varchar(255) NOT NULL DEFAULT '' COMMENT '',
|
||||||
`verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
|
`verb` varchar(100) NOT NULL DEFAULT '' COMMENT '',
|
||||||
|
|
|
@ -445,7 +445,7 @@ These Fields are not added below (yet). They are here to for bug search.
|
||||||
return "`item`.`author-id`, `item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`,
|
return "`item`.`author-id`, `item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`,
|
||||||
`item`.`owner-id`, `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`,
|
`item`.`owner-id`, `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`,
|
||||||
`item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`,
|
`item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`,
|
||||||
`item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`,
|
`item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`, `item`.`content-warning`,
|
||||||
`item`.`commented`, `item`.`created`, `item`.`edited`, `item`.`received`,
|
`item`.`commented`, `item`.`created`, `item`.`edited`, `item`.`received`,
|
||||||
`item`.`verb`, `item`.`object-type`, `item`.`postopts`, `item`.`plink`,
|
`item`.`verb`, `item`.`object-type`, `item`.`postopts`, `item`.`plink`,
|
||||||
`item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`,
|
`item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`,
|
||||||
|
|
|
@ -1182,6 +1182,11 @@ function put_item_in_cache(&$item, $update = false)
|
||||||
// I'm not sure if we should store it permanently, so we save the old value.
|
// I'm not sure if we should store it permanently, so we save the old value.
|
||||||
$body = $item["body"];
|
$body = $item["body"];
|
||||||
|
|
||||||
|
// Add the content warning
|
||||||
|
if (!empty($item['content-warning'])) {
|
||||||
|
$item["body"] = $item['content-warning'] . '[spoiler]' . $item["body"] . '[/spoiler]';
|
||||||
|
}
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
redir_private_images($a, $item);
|
redir_private_images($a, $item);
|
||||||
|
|
||||||
|
|
|
@ -1143,6 +1143,7 @@ class DBStructure
|
||||||
"author-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
"author-link" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
"author-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
"author-avatar" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
"title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
"title" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
|
"content-warning" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
"body" => ["type" => "mediumtext", "comment" => ""],
|
"body" => ["type" => "mediumtext", "comment" => ""],
|
||||||
"app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
"app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
"verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
|
"verb" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""],
|
||||||
|
|
|
@ -604,6 +604,21 @@ class OStatus
|
||||||
$item["coord"] = $georsspoint->item(0)->nodeValue;
|
$item["coord"] = $georsspoint->item(0)->nodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$categories = $xpath->query('atom:category', $entry);
|
||||||
|
if ($categories) {
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
foreach ($category->attributes as $attributes) {
|
||||||
|
if ($attributes->name == "term") {
|
||||||
|
$term = $attributes->textContent;
|
||||||
|
if (strlen($item["tag"])) {
|
||||||
|
$item["tag"] .= ',';
|
||||||
|
}
|
||||||
|
$item["tag"] .= "#[url=".System::baseUrl()."/search?tag=".$term."]".$term."[/url]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$self = '';
|
$self = '';
|
||||||
$add_body = '';
|
$add_body = '';
|
||||||
|
|
||||||
|
@ -643,12 +658,11 @@ class OStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mastodon Content Warning
|
// Mastodon Content Warning
|
||||||
$content_warning = false;
|
|
||||||
if (($item["verb"] == ACTIVITY_POST) && $xpath->evaluate('boolean(atom:summary)', $entry)) {
|
if (($item["verb"] == ACTIVITY_POST) && $xpath->evaluate('boolean(atom:summary)', $entry)) {
|
||||||
$clear_text = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
|
$clear_text = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
|
||||||
if (!empty($clear_text)) {
|
if (!empty($clear_text)) {
|
||||||
$item["body"] = html2bbcode($clear_text) . '[spoiler]' . $item["body"] . '[/spoiler]';
|
$item['content-warning'] = html2bbcode($clear_text);
|
||||||
$content_warning = true;
|
//$item["body"] = html2bbcode($clear_text) . '[spoiler]' . $item["body"] . '[/spoiler]';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,26 +687,6 @@ class OStatus
|
||||||
$item["parent-uri"] = $item["uri"];
|
$item["parent-uri"] = $item["uri"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$categories = $xpath->query('atom:category', $entry);
|
|
||||||
if ($categories) {
|
|
||||||
foreach ($categories as $category) {
|
|
||||||
foreach ($category->attributes as $attributes) {
|
|
||||||
if ($attributes->name == "term") {
|
|
||||||
$term = $attributes->textContent;
|
|
||||||
// don't add nsfw with content warning if enabled.
|
|
||||||
// Background: "nsfw" is set automatically by Mastodon
|
|
||||||
if (!Config::get('system', 'remove_nsfw_with_cw', false) ||
|
|
||||||
!$content_warning || ($term != 'nsfw')) {
|
|
||||||
if (strlen($item["tag"])) {
|
|
||||||
$item["tag"] .= ',';
|
|
||||||
}
|
|
||||||
$item["tag"] .= "#[url=".System::baseUrl()."/search?tag=".$term."]".$term."[/url]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($item['author-link'] != '') && !empty($item['protocol'])) {
|
if (($item['author-link'] != '') && !empty($item['protocol'])) {
|
||||||
$item = Conversation::insert($item);
|
$item = Conversation::insert($item);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user