Add gui/presenters/interpret_key_results.py
Improved Clarity on Key Check Messages for GUI
This commit is contained in:
parent
2e735c7303
commit
66dacf1b3f
1 changed files with 35 additions and 0 deletions
35
gui/presenters/interpret_key_results.py
Normal file
35
gui/presenters/interpret_key_results.py
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
def interpret_key_results(result: dict) -> str:
|
||||||
|
if not isinstance(result, dict):
|
||||||
|
return "There was an error with the format of the reply from the operation."
|
||||||
|
|
||||||
|
# unpack results:
|
||||||
|
valid = result.get('valid', False)
|
||||||
|
comparison = result.get('comparison', 'error')
|
||||||
|
error_msg = result.get('message', None)
|
||||||
|
|
||||||
|
# errors:
|
||||||
|
if error_msg:
|
||||||
|
if error_msg == "api_connection_issue":
|
||||||
|
return "There was a connection error with connecting to the API."
|
||||||
|
elif error_msg == "invalid_key":
|
||||||
|
return "Your original public key is in an invalid format to begin with."
|
||||||
|
else:
|
||||||
|
return "Unknown Error."
|
||||||
|
|
||||||
|
# comparison:
|
||||||
|
if comparison == "same":
|
||||||
|
first_sentance = "The key you had locally matched what the server had also."
|
||||||
|
elif comparison == "different":
|
||||||
|
first_sentance = "Your local key was different than the server's key."
|
||||||
|
else:
|
||||||
|
first_sentance = "There was an error with the comparison."
|
||||||
|
|
||||||
|
# validity:
|
||||||
|
if valid:
|
||||||
|
second_sentance = "The signature now matches with the new key."
|
||||||
|
else:
|
||||||
|
second_sentance = "But the signature still does not match, even with the new key. If you prepare tickets anyway, they might not verify when used."
|
||||||
|
|
||||||
|
# final return
|
||||||
|
final_msg = first_sentance + " " + second_sentance
|
||||||
|
return final_msg
|
||||||
Loading…
Reference in a new issue