Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new thunderbird-msg-filters package #5

Merged
merged 4 commits into from
Feb 1, 2020

Conversation

remusao
Copy link
Owner

@remusao remusao commented Feb 1, 2020

@remusao/thunderbird-msg-fitlers

Parse and pretty-print Thunderbird message filters files (msgFilterRules.dat)

This is a small library which can parse msgFilterRules.dat files from
Thunderbird, the free email application.
msgFilterRules.dat contain so-called "Message Filters", which can be used to
automatically apply actions to inbound emails based on some pre-conditions.
Things like automatic tagging, labeling or moving emails to specific folders.

I personally make extensive use of message filters, but as the number of rules
grows, I found the built-in interface to not be very convenient. Finding or
editing rules can become a pain. So I decided to write a library which allows
to manipulate these rules through a minimal and type-safe API.

The goal of the project is to allow developing more high-level tooling to
read, transform, extend, update the rules while not having to worry about the
low-level parsing details. It would also be possible to store the rules in a
nicer format then use the library to produce the final file which can be
consumed by Thunderbird.

Usage

import { parse, format } from 'thunderbird-msg-filters';

// A typical `msgFilterRules.dat` could contain this raw value.
const rules = parse(`
version="9"
logging="no"
name="rule 1"
enabled="yes"
type="17"
action="Mark flagged"
condition="OR (subject,contains,foo) OR (subject,contains,bar)"
name="rule 2"
enabled="yes"
type="17"
action="Mark read"
action="JunkScore"
actionValue="100"
condition="ALL"
`);

// This will produce the exact same output as previous example.
const rulesAsString = format({
  version: '9',
  logging: 'no',
  rules: [
    {
      name: 'rule 1',
      enabled: 'yes',
      type: '17',
      actions: [{ name: 'Mark flagged'}],
      condition: 'OR (subject,contains,foo) OR (subject,contains,bar)'
    },
    {
      name: 'rule 2',
      enabled: 'yes',
      type: '17',
      actions: [
        { name: 'Mark read' }
        { name: 'JunkScore', value: '100' }
      ],
      condition: 'ALL'
    },
  ]
});
📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @remusao/auto-config@1.2.0-canary.5.b814f6d.0
npm install @remusao/thunderbird-msg-filters@1.2.0-canary.5.b814f6d.0
npm install @remusao/trie@1.2.0-canary.5.b814f6d.0
# or 
yarn add @remusao/auto-config@1.2.0-canary.5.b814f6d.0
yarn add @remusao/thunderbird-msg-filters@1.2.0-canary.5.b814f6d.0
yarn add @remusao/trie@1.2.0-canary.5.b814f6d.0

@remusao remusao added the PR: New Feature 🚀 Increment minor version when merged label Feb 1, 2020
@remusao remusao merged commit 3da5414 into master Feb 1, 2020
@github-actions
Copy link

github-actions bot commented Feb 1, 2020

🚀 PR was released in @remusao/thunderbird-msg-filters@1.2.0 🚀

@github-actions github-actions bot added the released This issue/pull request has been released. label Feb 1, 2020
@remusao remusao deleted the add-thunderbird-msg-filters-package branch February 3, 2020 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: New Feature 🚀 Increment minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant