aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/Problem.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-02-11 15:42:30 +0000
committerMatthew Somerville <matthew@mysociety.org>2020-02-13 14:31:09 +0000
commitcf4f4473a795d2e1dd213f31b3d3fb4ab2711b72 (patch)
tree483a7498f7ff30a541e175b2fa460e595359a028 /perllib/FixMyStreet/DB/Result/Problem.pm
parente2e6f7babbb04d2a78dc3fbf43eb4f7865672444 (diff)
Link in other-reported email shows private report.
Use a token that does not log the user in, but lets the report be shown, even if it's a private report. Allow old tokens of that type to work.
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Problem.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm25
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.