sieve2workers 0.1.2

Convert a Sieve program into a Cloudflare Workers for Cloudflare Email Routing.
require ["variables", "relational", "body", "spamtestplus", "fileinto"];

### Sieve generated for save-on-SMTP identities {{{
# You do not have any identities with special filing.
### }}}

### Sieve generated for blocked senders {{{
# You have no blocked senders.
### }}}

### Sieve generated for disabled masked email addresses {{{
if header :contains "Fastmail-MaskedEmail" " state=disabled" {
  # addflag "\\Seen";
  # fileinto :specialuse "\\Trash" "INBOX.Trash";
  stop;
}
### }}}

### Sieve generated for spam protection {{{
if not header :matches "X-Spam-Known-Sender" "yes*" {
  if allof(
      header :contains "X-Backscatter" "yes",
      not header :matches "X-LinkName" "*"
  ) {
    set "spam" "Y";
  }
  # if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-score" "5" {
  #   set "spam" "Y";
  # }
}
### }}}

### MailFetch Implicit Keep {{{
### }}}

### Address rules {{{
# You have no address rules
### }}}

### Execute spam filing {{{
if string :is "${spam}" "Y" {
  # fileinto "\\Junk";
  stop;
}
### }}}

if body :contains "MAKE MONEY FAST" {
    discard;
}

if body :contains "to be saved" {
    fileinto "r2://BINDING_NAME";
}

if spamtest :value "lt" :comparator "i;ascii-numeric" "37" {
    discard;
}