Skip to content

Commit

Permalink
🩹 Do not send link users can't read in problem report resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
pajowu committed Oct 8, 2024
1 parent 355b5f6 commit 4469f6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions froide/problem/templates/problem/email_problem_resolved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
{% blocktrans with title=title %}We have resolved the problem you reported on the request “{{ title }}”.{% endblocktrans %}
{% endif %}
{% if report.resolution %}{{ report.resolution }}{% endif %}
{% if can_read_request %}

{% trans "You can go to the request here:" %}

{{ url }}
{% endif %}
{% blocktrans with site_name=site_name %}
Cheers,
{{ site_name }}{% endblocktrans %}
Expand Down
12 changes: 12 additions & 0 deletions froide/problem/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from django.conf import settings
from django.core.mail import mail_managers
from django.template.loader import render_to_string
from django.test import RequestFactory
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

from froide.foirequest.auth import can_read_foirequest


def inform_managers(report):
admin_url = settings.SITE_URL + reverse(
Expand All @@ -23,6 +26,14 @@ def inform_managers(report):
)


def can_read(user, foirequest):
request_factory = RequestFactory()
request = request_factory.get(foirequest.get_absolute_url())
request.user = user

can_read_foirequest(foirequest, request)


def inform_user_problem_resolved(report):
if report.auto_submitted or not report.user:
return False
Expand All @@ -39,6 +50,7 @@ def inform_user_problem_resolved(report):
report.message.get_absolute_short_url()
),
"site_name": settings.SITE_NAME,
"can_read_request": can_read(report.user, foirequest),
},
)

Expand Down

0 comments on commit 4469f6d

Please sign in to comment.