Skip to content

Commit

Permalink
Merge branch 'release/0.22.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
garethrees committed Aug 13, 2015
2 parents 4d6a3b1 + edfaa46 commit 67a00ba
Show file tree
Hide file tree
Showing 55 changed files with 4,531 additions and 227 deletions.
23 changes: 23 additions & 0 deletions app/mailers/request_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,29 @@ def receive(email, raw_email)
return
end

spam_action = AlaveteliConfiguration.incoming_email_spam_action
spam_threshold = AlaveteliConfiguration.incoming_email_spam_threshold
spam_header = AlaveteliConfiguration.incoming_email_spam_header
spam_score = email.header[spam_header].try(:value).to_f

if spam_action && spam_header && spam_threshold && spam_score
if spam_score > spam_threshold
case spam_action
when 'discard'
# Do nothing. Silently drop spam above the threshold
return
when 'holding_pen'
reason = _("Incoming message has a spam score ({{spam_score}}) " \
"above the configured threshold ({{spam_threshold}}).",
:spam_score => spam_score,
:spam_threshold => spam_threshold)
request = InfoRequest.holding_pen_request
request.receive(email, raw_email, false, reason)
return
end
end
end

# Send the message to each request, to be archived with it
for reply_info_request in reply_info_requests
# If environment variable STOP_DUPLICATES is set, don't send message with same id again
Expand Down
27 changes: 27 additions & 0 deletions config/general.yml-example
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,33 @@ INCOMING_EMAIL_PREFIX: 'foi+'
# ---
INCOMING_EMAIL_SECRET: 'xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx'

# Filter incoming mail that looks like spam. Spam can be redirected to the
# holding pen or discarded.
#
# If you filter incoming emails through a spam detector like SpamAssassin, you
# can configure Alaveteli to filter messages with a high spam score. This
# feature requires the messages to contain a header with a numeric spam score,
# and INCOMING_EMAIL_SPAM_ACTION, INCOMING_EMAIL_SPAM_HEADER and
# INCOMING_EMAIL_SPAM_THRESHOLD to be configured before the filtering will take
# effect.
#
# INCOMING_EMAIL_SPAM_ACTION - String or false
# Options are 'holding_pen' or 'discard'
# (default: false)
# INCOMING_EMAIL_SPAM_HEADER - String (default: 'X-Spam-Score')
# INCOMING_EMAIL_SPAM_THRESHOLD - Integer or false (default: false)
#
# Examples:
#
# INCOMING_EMAIL_SPAM_ACTION: 'holding_pen'
# INCOMING_EMAIL_SPAM_HEADER: 'X-mySociety-Spam-Score'
# INCOMING_EMAIL_SPAM_THRESHOLD: 20
#
# ---
INCOMING_EMAIL_SPAM_ACTION: false
INCOMING_EMAIL_SPAM_HEADER: 'X-Spam-Score'
INCOMING_EMAIL_SPAM_THRESHOLD: false

# Used as envelope from at the incoming email domain for cases where you don't
# care about failure.
#
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/alaveteli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
load "util.rb"

# Application version
ALAVETELI_VERSION = '0.22.1.0'
ALAVETELI_VERSION = '0.22.2.0'

# Add new inflection rules using the following format
# (all these examples are active by default):
Expand Down
13 changes: 13 additions & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# develop

# Version 0.22.2.0

## Highlighted Features

* Adds filtering of incoming mail based on a spam score from SpamAssassin.
Requests over a threshold can be discarded or sent to the holding pen.
See http://alaveteli.org/docs/customising/config#incoming_email_spam_action
for configuration instructions (Gareth Rees).

## Upgrade Notes

* There should be no action necessary.

# Version 0.22.1.0

## Highlighted Features
Expand Down
3 changes: 3 additions & 0 deletions lib/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ module AlaveteliConfiguration
:INCOMING_EMAIL_DOMAIN => 'localhost',
:INCOMING_EMAIL_PREFIX => 'foi+',
:INCOMING_EMAIL_SECRET => 'dummysecret',
:INCOMING_EMAIL_SPAM_ACTION => false,
:INCOMING_EMAIL_SPAM_HEADER => 'X-Spam-Score',
:INCOMING_EMAIL_SPAM_THRESHOLD => false,
:ISO_COUNTRY_CODE => 'GB',
:MINIMUM_REQUESTS_FOR_STATISTICS => 100,
:MAX_REQUESTS_PER_USER_PER_DAY => 6,
Expand Down
9 changes: 6 additions & 3 deletions locale/aln/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ msgid ""
msgstr ""
"Project-Id-Version: alaveteli\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 14:55+0000\n"
"PO-Revision-Date: 2015-07-24 14:58+0000\n"
"POT-Creation-Date: 2015-08-12 11:00+0000\n"
"PO-Revision-Date: 2015-08-12 11:02+0000\n"
"Last-Translator: Gareth Rees <[email protected]>\n"
"Language-Team: Albanian Gheg (http://www.transifex.com/projects/p/alaveteli/language/aln/)\n"
"Language-Team: Albanian Gheg (http://www.transifex.com/mysociety/alaveteli/language/aln/)\n"
"Language: aln\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -1200,6 +1200,9 @@ msgstr ""
msgid "Incoming message"
msgstr ""

msgid "Incoming message has a spam score ({{spam_score}}) above the configured threshold ({{spam_threshold}})."
msgstr ""

msgid "IncomingMessage|Cached attachment text clipped"
msgstr ""

Expand Down
5 changes: 4 additions & 1 deletion locale/app.pot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: version 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 14:55+0000\n"
"POT-Creation-Date: 2015-08-12 11:00+0000\n"
"PO-Revision-Date: 2011-10-09 01:10+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -1196,6 +1196,9 @@ msgstr ""
msgid "Incoming message"
msgstr ""

msgid "Incoming message has a spam score ({{spam_score}}) above the configured threshold ({{spam_threshold}})."
msgstr ""

msgid "IncomingMessage|Cached attachment text clipped"
msgstr ""

Expand Down
9 changes: 6 additions & 3 deletions locale/ar/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ msgid ""
msgstr ""
"Project-Id-Version: alaveteli\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 14:55+0000\n"
"PO-Revision-Date: 2015-07-24 15:00+0000\n"
"POT-Creation-Date: 2015-08-12 11:00+0000\n"
"PO-Revision-Date: 2015-08-12 11:02+0000\n"
"Last-Translator: Gareth Rees <[email protected]>\n"
"Language-Team: Arabic (http://www.transifex.com/projects/p/alaveteli/language/ar/)\n"
"Language-Team: Arabic (http://www.transifex.com/mysociety/alaveteli/language/ar/)\n"
"Language: ar\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -1216,6 +1216,9 @@ msgstr ""
msgid "Incoming message"
msgstr "رسالة واردة"

msgid "Incoming message has a spam score ({{spam_score}}) above the configured threshold ({{spam_threshold}})."
msgstr ""

msgid "IncomingMessage|Cached attachment text clipped"
msgstr "IncomingMessage|Cached attachment text clipped"

Expand Down
9 changes: 6 additions & 3 deletions locale/bg/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ msgid ""
msgstr ""
"Project-Id-Version: alaveteli\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 14:55+0000\n"
"PO-Revision-Date: 2015-07-24 15:02+0000\n"
"POT-Creation-Date: 2015-08-12 11:00+0000\n"
"PO-Revision-Date: 2015-08-12 11:02+0000\n"
"Last-Translator: Gareth Rees <[email protected]>\n"
"Language-Team: Bulgarian (http://www.transifex.com/projects/p/alaveteli/language/bg/)\n"
"Language-Team: Bulgarian (http://www.transifex.com/mysociety/alaveteli/language/bg/)\n"
"Language: bg\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -1203,6 +1203,9 @@ msgstr "Адрес за входяща поща"
msgid "Incoming message"
msgstr "Входящо съобщение"

msgid "Incoming message has a spam score ({{spam_score}}) above the configured threshold ({{spam_threshold}})."
msgstr ""

msgid "IncomingMessage|Cached attachment text clipped"
msgstr ""

Expand Down
9 changes: 6 additions & 3 deletions locale/bs/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ msgid ""
msgstr ""
"Project-Id-Version: alaveteli\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 14:55+0000\n"
"PO-Revision-Date: 2015-07-24 14:59+0000\n"
"POT-Creation-Date: 2015-08-12 11:00+0000\n"
"PO-Revision-Date: 2015-08-12 11:02+0000\n"
"Last-Translator: Gareth Rees <[email protected]>\n"
"Language-Team: Bosnian (http://www.transifex.com/projects/p/alaveteli/language/bs/)\n"
"Language-Team: Bosnian (http://www.transifex.com/mysociety/alaveteli/language/bs/)\n"
"Language: bs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -1285,6 +1285,9 @@ msgstr ""
msgid "Incoming message"
msgstr ""

msgid "Incoming message has a spam score ({{spam_score}}) above the configured threshold ({{spam_threshold}})."
msgstr ""

msgid "IncomingMessage|Cached attachment text clipped"
msgstr ""

Expand Down
9 changes: 6 additions & 3 deletions locale/ca/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ msgid ""
msgstr ""
"Project-Id-Version: alaveteli\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 14:55+0000\n"
"PO-Revision-Date: 2015-07-24 14:59+0000\n"
"POT-Creation-Date: 2015-08-12 11:00+0000\n"
"PO-Revision-Date: 2015-08-12 11:02+0000\n"
"Last-Translator: Gareth Rees <[email protected]>\n"
"Language-Team: Catalan (http://www.transifex.com/projects/p/alaveteli/language/ca/)\n"
"Language-Team: Catalan (http://www.transifex.com/mysociety/alaveteli/language/ca/)\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -1299,6 +1299,9 @@ msgstr ""
msgid "Incoming message"
msgstr ""

msgid "Incoming message has a spam score ({{spam_score}}) above the configured threshold ({{spam_threshold}})."
msgstr ""

msgid "IncomingMessage|Cached attachment text clipped"
msgstr "IncomingMessage|Cached attachment text clipped"

Expand Down
9 changes: 6 additions & 3 deletions locale/cs/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ msgid ""
msgstr ""
"Project-Id-Version: alaveteli\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 14:55+0000\n"
"PO-Revision-Date: 2015-07-24 15:00+0000\n"
"POT-Creation-Date: 2015-08-12 11:00+0000\n"
"PO-Revision-Date: 2015-08-12 11:02+0000\n"
"Last-Translator: Gareth Rees <[email protected]>\n"
"Language-Team: Czech (http://www.transifex.com/projects/p/alaveteli/language/cs/)\n"
"Language-Team: Czech (http://www.transifex.com/mysociety/alaveteli/language/cs/)\n"
"Language: cs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -1291,6 +1291,9 @@ msgstr "Adresa pro příchozí e-maily"
msgid "Incoming message"
msgstr "Příchozí zpráva"

msgid "Incoming message has a spam score ({{spam_score}}) above the configured threshold ({{spam_threshold}})."
msgstr ""

msgid "IncomingMessage|Cached attachment text clipped"
msgstr "Příchozí zpráva | Soubor z mezipaměti přiložen"

Expand Down
9 changes: 6 additions & 3 deletions locale/cy/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ msgid ""
msgstr ""
"Project-Id-Version: alaveteli\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 14:55+0000\n"
"PO-Revision-Date: 2015-07-24 15:00+0000\n"
"POT-Creation-Date: 2015-08-12 11:00+0000\n"
"PO-Revision-Date: 2015-08-12 11:02+0000\n"
"Last-Translator: Gareth Rees <[email protected]>\n"
"Language-Team: Welsh (http://www.transifex.com/projects/p/alaveteli/language/cy/)\n"
"Language-Team: Welsh (http://www.transifex.com/mysociety/alaveteli/language/cy/)\n"
"Language: cy\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -1217,6 +1217,9 @@ msgstr "Cyfeiriad e-bost sy'n dod i mewn"
msgid "Incoming message"
msgstr "Neges sy'n dod i mewn"

msgid "Incoming message has a spam score ({{spam_score}}) above the configured threshold ({{spam_threshold}})."
msgstr ""

msgid "IncomingMessage|Cached attachment text clipped"
msgstr "IncomingMessage|Testun atodiad yn y storfa wedi ei docio"

Expand Down
18 changes: 11 additions & 7 deletions locale/de/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
# KerstiRu <[email protected]>, 2011
# louisecrow <[email protected]>, 2014
# louisecrow <[email protected]>, 2014
# Philipp Brocar <[email protected]>, 2015
# stefanw <[email protected]>, 2011
msgid ""
msgstr ""
"Project-Id-Version: alaveteli\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-07-24 14:55+0000\n"
"PO-Revision-Date: 2015-07-24 15:02+0000\n"
"POT-Creation-Date: 2015-08-12 11:00+0000\n"
"PO-Revision-Date: 2015-08-12 11:02+0000\n"
"Last-Translator: Gareth Rees <[email protected]>\n"
"Language-Team: German (http://www.transifex.com/projects/p/alaveteli/language/de/)\n"
"Language-Team: German (http://www.transifex.com/mysociety/alaveteli/language/de/)\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -84,7 +85,7 @@ msgid " You will also be emailed updates about the request."
msgstr "Aktualisierungen zu dieser Anfrage werden Ihnen auch per Email übermittelt. "

msgid " filtered by status: '{{status}}'"
msgstr ""
msgstr "gefiltert nach Status: '{{status}}'"

msgid " when you send this message."
msgstr "wenn Sie diese Nachricht senden. "
Expand All @@ -105,16 +106,16 @@ msgid "'{{link_to_user}}', a person"
msgstr "'{{link_to_user}}', eine Person"

msgid "(hide)"
msgstr ""
msgstr "(ausblenden)"

msgid "(or <a href=\"{{url}}\">sign in</a>)"
msgstr ""
msgstr "(oder <a href=\"{{url}}\">einloggen</a>)"

msgid "(show)"
msgstr ""

msgid "*unknown*"
msgstr ""
msgstr "*unbekannt*"

msgid ",\\n\\n\\n\\nYours,\\n\\n{{user_name}}"
msgstr ""
Expand Down Expand Up @@ -1252,6 +1253,9 @@ msgstr ""
msgid "Incoming message"
msgstr ""

msgid "Incoming message has a spam score ({{spam_score}}) above the configured threshold ({{spam_threshold}})."
msgstr ""

msgid "IncomingMessage|Cached attachment text clipped"
msgstr "IncomingMessage|Cached attachment text clipped"

Expand Down
Loading

0 comments on commit 67a00ba

Please sign in to comment.