Skip to content

Commit

Permalink
Update rtip.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Emanuele Bosu committed Nov 14, 2024
1 parent 700dba0 commit 1eaa3b9
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions backend/globaleaks/handlers/recipient/rtip.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,16 +1571,7 @@ def wrap_retry_fs_copy_file(self, session, source_id, source_prv_key):

@transact
def forward_file(self, session, rfile_id, itip_id, visibility):
if b'tids' in self.request.args:
try:
tids = ast.literal_eval(self.request.args.get(b"tids", [])[0].decode())
if not isinstance(tids, list):
raise ValueError('is not a list')
except Exception as e:
logging.debug(e)
tids = []
else:
tids = []
tids = self.extract_tids()

rtip = db_get(session, models.ReceiverTip, (models.ReceiverTip.receiver_id == self.session.user_id,
models.ReceiverTip.internaltip_id == itip_id))
Expand All @@ -1607,15 +1598,27 @@ def upload_file(self, session, tid, user_id, itip_id, uploaded_file):
session, tid, user_id, itip_id, uploaded_file)
return response

def extract_tids(self):
if b'tids' in self.request.args:
try:
tids = ast.literal_eval(self.request.args.get(b"tids", [])[0].decode())
if not isinstance(tids, list):
raise ValueError('is not a list')
return tids
except Exception as e:
logging.debug(e)
return []

@inlineCallbacks
def process(self, tid, user_id, itip_id, uploaded_file):
ret = yield self.upload_file(tid, user_id, itip_id, uploaded_file)

if not isinstance(uploaded_file.get('visibility'), int):
uploaded_file['visibility'] = uploaded_file['visibility'].decode()

deferToThread(
self.forward_file, self.uploaded_file['filename'], itip_id, uploaded_file['visibility'])
if self.extract_tids():
deferToThread(
self.forward_file, self.uploaded_file['filename'], itip_id, uploaded_file['visibility'])
return ret

def post(self, itip_id):
Expand Down

0 comments on commit 1eaa3b9

Please sign in to comment.