Skip to content

Commit

Permalink
Add do-not-reply config variable, removing special case from code.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jan 2, 2013
1 parent 2db12c5 commit 16e4d3b
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 18 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ before_script:
-e "s,cobrand_two: 'hostname_substring2',fixmystreet: 'localhost',"
-e "s,(BASE_URL:) 'http://www.example.org',\\1 'http://localhost',"
-e "s,(MAPIT_URL:) '',\\1 'http://mapit.mysociety.org/',"
-e "s,(CONTACT_EMAIL:) 'team,\\1 'person,"
conf/general.yml-example > conf/general.yml
- ./bin/cron-wrapper ./bin/make_po FixMyStreet-EmptyHomes
- ./bin/cron-wrapper ./bin/make_emptyhomes_welsh_po
Expand Down
1 change: 1 addition & 0 deletions bin/install-as-user
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ sed -r \
-e "s,^( *BASE_URL:).*,\\1 'http://$HOST'," \
-e "s,^( *EMAIL_DOMAIN:).*,\\1 '$HOST'," \
-e "s,^( *CONTACT_EMAIL:).*,\\1 'help@$HOST'," \
-e "s,^( *DO_NOT_REPLY_EMAIL:).*,\\1 'help@$HOST'," \
conf/general.yml-example > conf/general.yml

# Create the database if it doesn't exist:
Expand Down
4 changes: 4 additions & 0 deletions conf/general.yml-example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ BASE_URL: 'http://www.example.org'
EMAIL_DOMAIN: 'example.org'
CONTACT_EMAIL: 'team@example.org'
CONTACT_NAME: 'FixMyStreet'
# Address used for emails you don't expect a reply to (e.g. confirmation
# emails); can be same as CONTACT_EMAIL above, of course, if you don't have a
# special address.
DO_NOT_REPLY_EMAIL: 'do-not-reply@example.org'

# Whether this is a development site or not.
STAGING_SITE: 1
Expand Down
3 changes: 1 addition & 2 deletions perllib/FixMyStreet/App.pm
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,8 @@ sub send_email {
my $template = shift;
my $extra_stash_values = shift || {};

my $sender = $c->cobrand->contact_email;
my $sender = $c->config->{DO_NOT_REPLY_EMAIL};
my $sender_name = $c->cobrand->contact_name;
$sender =~ s/team/fms-DO-NOT-REPLY/;

# create the vars to pass to the email template
my $vars = {
Expand Down
4 changes: 2 additions & 2 deletions perllib/FixMyStreet/App/Controller/Contact.pm
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ generally required to stash
sub setup_request : Private {
my ( $self, $c ) = @_;

$c->stash->{contact_email} = $c->cobrand->contact_email( 'contact' );
$c->stash->{contact_email} = $c->cobrand->contact_email;
$c->stash->{contact_email} =~ s/\@/@/;

for my $param (qw/em subject message/) {
Expand All @@ -206,7 +206,7 @@ Sends the email
sub send_email : Private {
my ( $self, $c ) = @_;

my $recipient = $c->cobrand->contact_email( 'contact' );
my $recipient = $c->cobrand->contact_email;
my $recipient_name = $c->cobrand->contact_name();

$c->stash->{host} = $c->req->header('HOST');
Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/App/Controller/Open311.pm
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ sub error : Private {
sub get_discovery : Private {
my ( $self, $c ) = @_;

my $contact_email = $c->config->{CONTACT_EMAIL};
my $contact_email = $c->cobrand->contact_email;
my $prod_url = 'http://www.fiksgatami.no/open311';
my $test_url = 'http://fiksgatami-dev.nuug.no/open311';
my $prod_changeset = '2011-04-08T00:00:00Z';
Expand Down
4 changes: 1 addition & 3 deletions perllib/FixMyStreet/Cobrand/Bromley.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ sub process_extras {

sub contact_email {
my $self = shift;
my $type = shift || '';
return join( '@', 'info', 'bromley.gov.uk' ) if $type eq 'contact';
return $self->next::method();
return join( '@', 'info', 'bromley.gov.uk' );
}
sub contact_name { 'Bromley Council (do not reply)'; }

Expand Down
5 changes: 2 additions & 3 deletions perllib/FixMyStreet/DB/ResultSet/AlertType.pm
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,12 @@ sub _send_aggregated_alert_email(%) {
unless -e $template;
$template = Utils::read_file($template);

my $sender = $cobrand->contact_email;
(my $from = $sender) =~ s/team/fms-DO-NOT-REPLY/; # XXX
my $sender = FixMyStreet->config('DO_NOT_REPLY_EMAIL');
my $result = FixMyStreet::App->send_email_cron(
{
_template_ => $template,
_parameters_ => \%data,
From => [ $from, _($cobrand->contact_name) ],
From => [ $sender, _($cobrand->contact_name) ],
To => $data{alert_email},
},
$sender,
Expand Down
3 changes: 1 addition & 2 deletions perllib/FixMyStreet/DB/ResultSet/Questionnaire.pm
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ sub send_questionnaires_period {
} );
$h{url} = $cobrand->base_url($row->cobrand_data) . '/Q/' . $token->token;

my $sender = $cobrand->contact_email;
my $sender = FixMyStreet->config('DO_NOT_REPLY_EMAIL');
my $sender_name = _($cobrand->contact_name);
$sender =~ s/team/fms-DO-NOT-REPLY/;

print "Sending questionnaire " . $questionnaire->id . ", problem "
. $row->id . ", token " . $token->token . " to "
Expand Down
5 changes: 1 addition & 4 deletions perllib/FixMyStreet/EmailSend.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ package FixMyStreet::EmailSend;
use base Email::Send::SMTP;

sub get_env_sender {
# Should really use cobrand's contact_email function, but not sure how
# best to access that from in here.
my $sender = FixMyStreet->config('CONTACT_EMAIL');
$sender =~ s/team/fms-DO-NOT-REPLY/;
my $sender = FixMyStreet->config('DO_NOT_REPLY_EMAIL');
return $sender;
}

Expand Down

0 comments on commit 16e4d3b

Please sign in to comment.