diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 61 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tokens.pm | 4 |
3 files changed, 32 insertions, 34 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index b8f038ce3..f8ea84d08 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -195,6 +195,7 @@ sub display_location : Private { colour => $colour, id => $p->id, title => $p->title_safe, + problem => $p, } } @$on_map_all, @$around_map; } diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index c4a2162a8..e81dc719f 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -143,22 +143,11 @@ sub report_new_ajax : Path('mobile') : Args(0) { $c->forward('save_user_and_report'); my $report = $c->stash->{report}; - my $data = $c->stash->{token_data} || {}; - my $token = $c->model("DB::Token")->create( { - scope => 'problem', - data => { - %$data, - id => $report->id - } - } ); if ( $report->confirmed ) { $c->forward( 'create_reporter_alert' ); $c->stash->{ json_response } = { success => 1, report => $report->id }; } else { - $c->stash->{token_url} = $c->uri_for_email( '/P', $token->token ); - $c->send_email( 'problem-confirm.txt', { - to => [ $report->name ? [ $report->user->email, $report->name ] : $report->user->email ], - } ); + $c->forward( 'send_problem_confirm_email' ); $c->stash->{ json_response } = { success => 1 }; } @@ -1021,6 +1010,31 @@ sub tokenize_user : Private { if $c->get_param('oauth_need_email') && $c->session->{oauth}{twitter_id}; } +sub send_problem_confirm_email : Private { + my ( $self, $c ) = @_; + my $data = $c->stash->{token_data} || {}; + my $report = $c->stash->{report}; + my $token = $c->model("DB::Token")->create( { + scope => 'problem', + data => { + %$data, + id => $report->id + } + } ); + + my $template = 'problem-confirm.txt'; + $template = 'problem-confirm-not-sending.txt' unless $report->bodies_str; + + $c->stash->{token_url} = $c->uri_for_email( '/P', $token->token ); + if ($c->cobrand->can('problem_confirm_email_extras')) { + $c->cobrand->problem_confirm_email_extras($report); + } + + $c->send_email( $template, { + to => [ $report->name ? [ $report->user->email, $report->name ] : $report->user->email ], + } ); +} + =head2 save_user_and_report Save the user and the report. @@ -1178,30 +1192,13 @@ sub redirect_or_confirm_creation : Private { return 1; } - my $template = 'problem-confirm.txt'; - $template = 'problem-confirm-not-sending.txt' unless $report->bodies_str; - - # otherwise create a confirm token and email it to them. - my $data = $c->stash->{token_data} || {}; - my $token = $c->model("DB::Token")->create( { - scope => 'problem', - data => { - %$data, - id => $report->id - } - } ); - $c->stash->{token_url} = $c->uri_for_email( '/P', $token->token ); - if ($c->cobrand->can('problem_confirm_email_extras')) { - $c->cobrand->problem_confirm_email_extras($report); - } - $c->send_email( $template, { - to => [ $report->name ? [ $report->user->email, $report->name ] : $report->user->email ], - } ); + # otherwise email a confirm token to them. + $c->forward( 'send_problem_confirm_email' ); # tell user that they've been sent an email $c->stash->{template} = 'email_sent.html'; $c->stash->{email_type} = 'problem'; - $c->log->info($report->user->id . ' created ' . $report->id . ', email sent, ' . ($data->{password} ? 'password set' : 'password not set')); + $c->log->info($report->user->id . ' created ' . $report->id . ', email sent, ' . ($c->stash->{token_data}->{password} ? 'password set' : 'password not set')); } sub create_reporter_alert : Private { diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index 38f344250..da017c57f 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -32,7 +32,7 @@ sub confirm_problem : Path('/P') { $c->stash->{report} = { id => 123, title => 'Title of Report', - bodies_str => 'True', + bodies_str => '1', url => '/report/123', service => $c->get_param('service'), }; @@ -195,7 +195,7 @@ sub confirm_update : Path('/C') { $c->stash->{problem} = { id => 123, title => 'Title of Report', - bodies_str => 'True', + bodies_str => '1', url => '/report/123', }; return; |