Skip to main content
Ayase Quart includes a comprehensive moderation system for managing user-submitted reports and filtering content.

Moderation features

  • User reports - View and manage community-submitted reports
  • Auto-hide - Automatically hide reported content
  • Regex filtering - Filter content based on regex patterns
  • Multiple interfaces - Web, API, and CLI support
  • Authentication - Secure access with cookie or bearer token authentication
SSL certificates are required for moderation authentication unless moderation.auth.cookie_secure=false is set.

Configuration

Configure moderation settings in config.toml:
[moderation]
enabled = true
api = false

admin_user = 'admin'
admin_password = 'admin'

# Auto-hide reported content
hide_post_if_reported = true

# Hide after N reports from different IPs
n_reports_then_hide = 1

# Hide posts deleted by upstream moderators
hide_upstream_deleted_posts = true

# Hide replies to hidden OPs
remove_replies_to_hidden_op = true

# Cache type for filters
filter_cache_type = 'sqlite'  # 'sqlite' or 'redis'

# Regex pattern to never serve matching posts
regex_filter = ''  # e.g. 'spam|nsfw|banned_term'

# Path to sqlite-regex extension
path_to_regex_so = ''  # Download from https://github.com/asg017/sqlite-regex/releases

# Directory for hidden images
hidden_images_path = ''  # e.g. '/home/garbage/disposal'
Change the default username and password before deploying to production.

SQLite moderation database

Configure the SQLite moderation database:
[moderation.sqlite]
database = 'path/to/moderation.db'
SQLite 3.35.0+ is required for moderation tools. Check version:
python -c "import sqlite3; print(sqlite3.sqlite_version)"

Redis configuration

For better performance, use Redis for authentication and filtering:
[moderation.redis]
db = 4
fc_key_prefix = 'filter_cache:'
fc_dump_dir = './data/filter_cache/'
bloom_err_rate = 0.01
bloom_init_size = 4_000_000
bloom_resize_mult = 2
cuckoo_capacity = 10_000
cuckoo_bucket = 2000
cuckoo_iter_max = 5

Authentication settings

[moderation.auth]
cookie_samesite = 'Strict'
cookie_secure = false  # Set to true in production with HTTPS
cookie_http_only = true
cookie_name = 'aq'

cookie_salt = 'web salt'
bearer_salt = 'api salt'

cookie_duration = 604_800  # One week
bearer_duration = 604_800  # One week

Set up Redis (optional)

Redis improves performance for moderation bloom filtering.
1

Install Redis

Redis is typically included in the system packages:
sudo apt update
sudo apt install redis-server
2

Configure Redis

Edit the Redis configuration:
sudo nano /etc/redis/redis.conf
Change supervised no to supervised systemd and configure your listening port.
3

Restart Redis

Apply changes and verify status:
sudo systemctl restart redis
sudo systemctl status redis
4

Enable in config

Update config.toml:
[stats]
redis = true
redis_db = 2

[moderation]
filter_cache_type = 'redis'

Web interface

The web interface uses cookie-based authentication with a math captcha.
1

Access login page

Navigate to your configured login endpoint (default /login):
http://127.0.0.1:9001/login
2

Solve captcha

Complete the math captcha to prove you’re human.
3

Enter credentials

Use your configured admin credentials (default: username admin, password admin).
4

Manage reports

Access moderation features through the web interface:
  • View submitted reports
  • Hide/show posts
  • Delete content
  • Add moderator notes

API authentication

The API uses bearer token authentication.
1

Enable API

Set in config.toml:
[moderation]
api = true
2

Get access token

Send a POST request to get a token:
curl -X POST http://localhost:9001/api/v1/login \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": "admin"}'
3

Use token in requests

Include the token in the Authorization header:
curl http://localhost:9001/api/v1/reports \
  -H "Authorization: bearer YOUR_TOKEN_HERE"
Use Bruno to test the API. Import the collection from /dev/bruno_aq.json.

CLI commands

The CLI doesn’t require authentication since it requires server access.

View report count

ayaseq report cli-get-report-count
Output:
Report count: 4

List reports

View all reports:
ayaseq report cli-get-reports
Filter by criteria:
ayaseq report cli-get-reports --public_access v --created_at_gte "2024-01-01"
Available filters:
  • --report_parent_id, -id - Specific report ID
  • --board_shortnames, -boards - Filter by boards
  • --is_op, -op - Filter by OP status
  • --thread_num, -tno - Specific thread
  • --num, -pno - Specific post
  • --submitter_category, -cat - Report category
  • --public_access, -access - Access level
  • --mod_status, -status - Moderation status
  • --created_at_gte, -cgte - Created after date
  • --created_at_lte, -clte - Created before date

Edit report

Update report metadata:
ayaseq report cli-edit-report \
  --report_parent_id 2 \
  --mod_status c \
  --mod_notes "Reviewed and closed"
Options:
  • --public_access, -access - Set access level (v=visible, h=hidden)
  • --mod_status, -status - Set status (o=open, c=closed)
  • --mod_notes, -notes - Add moderator notes

Delete report

Remove a report:
ayaseq report cli-delete-report --report_parent_id 5

Take action on report

Perform moderation actions:
ayaseq report cli-reports-action \
  --report_parent_id 2 \
  --action post_hide \
  --mod_notes "Hidden for violating rules"
Available actions:
  • report_delete - Delete the report
  • post_delete - Delete the reported post
  • media_delete - Delete associated media
  • media_hide - Hide media
  • media_show - Show hidden media
  • post_show - Show hidden post
  • post_hide - Hide post
  • report_close - Close report
  • report_open - Reopen report
  • report_save_notes - Save moderator notes

Regex filtering

Filter posts matching regex patterns to never serve them.
1

Download sqlite-regex extension

Download the SQLite regex extension from sqlite-regex releases.
2

Configure regex filter

Edit config.toml:
[moderation]
regex_filter = 'spam|viagra|banned_term'
path_to_regex_so = '/path/to/regex0.so'
3

Restart Ayase Quart

The filter applies to all future requests:
sudo systemctl restart ayasequart
Complex regex patterns may impact performance. Test thoroughly before deploying.

Report categories

Users can submit reports in these categories:
  • NSFW content on a SFW board
  • DCMA violation
  • Illegal content
  • Spam
  • Rule violation
  • Other

Moderation statuses

  • o - Open (pending review)
  • c - Closed (reviewed and resolved)

Public access levels

  • v - Visible (publicly accessible)
  • h - Hidden (not displayed to users)

Next steps

SSL certificates

Set up SSL for secure authentication

Production deployment

Deploy with systemd and reverse proxy

Build docs developers (and LLMs) love