diff --git a/announce.py b/announce.py index 098cb8820..97c9d4fb1 100644 --- a/announce.py +++ b/announce.py @@ -253,7 +253,8 @@ def sendAnnounceViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, newAnnounceJson, [], inboxUrl, + postResult = postJson(httpPrefix, fromDomainFull, + session, newAnnounceJson, [], inboxUrl, headers, 3, True) if not postResult: print('WARN: announce not posted') @@ -332,7 +333,8 @@ def sendUndoAnnounceViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, unAnnounceJson, [], inboxUrl, + postResult = postJson(httpPrefix, domainFull, + session, unAnnounceJson, [], inboxUrl, headers, 3, True) if not postResult: print('WARN: undo announce not posted') diff --git a/availability.py b/availability.py index 441b01264..9df2173bd 100644 --- a/availability.py +++ b/availability.py @@ -143,7 +143,8 @@ def sendAvailabilityViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, newAvailabilityJson, [], + postResult = postJson(httpPrefix, domainFull, + session, newAvailabilityJson, [], inboxUrl, headers, 30, True) if not postResult: print('WARN: availability failed to post') diff --git a/bookmarks.py b/bookmarks.py index 04a68052b..58a772b3d 100644 --- a/bookmarks.py +++ b/bookmarks.py @@ -418,7 +418,8 @@ def sendBookmarkViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, newBookmarkJson, [], inboxUrl, + postResult = postJson(httpPrefix, domainFull, + session, newBookmarkJson, [], inboxUrl, headers, 3, True) if not postResult: if debug: @@ -502,7 +503,8 @@ def sendUndoBookmarkViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, newBookmarkJson, [], inboxUrl, + postResult = postJson(httpPrefix, domainFull, + session, newBookmarkJson, [], inboxUrl, headers, 3, True) if not postResult: if debug: diff --git a/delete.py b/delete.py index 0566015d6..05ceb051d 100644 --- a/delete.py +++ b/delete.py @@ -93,7 +93,8 @@ def sendDeleteViaServer(baseDir: str, session, 'Authorization': authHeader } postResult = \ - postJson(session, newDeleteJson, [], inboxUrl, headers, 3, True) + postJson(httpPrefix, fromDomainFull, + session, newDeleteJson, [], inboxUrl, headers, 3, True) if not postResult: if debug: print('DEBUG: POST delete failed for c2s to ' + inboxUrl) diff --git a/follow.py b/follow.py index 0b1ecbc4d..f7a48ed10 100644 --- a/follow.py +++ b/follow.py @@ -1029,7 +1029,8 @@ def sendFollowRequestViaServer(baseDir: str, session, 'Authorization': authHeader } postResult = \ - postJson(session, newFollowJson, [], inboxUrl, headers, 3, True) + postJson(httpPrefix, fromDomainFull, + session, newFollowJson, [], inboxUrl, headers, 3, True) if not postResult: if debug: print('DEBUG: POST follow request failed for c2s to ' + inboxUrl) @@ -1122,7 +1123,8 @@ def sendUnfollowRequestViaServer(baseDir: str, session, 'Authorization': authHeader } postResult = \ - postJson(session, unfollowJson, [], inboxUrl, headers, 3, True) + postJson(httpPrefix, fromDomainFull, + session, unfollowJson, [], inboxUrl, headers, 3, True) if not postResult: if debug: print('DEBUG: POST unfollow failed for c2s to ' + inboxUrl) diff --git a/like.py b/like.py index 646913043..7e5d51374 100644 --- a/like.py +++ b/like.py @@ -205,7 +205,8 @@ def sendLikeViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, newLikeJson, [], inboxUrl, + postResult = postJson(httpPrefix, fromDomainFull, + session, newLikeJson, [], inboxUrl, headers, 3, True) if not postResult: if debug: @@ -287,7 +288,8 @@ def sendUndoLikeViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, newUndoLikeJson, [], inboxUrl, + postResult = postJson(httpPrefix, fromDomainFull, + session, newUndoLikeJson, [], inboxUrl, headers, 3, True) if not postResult: if debug: diff --git a/pgp.py b/pgp.py index b32958603..619bad3d5 100644 --- a/pgp.py +++ b/pgp.py @@ -588,7 +588,8 @@ def pgpPublicKeyUpload(baseDir: str, session, tries = 0 while tries < 4: postResult = \ - postJson(session, actorUpdate, [], inboxUrl, + postJson(httpPrefix, domainFull, + session, actorUpdate, [], inboxUrl, headers, 5, quiet) if postResult: break diff --git a/posts.py b/posts.py index 862705234..6e275d45f 100644 --- a/posts.py +++ b/posts.py @@ -4198,7 +4198,8 @@ def sendBlockViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, newBlockJson, [], inboxUrl, + postResult = postJson(httpPrefix, fromDomainFull, + session, newBlockJson, [], inboxUrl, headers, 30, True) if not postResult: print('WARN: block unable to post') @@ -4273,7 +4274,8 @@ def sendMuteViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, newMuteJson, [], inboxUrl, + postResult = postJson(httpPrefix, fromDomainFull, + session, newMuteJson, [], inboxUrl, headers, 3, True) if postResult is None: print('WARN: mute unable to post') @@ -4354,7 +4356,8 @@ def sendUndoMuteViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, undoMuteJson, [], inboxUrl, + postResult = postJson(httpPrefix, fromDomainFull, + session, undoMuteJson, [], inboxUrl, headers, 3, True) if postResult is None: print('WARN: undo mute unable to post') @@ -4438,7 +4441,8 @@ def sendUndoBlockViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, newBlockJson, [], inboxUrl, + postResult = postJson(httpPrefix, fromDomainFull, + session, newBlockJson, [], inboxUrl, headers, 30, True) if not postResult: print('WARN: unblock unable to post') diff --git a/session.py b/session.py index 0c4de0b39..f6ccfbb3a 100644 --- a/session.py +++ b/session.py @@ -149,7 +149,8 @@ def getJson(session, url: str, headers: {}, params: {}, debug: bool, return None -def postJson(session, postJsonObject: {}, federationList: [], +def postJson(httpPrefix: str, domainFull: str, + session, postJsonObject: {}, federationList: [], inboxUrl: str, headers: {}, timeoutSec: int = 60, quiet: bool = False) -> str: """Post a json message to the inbox of another person @@ -160,6 +161,11 @@ def postJson(session, postJsonObject: {}, federationList: [], print('postJson: ' + inboxUrl + ' not permitted') return None + sessionHeaders = headers + sessionHeaders['User-Agent'] = 'Epicyon/' + __version__ + sessionHeaders['User-Agent'] += \ + '; +' + httpPrefix + '://' + domainFull + '/' + try: postResult = \ session.post(url=inboxUrl, diff --git a/shares.py b/shares.py index 467209750..4fb62daad 100644 --- a/shares.py +++ b/shares.py @@ -410,7 +410,8 @@ def sendShareViaServer(baseDir, session, 'Authorization': authHeader } postResult = \ - postJson(session, newShareJson, [], inboxUrl, headers, 30, True) + postJson(httpPrefix, fromDomainFull, + session, newShareJson, [], inboxUrl, headers, 30, True) if not postResult: if debug: print('DEBUG: POST share failed for c2s to ' + inboxUrl) @@ -500,7 +501,8 @@ def sendUndoShareViaServer(baseDir: str, session, 'Authorization': authHeader } postResult = \ - postJson(session, undoShareJson, [], inboxUrl, + postJson(httpPrefix, fromDomainFull, + session, undoShareJson, [], inboxUrl, headers, 30, True) if not postResult: if debug: diff --git a/skills.py b/skills.py index d2e8a8306..dae7d567b 100644 --- a/skills.py +++ b/skills.py @@ -246,7 +246,8 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str, 'Authorization': authHeader } postResult = \ - postJson(session, newSkillJson, [], inboxUrl, + postJson(httpPrefix, domainFull, + session, newSkillJson, [], inboxUrl, headers, 30, True) if not postResult: if debug: