Skip to content

Commit 4adacbf

Browse files
committed
Added utils.get_suid_from_uuid function to ensure parameters are identical
1 parent e83e61c commit 4adacbf

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/imio/esign/utils.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,10 @@ def remove_session(session_id):
385385
# logger.info("Session %s removed", session_id)
386386

387387

388-
def get_file_download_url(uid, separator="-", block_size=5, root_url=None, short_uid=None):
388+
def get_file_download_url(uid, root_url=None, short_uid=None):
389389
"""Get the file download URL for a given file UID.
390390
391391
:param uid: file UID
392-
:param separator: separator used in short UID encoding
393-
:param block_size: block size used in short UID encoding
394392
:param root_url: root URL. If not provided, the settings value is used
395393
:param short_uid: take this short UID instead of computing it
396394
:return: file download URL, short_uid
@@ -401,7 +399,7 @@ def get_file_download_url(uid, separator="-", block_size=5, root_url=None, short
401399
if not root_url:
402400
raise Exception("No root URL provided for file download url.")
403401
if not short_uid:
404-
short_uid = shortuid_encode_id(uid, separator=separator, block_size=block_size)
402+
short_uid = get_suid_from_uuid(uid)
405403
return "{}/{}".format(root_url.strip('/'), short_uid), short_uid
406404

407405

@@ -416,3 +414,12 @@ def get_max_download_date(obj, delta=timedelta(days=90), adate=None):
416414
if adate is None:
417415
adate = obj.modified().asdatetime().date()
418416
return adate + delta
417+
418+
419+
def get_suid_from_uuid(uid):
420+
"""Get the short UID from a given UUID.
421+
422+
:param uid: UUID
423+
:return: short UID
424+
"""
425+
return shortuid_encode_id(uid, separator="-", block_size=5)

0 commit comments

Comments
 (0)