Add jsonld signatures to posts

main
Bob Mottram 2020-06-15 14:08:19 +01:00
parent e5200139db
commit 8af75436b6
1 changed files with 15 additions and 0 deletions

View File

@ -53,6 +53,7 @@ from blocking import isBlocked
from filters import isFiltered
from git import convertPostToPatch
from semantic import labelAccusatoryPost
from jsonldsig import jsonldSign
# try:
# from BeautifulSoup import BeautifulSoup
# except ImportError:
@ -1418,6 +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
# convert json to string so that there are no
# subsequent conversions after creating message body digest
postJsonStr = json.dumps(postJsonObject)
@ -1741,6 +1749,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
# convert json to string so that there are no
# subsequent conversions after creating message body digest
postJsonStr = json.dumps(postJsonObject)