Skip to content

OpenSourcePolitics/decidim-spam_detection

Repository files navigation

Decidim::SpamDetection

codecov Tests Gem Version

Usage

SpamDetection is a detection bot made by OpenSourcePolitics. It works with a spam detection service which marks the user with a spam probability score, between 0.7 and 0.99 it is probable, and above 0.99 it is very sure.

By default, the bot does not blocks the user, it only reports them. All reports and blocks are made like regular Decidim ones.

Installation

Add this line to your application's Gemfile:

gem "decidim-spam_detection"

And then execute:

bundle exec rake decidim:spam_detection:mark_users

if you are using sidekiq scheduler you can use the following configuration:

:queues:
- user_report
- block_user
- scheduled

:schedule:
    DetectSpamUsers:
    cron: '0 0 8 * * *' # Run at 08:00
    class: Decidim::SpamDetection::MarkUsersJob
    queue: scheduled

Block already marked users

If you want to block already marked users, you can use the following command:

bundle exec rake decidim:spam_detection:block_users

Further configuration

list of env var, default value and their usage:

ACTIVATE_SPAM_DETECTION_SERVICE:
    default: false
    usage: Activate the spam detection service if api url is set to default one
SPAM_DETECTION_API_AUTH_TOKEN
    default_value: dummy
    usage: Token auth for authentication used by external service, ask us for more details
SPAM_DETECTION_API_URL 
    default_value: "http://localhost:8080/api"
    usage: URL of the external service
SPAM_DETECTION_NAME 
    default_value: "spam detection bot"
    usage: Name used by the spam detection bot
SPAM_DETECTION_NICKNAME 
    default_value: "Spam_detection_bot"
    usage: Nickname used by the spam detection bot
SPAM_DETECTION_EMAIL 
    default_value: "[email protected]"
    usage: Email used by the spam detection bot
PERFORM_BLOCK_USER 
    default_value: false
    usage: Determine if the bot can perform blocking, default mode is just report
SPAM_DETECTION_BLOCKING_LEVEL
    default_value: 0.99
    usage: Define which level of spam probability is considered as blocking in job Decidim::SpamDetection::BlockUsersJob (and task rake decidim:spam_detection:block_users)

API usage

We can provide the detection service, please check us out at [email protected]

Contributing

See Decidim.

License

This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.