mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Merge pull request #4933 from pixelfed/staging
Autospam Live Filters - block remote activities based on comma separated keywords
This commit is contained in:
commit
e1d579b10b
4 changed files with 41 additions and 0 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.11.11...dev)
|
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.11.11...dev)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Autospam Live Filters - block remote activities based on comma separated keywords ([40b45b2a](https://github.com/pixelfed/pixelfed/commit/40b45b2a))
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
- Update ApiV1Controller, fix network timeline ([0faf59e3](https://github.com/pixelfed/pixelfed/commit/0faf59e3))
|
- Update ApiV1Controller, fix network timeline ([0faf59e3](https://github.com/pixelfed/pixelfed/commit/0faf59e3))
|
||||||
|
|
|
@ -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 a new issue