Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 Do not send link users can't read in problem report resolution #764

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions froide/foirequest/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.conf import settings
from django.db.models import Q
from django.http import HttpRequest
from django.test import RequestFactory
from django.urls import reverse
from django.utils.crypto import constant_time_compare, salted_hmac
from django.utils.translation import override
Expand All @@ -25,6 +26,13 @@
from .models import FoiAttachment, FoiMessage, FoiProject, FoiRequest


def get_request_for_user(user, path: str):
request_factory = RequestFactory()
request = request_factory.get(path)
request.user = user
return request


def get_campaign_auth_foirequests_filter(request: HttpRequest, fk_path=None):
if not request.user.is_staff:
return None
Expand Down
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
8 changes: 8 additions & 0 deletions froide/problem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from django.urls import reverse
from django.utils.translation import gettext_lazy as _

from froide.foirequest.auth import can_read_foirequest, get_request_for_user


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


def can_read(user, foirequest):
request = get_request_for_user(user, foirequest.get_absolute_url())
return 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 +46,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