From f97be514cbc4fa30602298ef558d95cd9e689239 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Sat, 31 Aug 2019 14:44:01 +0300 Subject: [PATCH] Allow public key to be passed also as str to handle_send This allows apps to serialize sending to things like Redis easier. --- federation/outbound.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/federation/outbound.py b/federation/outbound.py index cd0fa43..d112bb1 100644 --- a/federation/outbound.py +++ b/federation/outbound.py @@ -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": , + "public_key": | 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"]