Merge remote-tracking branch 'upstream/develop' into discover

This commit is contained in:
Michael 2024-01-26 13:54:25 +00:00
commit f1173853f3
10 changed files with 284 additions and 258 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 2024.03-dev (Yellow Archangel)
-- DB_UPDATE_VERSION 1547
-- DB_UPDATE_VERSION 1548
-- ------------------------------------------
@ -1243,7 +1243,7 @@ CREATE TABLE IF NOT EXISTS `post-category` (
CREATE TABLE IF NOT EXISTS `post-counts` (
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
`vid` smallint unsigned NOT NULL COMMENT 'Id of the verb table entry that contains the activity verbs',
`reaction` varchar(1) NOT NULL COMMENT 'Emoji Reaction',
`reaction` varchar(4) NOT NULL COMMENT 'Emoji Reaction',
`parent-uri-id` int unsigned COMMENT 'Id of the item-uri table that contains the parent uri',
`count` int unsigned DEFAULT 0 COMMENT 'Number of activities',
PRIMARY KEY(`uri-id`,`vid`,`reaction`),

View File

@ -10,7 +10,7 @@ Fields
| ------------- | ----------------------------------------------------------- | ----------------- | ---- | --- | ------- | ----- |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | |
| vid | Id of the verb table entry that contains the activity verbs | smallint unsigned | NO | PRI | NULL | |
| reaction | Emoji Reaction | varchar(1) | NO | PRI | NULL | |
| reaction | Emoji Reaction | varchar(4) | NO | PRI | NULL | |
| parent-uri-id | Id of the item-uri table that contains the parent uri | int unsigned | YES | | NULL | |
| count | Number of activities | int unsigned | YES | | 0 | |

View File

@ -78,7 +78,7 @@ class Counts
{
self::update($uri_id, $parent_uri_id, Verb::getID(Activity::POST), Activity::POST);
$activities = DBA::p("SELECT `parent-uri-id`, `vid`, `verb`, `body` FROM `post-view` WHERE `thr-parent-id` = ? AND `gravity` = ? GROUP BY `parent-uri-id`, `vid`, `verb`, `body`", $uri_id, Item::GRAVITY_ACTIVITY);
$activities = DBA::p("SELECT `parent-uri-id`, `vid`, `verb`, `body` FROM `post-view` WHERE `thr-parent-id` = ? AND `gravity` = ? AND `vid` IS NOT NULL GROUP BY `parent-uri-id`, `vid`, `verb`, `body`", $uri_id, Item::GRAVITY_ACTIVITY);
while ($activity = DBA::fetch($activities)) {
self::update($uri_id, $activity['parent-uri-id'], $activity['vid'], $activity['verb'], $activity['body']);
}

View File

@ -159,6 +159,7 @@ class Site extends BaseAdmin
$relay_scope = (!empty($_POST['relay_scope']) ? trim($_POST['relay_scope']) : '');
$relay_server_tags = (!empty($_POST['relay_server_tags']) ? trim($_POST['relay_server_tags']) : '');
$relay_deny_tags = (!empty($_POST['relay_deny_tags']) ? trim($_POST['relay_deny_tags']) : '');
$relay_max_tags = (!empty($_POST['relay_max_tags']) ? intval($_POST['relay_max_tags']) : 0);
$relay_user_tags = !empty($_POST['relay_user_tags']);
$relay_deny_undetected_language = !empty($_POST['relay_deny_undetected_language']);
@ -333,6 +334,7 @@ class Site extends BaseAdmin
$transactionConfig->set('system', 'relay_scope' , $relay_scope);
$transactionConfig->set('system', 'relay_server_tags' , $relay_server_tags);
$transactionConfig->set('system', 'relay_deny_tags' , $relay_deny_tags);
$transactionConfig->set('system', 'relay_max_tags' , $relay_max_tags);
$transactionConfig->set('system', 'relay_user_tags' , $relay_user_tags);
$transactionConfig->set('system', 'relay_deny_undetected_language', $relay_deny_undetected_language);
$transactionConfig->set('system', 'relay_language_quality' , $relay_language_quality);
@ -586,6 +588,7 @@ class Site extends BaseAdmin
'$relay_scope' => ['relay_scope', DI::l10n()->t('Relay scope'), DI::config()->get('system', 'relay_scope'), DI::l10n()->t('Can be "all" or "tags". "all" means that every public post should be received. "tags" means that only posts with selected tags should be received.'), [Relay::SCOPE_NONE => DI::l10n()->t('Disabled'), Relay::SCOPE_ALL => DI::l10n()->t('all'), Relay::SCOPE_TAGS => DI::l10n()->t('tags')]],
'$relay_server_tags' => ['relay_server_tags', DI::l10n()->t('Server tags'), DI::config()->get('system', 'relay_server_tags'), DI::l10n()->t('Comma separated list of tags for the "tags" subscription.')],
'$relay_deny_tags' => ['relay_deny_tags', DI::l10n()->t('Deny Server tags'), DI::config()->get('system', 'relay_deny_tags'), DI::l10n()->t('Comma separated list of tags that are rejected.')],
'$relay_max_tags' => ['relay_max_tags', DI::l10n()->t('Maximum amount of tags'), DI::config()->get('system', 'relay_max_tags'), DI::l10n()->t('Maximum amount of tags in a post before it is rejected as spam. The post has to contain at least one link. Posts from subscribed accounts will not be rejected.')],
'$relay_user_tags' => ['relay_user_tags', DI::l10n()->t('Allow user tags'), DI::config()->get('system', 'relay_user_tags'), DI::l10n()->t('If enabled, the tags from the saved searches will used for the "tags" subscription in addition to the "relay_server_tags".')],
'$relay_deny_undetected_language' => ['relay_deny_undetected_language', DI::l10n()->t('Deny undetected languages'), DI::config()->get('system', 'relay_deny_undetected_language'), DI::l10n()->t('If enabled, posts with undetected languages will be rejected.')],
'$relay_language_quality' => ['relay_language_quality', DI::l10n()->t('Language Quality'), DI::config()->get('system', 'relay_language_quality'), DI::l10n()->t('The minimum language quality that is required to accept the post.')],

View File

@ -113,6 +113,12 @@ class Relay
}
if (!empty($tagList) || !empty($denyTags)) {
$max_tags = $config->get('system', 'relay_max_tags');
if ($max_tags && (count($tags) > $max_tags) && preg_match('/[^@!#]\[url\=.*?\].*?\[\/url\]/ism', $body)) {
Logger::info('Possible hashtag spam detected - rejected', ['hashtags' => $tags, 'network' => $network, 'url' => $url, 'causer' => $causer, 'body' => $body]);
return false;
}
$content = mb_strtolower(BBCode::toPlaintext($body, false));
foreach ($tags as $tag) {

View File

@ -56,7 +56,7 @@ use Friendica\Database\DBA;
// This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1547);
define('DB_UPDATE_VERSION', 1548);
}
return [
@ -1270,7 +1270,7 @@ return [
"fields" => [
"uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
"vid" => ["type" => "smallint unsigned", "not null" => "1", "primary" => "1", "foreign" => ["verb" => "id", "on delete" => "restrict"], "comment" => "Id of the verb table entry that contains the activity verbs"],
"reaction" => ["type" => "varchar(1)", "not null" => "1", "primary" => "1", "comment" => "Emoji Reaction"],
"reaction" => ["type" => "varchar(4)", "not null" => "1", "primary" => "1", "comment" => "Emoji Reaction"],
"parent-uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table that contains the parent uri"],
"count" => ["type" => "int unsigned", "default" => 0, "comment" => "Number of activities"],
],

View File

@ -237,6 +237,10 @@ return [
// Minimum value for the language detection quality for relay posts. The value must be between 0 and 1.
'relay_language_quality' => 0,
// relay_max_tags (Integer)
// Maximum amount of tags in a post before it is rejected as spam.
'relay_max_tags' => 10,
// proxify_content (Boolean)
// Use the proxy functionality for fetching external content
'proxify_content' => true,

File diff suppressed because it is too large Load Diff

View File

@ -160,6 +160,7 @@
{{include file="field_select.tpl" field=$relay_scope}}
{{include file="field_input.tpl" field=$relay_server_tags}}
{{include file="field_input.tpl" field=$relay_deny_tags}}
{{include file="field_input.tpl" field=$relay_max_tags}}
{{include file="field_checkbox.tpl" field=$relay_user_tags}}
{{include file="field_checkbox.tpl" field=$relay_directly}}
{{include file="field_checkbox.tpl" field=$relay_deny_undetected_language}}

View File

@ -329,6 +329,7 @@
{{include file="field_select.tpl" field=$relay_scope}}
{{include file="field_input.tpl" field=$relay_server_tags}}
{{include file="field_input.tpl" field=$relay_deny_tags}}
{{include file="field_input.tpl" field=$relay_max_tags}}
{{include file="field_checkbox.tpl" field=$relay_user_tags}}
{{include file="field_checkbox.tpl" field=$relay_directly}}
{{include file="field_checkbox.tpl" field=$relay_deny_undetected_language}}