Skip to content

Commit b3a9bff

Browse files
committed
List every report present only to the channel to recipients only if recipients selection is not enabled
1 parent fddfbc8 commit b3a9bff

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

backend/globaleaks/handlers/recipient/__init__.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,16 @@ def get_receivertips(session, tid, receiver_id, user_key, language, args={}):
6262
.group_by(models.ReceiverTip.internaltip_id):
6363
receiver_count_by_itip[itip_id] = count
6464

65-
# Retrieve all the contexts associated with the current receiver
66-
receiver_contexts = set()
67-
for context_id in session.query(models.ReceiverContext.context_id) \
68-
.filter(models.ReceiverContext.receiver_id == receiver_id):
69-
receiver_contexts.add(context_id[0])
65+
# Retrieve all channels that include this recipient, but only if
66+
# the recipients of those channels are not selectable.
67+
receiver_contexts = [
68+
context_id[0] for context_id in session.query(models.Context.id)
69+
.join(models.ReceiverContext,
70+
models.Context.id == models.ReceiverContext.context_id)
71+
.filter(models.Context.allow_recipients_selection == False,
72+
models.ReceiverContext.receiver_id == receiver_id
73+
).all()
74+
]
7075

7176
dict_ret = dict()
7277
# Fetch rtip, internaltip and associated questionnaire schema
@@ -79,7 +84,7 @@ def get_receivertips(session, tid, receiver_id, user_key, language, args={}):
7984
models.InternalTipData.key == 'whistleblower_identity'),
8085
isouter=True) \
8186
.filter(or_(models.InternalTip.context_id.in_(receiver_contexts),
82-
models.ReceiverTip.receiver_id == receiver_id),
87+
models.ReceiverTip.receiver_id == receiver_id),
8388
models.InternalTip.update_date >= updated_after,
8489
models.InternalTip.update_date <= updated_before,
8590
models.InternalTip.id == models.ReceiverTip.internaltip_id,

0 commit comments

Comments
 (0)