Add handling for message reply via email

If the reply_email_domain configuration is set the messages plugin will
use unique Reply-To addresses for every email. They contain enough
information to reconstruct the message context and a hash to avoid
user forgery and spam.
A mail transfer agent must be configured to call the new rake task
foodsoft:parse_reply_email for incoming mails. The rake task requires
the receipt of the mail in the RECIPIENT variable and the raw message
via standard input. An example invocation would look like:
rake foodsoft:parse_reply_email RECIPIENT=f.1.1.HASH < test.eml
This commit is contained in:
Patrick Gansterer 2016-02-26 14:42:16 +01:00 committed by wvengen
parent 6b32d0c960
commit 4e35e2d58e
11 changed files with 135 additions and 11 deletions

View file

@ -80,6 +80,10 @@ class FoodsoftConfig
setup_database
end
def select_multifoodcoop(foodcoop)
select_foodcoop foodcoop if config[:multi_coop_install]
end
# Return configuration value for the currently selected foodcoop.
#
# First tries to read configuration from the database (cached),
@ -134,15 +138,20 @@ class FoodsoftConfig
keys.map(&:to_s).uniq
end
# @return [Array<String>] Valid names of foodcoops.
def foodcoops
if config[:multi_coop_install]
APP_CONFIG.keys.reject { |coop| coop =~ /^(default|development|test|production)$/ }
else
config[:default_scope]
end
end
# Loop through each foodcoop and executes the given block after setup config and database
def each_coop
if config[:multi_coop_install]
APP_CONFIG.keys.reject { |coop| coop =~ /^(default|development|test|production)$/ }.each do |coop|
select_foodcoop coop
yield coop
end
else
yield config[:default_scope]
foodcoops.each do |coop|
select_multifoodcoop coop
yield coop
end
end