diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-02-14 09:22:15 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-02-14 09:22:15 +0000 |
commit | f5744500d82c8a3cf2a70ce0544d778579b1694a (patch) | |
tree | dc2e27b73cf97111754e273bff6bb256d9c9fee6 /perllib/FixMyStreet/DB/Result/Problem.pm | |
parent | 88e1827bd645f36be074f95eea25d1f539f1aecc (diff) | |
parent | 3e00fa1c74c92bf902b1d41d524ad79a1554e835 (diff) |
Merge branch 'private-in-email'
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index f10f1f7ec..b68c228b9 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -525,6 +525,31 @@ sub tokenised_url { return "/M/". $token->token; } +has view_token => ( + is => 'ro', + lazy => 1, + default => sub { + my $self = shift; + my $token = FixMyStreet::App->model('DB::Token')->create({ + scope => 'alert_to_reporter', + data => { id => $self->id } + }); + }, +); + +=head2 view_url + +Return a url for this problem report that will always show it +(even if e.g. a private report) but does not log the user in. + +=cut + +sub view_url { + my $self = shift; + return $self->url unless $self->non_public; + return "/R/" . $self->view_token->token; +} + =head2 is_hidden Returns 1 if the problem is in an hidden state otherwise 0. |