Code Monkey home page Code Monkey logo

mm-mdfix-email's Introduction

Mattermost Message Formatter - Email Markdown Removal

This project provides a Dockerized Python script to remove markdown formatted email addresses in formatted code blocks in Mattermost messages stored in a PostgreSQL database, ensuring code blocks are properly formatted with newlines, making them more readable.

Prerequisites

  • Docker
  • Access to your Mattermost PostgreSQL database

Usage

1. Configuration

Copy the default.env file in the root directory of this project to .env and set your variables:

DB_HOST=your_host
DB_PORT=your_port
DB_USER=your_user
DB_PASSWORD=your_password
DB_NAME=your_dbname
CHANNEL_ID=optional_channel_id
COMMIT_MODE=false

Replace the placeholders (your_host, your_port, etc.) with your actual database connection details. The CHANNEL_ID is optional; if provided, only messages from that channel will be processed. By default, the script runs in test mode (COMMIT_MODE=false). If you want to commit changes to the database, set COMMIT_MODE=true.

There are additional debug messages available by adding DEBUG=true to your environment.

2. Run the Docker Container

docker run --env-file .env ghcr.io/maxwellpower/mm-mdfix-email

Using Command Line

If you prefer to provide the environment variables directly:

docker run -e DB_HOST=your_host -e DB_PORT=your_port -e DB_USER=your_user -e DB_PASSWORD=your_password -e DB_NAME=your_dbname -e CHANNEL_ID=optional_channel_id -e COMMIT_MODE=false ghcr.io/maxwellpower/mm-mdfix-email

Replace the placeholders with your actual database connection details.

Notes

  • The script processes messages containing code blocks (enclosed in triple backticks ```).
  • Messages with a language specifier immediately after the opening ticks (e.g., ```php) remain unchanged.
  • Only messages from posts that haven't been marked as deleted (where deleteat is 0) are processed.
  • By default, the script runs in test mode, allowing you to review potential changes without modifying the database. To apply changes, set COMMIT_MODE=true.

mm-mdfix-email's People

Contributors

maxwellpower avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.