From 3766f6e9c1f25b8d901d5c2e15dc6c08a8ef861b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 15 Jun 2020 14:38:21 +0100 Subject: [PATCH] Only jsonld sign if a previous signature does not exist --- posts.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/posts.py b/posts.py index 88db61ef..6f0ff055 100644 --- a/posts.py +++ b/posts.py @@ -1419,12 +1419,13 @@ def sendPost(projectVersion: str, return 7 postPath = inboxUrl.split(toDomain, 1)[1] - try: - signedPostJsonObject = jsonldSign(postJsonObject, privateKeyPem) - postJsonObject = signedPostJsonObject - except BaseException: - print('WARN: failed to JSON-LD sign post') - pass + if not postJsonObject.get('signature'): + try: + signedPostJsonObject = jsonldSign(postJsonObject, privateKeyPem) + postJsonObject = signedPostJsonObject + except BaseException: + print('WARN: failed to JSON-LD sign post') + pass # convert json to string so that there are no # subsequent conversions after creating message body digest @@ -1749,12 +1750,13 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str, addFollowersToPublicPost(postJsonObject) - try: - signedPostJsonObject = jsonldSign(postJsonObject, privateKeyPem) - postJsonObject = signedPostJsonObject - except BaseException: - print('WARN: failed to JSON-LD sign post') - pass + if not postJsonObject.get('signature'): + try: + signedPostJsonObject = jsonldSign(postJsonObject, privateKeyPem) + postJsonObject = signedPostJsonObject + except BaseException: + print('WARN: failed to JSON-LD sign post') + pass # convert json to string so that there are no # subsequent conversions after creating message body digest