mirror of https://github.com/pixelfed/pixelfed.git
Update Autospam, add live filters to block remote activities based on comma separated keywords
This commit is contained in:
parent
bc4d223714
commit
40b45b2a11
|
@ -315,6 +315,23 @@ class Helpers {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(config('autospam.live_filters.enabled')) {
|
||||||
|
$filters = config('autospam.live_filters.filters');
|
||||||
|
if(!empty($filters) && isset($res['content']) && !empty($res['content']) && strlen($filters) > 3) {
|
||||||
|
$filters = array_map('trim', explode(',', $filters));
|
||||||
|
$content = $res['content'];
|
||||||
|
foreach($filters as $filter) {
|
||||||
|
$filter = trim($filter);
|
||||||
|
if(!$filter || !strlen($filter)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(str_contains($content, $filter)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(isset($res['object'])) {
|
if(isset($res['object'])) {
|
||||||
$activity = $res;
|
$activity = $res;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -197,6 +197,22 @@ class Inbox
|
||||||
public function handleCreateActivity()
|
public function handleCreateActivity()
|
||||||
{
|
{
|
||||||
$activity = $this->payload['object'];
|
$activity = $this->payload['object'];
|
||||||
|
if(config('autospam.live_filters.enabled')) {
|
||||||
|
$filters = config('autospam.live_filters.filters');
|
||||||
|
if(!empty($filters) && isset($activity['content']) && !empty($activity['content']) && strlen($filters) > 3) {
|
||||||
|
$filters = array_map('trim', explode(',', $filters));
|
||||||
|
$content = $activity['content'];
|
||||||
|
foreach($filters as $filter) {
|
||||||
|
$filter = trim($filter);
|
||||||
|
if(!$filter || !strlen($filter)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(str_contains($content, $filter)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$actor = $this->actorFirstOrCreate($this->payload['actor']);
|
$actor = $this->actorFirstOrCreate($this->payload['actor']);
|
||||||
if(!$actor || $actor->domain == null) {
|
if(!$actor || $actor->domain == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -33,5 +33,10 @@ return [
|
||||||
'nlp' => [
|
'nlp' => [
|
||||||
'enabled' => false,
|
'enabled' => false,
|
||||||
'spam_sample_limit' => env('PF_AUTOSPAM_NLP_SPAM_SAMPLE_LIMIT', 200),
|
'spam_sample_limit' => env('PF_AUTOSPAM_NLP_SPAM_SAMPLE_LIMIT', 200),
|
||||||
|
],
|
||||||
|
|
||||||
|
'live_filters' => [
|
||||||
|
'enabled' => env('PF_AUTOSPAM_LIVE_FILTERS_ENABLED', false),
|
||||||
|
'filters' => env('PF_AUTOSPAM_LIVE_FILTERS_CSV', ''),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue