Allow public key to be passed also as str to handle_send

This allows apps to serialize sending to things like Redis easier.
mentions
Jason Robinson 2019-08-31 14:44:01 +03:00
rodzic e5dd3db0dc
commit f97be514cb
1 zmienionych plików z 4 dodań i 1 usunięć

Wyświetl plik

@ -4,6 +4,7 @@ import logging
from typing import List, Dict, Union
# noinspection PyPackageRequirements
from Crypto.PublicKey import RSA
from Crypto.PublicKey.RSA import RsaKey
from iteration_utilities import unique_everseen
@ -87,7 +88,7 @@ def handle_send(
"fid": "",
"protocol": "diaspora",
"public": False,
"public_key": <RSAPublicKey object>,
"public_key": <RSAPublicKey object> | str,
},
{
"endpoint": "https://domain2.tld/receive/public",
@ -135,6 +136,8 @@ def handle_send(
endpoint = recipient["endpoint"]
fid = recipient["fid"]
public_key = recipient.get("public_key")
if isinstance(public_key, str):
public_key = RSA.importKey(public_key)
protocol = recipient["protocol"]
public = recipient["public"]