🩹 add alias duplication avoiding logic
This commit is contained in:
parent
6799af0572
commit
d067faed7b
|
@ -37,9 +37,11 @@ class Views(
|
|||
def generate_alias_id(self, chat):
|
||||
chat_id = chat.id
|
||||
title = chat.title
|
||||
|
||||
while True:
|
||||
orig_id = f"{title}{chat_id}" # the original id
|
||||
alias_id = base64.urlsafe_b64encode(hashlib.md5(orig_id.encode()).digest())[:self.url_len].decode()
|
||||
orig_id = f"{chat_id}" # the original id
|
||||
unique_hash = hashlib.md5(orig_id.encode()).digest()
|
||||
alias_id = base64.urlsafe_b64encode(unique_hash).decode()[:self.url_len]
|
||||
|
||||
if alias_id in self.chat_ids:
|
||||
self.url_len += 1 # increment url_len just incase the hash is already used.
|
||||
|
|
Loading…
Reference in New Issue