Skip to content

An advanced web frontend for the modmail discord bot with built in Discord OAuth2 authentication, and support for browsing and searching current and historical logs. Directly replaces logviewer.

License

Notifications You must be signed in to change notification settings

khakers/modmail-viewer

Repository files navigation

Modmail Viewer

GitHub latest release (latest SemVer) GitHub Help Wanted issues Wiki

Deploy on Railway (not recommended)

A drop in alternative frontend for your modmail-dev/modmail bot instance with built-in Discord authentication, advanced features and better mobile support. Replaces logivewer with more features

Built from scratch using Javalin, JTE, Bootstrap 5, and Unpoly.

Screenshots

modmail-logviewer-log log browsing

Modmail-Viewer is currently a beta. You should always read update notes before applying updates as there may be breaking changes between major versions, and ensure you are running an up to date version to have the latest fixes and support.

Report any bugs you encounter via github issues at this repository (not modmail or logviewer, as this is a community project).
Use GitHub discussions for feature requests or to ask questions. Please prefer not to directly DM me, as it's not discoverable for other people that may help, and it's possible that I won't not notice it for a while.

Interested in a custom version or features for your server? Contact me privately on discord to sponsor features or to commision changes.

Features

  • All features in logviewer + more
  • Discord OAuth2 authentication based on your modmail roles. See the wiki page on permissions.
  • Browsable paginated logs sorted by most recent message and filterable by status.
  • Mobile friendly design.
  • Full Discord Markdown formatting (Including spoilers, custom emojis, and timestamps).
  • Customizable Branding
  • Dark/Light Themes
  • Log text search
  • HTTPS support
  • NSFW warnings
  • Image spoiler support
  • Ticket dashboard 🔜
  • Audit Logging 🔜
  • Inline attachment support 🔜
  • Retrievable message links 🔜

Self-hosting

You should place your modmail-viewer instance behind Cloudflare or some other reverse proxy (such as Caddy) to provide automatic https OR provide the required keys/certs to the application yourself if you plan on using authentication.

Docker

Running the application with Docker is the fastest and best supported way to run modmail-viewer. Additionally, you can easily run it using any service that supports running docker containers.

Docker Run

To quickly test modmail-viewer, you can use this docker run command. Make sure to substitute the environment variables for what is applicable to you.

docker run --name modmail-viewer -p 80:80 \
  --env "MODMAIL_VIEWER_MONGODB_URI=mongodb://mongo:27017" \
  --env "MODMAIL_VIEWER_URL=http://127.0.0.1" \
  --env "MODMAIL_VIEWER_DISCORD_OAUTH_CLIENT_ID=1234" \
  --env "MODMAIL_VIEWER_DISCORD_OAUTH_CLIENT_SECRET=abcd" \
  -d ghcr.io/khakers/modmail-viewer:latest

Docker Compose

For long term ease of use, it's highly recommended that you use docker compose. An example docker compose for running only modmail-logviewer.

Note See docker-compose.yml for a compose file that can run modmail, modmail-viewer, and mongodb.

version: "3.7"
services:
  viewer:
    image: ghcr.io/khakers/modmail-viewer:latest
    env_file:
      - .env
    ports:
      - "80:80"
      # uncomment if using SSL
      #- "443:443"
    environment:
      - "MODMAIL_VIEWER_MONGODB_URI=mongodb://mongo:27017"
      - "MODMAIL_VIEWER_URL=http://127.0.0.1"
.env example

Should be located next to your docker-compose.yml, contains secrets.

Note See the wiki page on authentication setup for more information.

MODMAIL_VIEWER_DISCORD_OAUTH_CLIENT_ID=123456789
MODMAIL_VIEWER_DISCORD_OAUTH_CLIENT_SECRET=67234rtg3b2otgfhbn3298t7h
MODMAIL_VIEWER_SECRETKEY=secret

Other

Before getting started, you'll need:

  • A JDK/JRE 17 installation

Download the latest release from GitHub and unzip/tar the modmail-viewer archive

Run the webserver via the included scripts bin/modmail-viewer on linux, and bin/modmail-viewer.bat on windows.

It's recommended to either set up a reverse proxy (such as Cloudflare or Caddy) in front of your modmail-logviewer instance, or enable SSL and provide your own certificate and private key. You can generate one for your domain automatically with Certbot.

To run the webserver in the background, it's recommended you use a service manager such as Systemd.

Configuration

Permissions

See the wiki page on permissions.

Environment Variables

Environment Variable Description
MODMAIL_VIEWER_URL The URL your modmail viewer instance is reachable at (i.e http://127.0.0.1)
MODMAIL_VIEWER_MONGODB_URI URI for the MongoDB instance
MODMAIL_VIEWER_DISCORD_OAUTH_CLIENT_ID Your Discord Application ID. Can be skipped if authentication is disabled.
MODMAIL_VIEWER_DISCORD_OAUTH_CLIENT_SECRET Your Discord OAuth2 client secret
MODMAIL_VIEWER_DISCORD_GUILD_ID The ID of your discord Guild. This should be whatever guild has relevant discord Roles, as it checks the users roles in the provided guild
MODMAIL_VIEWER_SECRETKEY A randomly generated secret key used for signing auth tokens.
ANYONE WITH THIS KEY CAN FORGE AUTHENTICATION TOKENS and impersonate any user. Should be at least 32 characters. If you don't provide one, sessions will not persist across restarts.
MODMAIL_VIEWER_DEV Enables development features. Do not enable in production. Requires a JDK.
MODMAIL_VIEWER_AUTH_ENABLED Set to false to completely disable authentication. May break some features.
MODMAIL_VIEWER_SSL Enables SSL and HTTP/2 when connected via https.
MODMAIL_VIEWER_HTTPS_ONLY Disables the http port and redirects all connections to https. Enabled by default if SSL is enabled. Does not function on localhost.
MODMAIL_VIEWER_SSL_CERT Path to the SSL certificate pem file. Does not hot reload.
MODMAIL_VIEWER_SSL_KEY Path to the SSL certificate private key pem file. Does not hot reload.
MODMAIL_VIEWER_HTTP_PORT Port HTTP traffic will be served at. Defaults to 80
MODMAIL_VIEWER_HTTPS_PORT Port HTTPS traffic will be served at. Defaults to 443
MODMAIL_VIEWER_SNI Set SNI to be enabled/disabled. Requires SSL to be enabled
MODMAI_VIEWER_INSECURE Disable setting cookies as secure. Only do this if your site is only accessible via http
MODMAIL_VIEWER_BRANDING Text to display in the navbar title. Will display "Modmail-Viewer" by default
MODMAIL_VIEWER_LOG_LEVEL Set the application log level (INFO, DEBUG, ERROR, TRACE)
MODMAIL_VIEWER_ANALYTICS Allows you to add the html for your analytics solution. This is inserted at the end of the head (and should thus likely be marked as defer for performance reasons)
MODMAIL_VIEWER_ANALYTICS_BASE64 Same as the above, but expects it's value to be base64 encoded. This is exists in the off chance that you run into character encoding issues using the standard variable. Will only work if standard option is not provided.
MODMAIL_VIEWER_BOT_ID The id of your modmail discord bot. You likely don't need to specify this. However, failing to do so may lead modmail-viewer to fetch the wrong config from mongodb if you've had multiple bots using the same mongodb database.

Attribution

This project uses graphics from Twemoji licensed under CC-BY 4.0: https://creativecommons.org/licenses/by/4.0/ using the jdecked/temoji library

About

An advanced web frontend for the modmail discord bot with built in Discord OAuth2 authentication, and support for browsing and searching current and historical logs. Directly replaces logviewer.

Topics

Resources

License

Stars

Watchers

Forks

Packages