epicyon/announce.py

546 lines
21 KiB
Python
Raw Normal View History

2020-04-01 19:11:39 +00:00
__filename__ = "announce.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "1.1.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
2019-07-02 09:25:29 +00:00
2019-10-19 18:22:43 +00:00
import os
from pprint import pprint
2019-11-24 13:46:28 +00:00
from utils import removePostFromCache
2019-07-02 09:25:29 +00:00
from utils import getStatusNumber
from utils import createOutboxDir
2019-07-02 10:43:54 +00:00
from utils import urlPermitted
2019-07-11 17:55:10 +00:00
from utils import getNicknameFromActor
from utils import getDomainFromActor
from utils import locatePost
from utils import getCachedPostFilename
2019-10-22 11:55:06 +00:00
from utils import loadJson
from utils import saveJson
2019-07-11 17:55:10 +00:00
from posts import sendSignedJson
2019-07-16 19:07:45 +00:00
from posts import getPersonBox
from session import postJson
from webfinger import webfingerHandle
from auth import createBasicAuthHeader
2019-07-02 09:25:29 +00:00
2020-04-01 19:11:39 +00:00
def outboxAnnounce(recentPostsCache: {},
baseDir: str, messageJson: {}, debug: bool) -> bool:
""" Adds or removes announce entries from the shares collection
within a given post
"""
if not messageJson.get('actor'):
return False
if not messageJson.get('type'):
return False
if not messageJson.get('object'):
return False
2020-04-01 19:11:39 +00:00
if messageJson['type'] == 'Announce':
if not isinstance(messageJson['object'], str):
2019-09-02 09:43:43 +00:00
return False
2020-04-01 19:11:39 +00:00
nickname = getNicknameFromActor(messageJson['actor'])
2019-09-02 09:43:43 +00:00
if not nickname:
print('WARN: no nickname found in '+messageJson['actor'])
return False
2020-04-01 19:11:39 +00:00
domain, port = getDomainFromActor(messageJson['actor'])
postFilename = locatePost(baseDir, nickname, domain,
messageJson['object'])
if postFilename:
2020-04-01 19:11:39 +00:00
updateAnnounceCollection(recentPostsCache, baseDir, postFilename,
messageJson['actor'], domain, debug)
return True
2020-04-01 19:11:39 +00:00
if messageJson['type'] == 'Undo':
if not isinstance(messageJson['object'], dict):
2019-09-02 09:43:43 +00:00
return False
if not messageJson['object'].get('type'):
return False
2020-04-01 19:11:39 +00:00
if messageJson['object']['type'] == 'Announce':
if not isinstance(messageJson['object']['object'], str):
2019-09-02 09:43:43 +00:00
return False
2020-04-01 19:11:39 +00:00
nickname = getNicknameFromActor(messageJson['actor'])
2019-09-02 09:43:43 +00:00
if not nickname:
2020-04-01 19:11:39 +00:00
print('WARN: no nickname found in ' + messageJson['actor'])
2019-09-02 09:43:43 +00:00
return False
2020-04-01 19:11:39 +00:00
domain, port = getDomainFromActor(messageJson['actor'])
postFilename = locatePost(baseDir, nickname, domain,
messageJson['object']['object'])
if postFilename:
2020-04-01 19:11:39 +00:00
undoAnnounceCollectionEntry(recentPostsCache,
baseDir, postFilename,
messageJson['actor'],
domain, debug)
return True
return False
2020-04-01 19:11:39 +00:00
def undoAnnounceCollectionEntry(recentPostsCache: {},
baseDir: str, postFilename: str,
actor: str, domain: str, debug: bool) -> None:
2019-11-03 15:27:29 +00:00
"""Undoes an announce for a particular actor by removing it from
2020-03-22 21:16:02 +00:00
the "shares" collection within a post. Note that the "shares"
2019-11-03 15:27:29 +00:00
collection has no relation to shared items in shares.py. It's
shares of posts, not shares of physical objects.
"""
2020-04-01 19:11:39 +00:00
postJsonObject = loadJson(postFilename)
2019-09-30 22:39:02 +00:00
if postJsonObject:
2020-03-30 19:09:45 +00:00
# remove any cached version of this announce so that the announce
# icon is changed
2020-04-01 19:11:39 +00:00
nickname = getNicknameFromActor(actor)
cachedPostFilename = getCachedPostFilename(baseDir, nickname, domain,
postJsonObject)
2019-11-29 23:04:37 +00:00
if cachedPostFilename:
if os.path.isfile(cachedPostFilename):
os.remove(cachedPostFilename)
2020-04-01 19:11:39 +00:00
removePostFromCache(postJsonObject, recentPostsCache)
if not postJsonObject.get('type'):
return
2020-04-01 19:11:39 +00:00
if postJsonObject['type'] != 'Create':
return
if not postJsonObject.get('object'):
if debug:
pprint(postJsonObject)
print('DEBUG: post has no object')
return
if not isinstance(postJsonObject['object'], dict):
return
if not postJsonObject['object'].get('shares'):
return
if not postJsonObject['object']['shares'].get('items'):
return
2020-04-01 19:11:39 +00:00
totalItems = 0
if postJsonObject['object']['shares'].get('totalItems'):
2020-04-01 19:11:39 +00:00
totalItems = postJsonObject['object']['shares']['totalItems']
itemFound = False
2019-08-01 12:18:22 +00:00
for announceItem in postJsonObject['object']['shares']['items']:
if announceItem.get('actor'):
2020-04-01 19:11:39 +00:00
if announceItem['actor'] == actor:
if debug:
2020-04-01 19:11:39 +00:00
print('DEBUG: Announce was removed for ' + actor)
anIt = announceItem
postJsonObject['object']['shares']['items'].remove(anIt)
itemFound = True
break
if itemFound:
2020-04-01 19:11:39 +00:00
if totalItems == 1:
if debug:
2020-04-01 19:11:39 +00:00
print('DEBUG: shares (announcements) ' +
'was removed from post')
2019-08-01 12:18:22 +00:00
del postJsonObject['object']['shares']
else:
2020-04-01 19:11:39 +00:00
itlen = len(postJsonObject['object']['shares']['items'])
postJsonObject['object']['shares']['totalItems'] = itlen
saveJson(postJsonObject, postFilename)
2020-04-01 19:11:39 +00:00
def updateAnnounceCollection(recentPostsCache: {},
baseDir: str, postFilename: str,
actor: str, domain: str, debug: bool) -> None:
"""Updates the announcements collection within a post
2019-11-03 15:27:29 +00:00
Confusingly this is known as "shares", but isn't the
same as shared items within shares.py
2019-08-01 10:12:10 +00:00
It's shares of posts, not shares of physical objects.
"""
2020-04-01 19:11:39 +00:00
postJsonObject = loadJson(postFilename)
2019-09-30 22:39:02 +00:00
if postJsonObject:
2019-11-19 12:52:27 +00:00
# remove any cached version of this announce so that the announce
2019-11-03 15:27:29 +00:00
# icon is changed
2020-04-01 19:11:39 +00:00
nickname = getNicknameFromActor(actor)
cachedPostFilename = getCachedPostFilename(baseDir, nickname, domain,
postJsonObject)
2019-11-29 23:04:37 +00:00
if cachedPostFilename:
if os.path.isfile(cachedPostFilename):
os.remove(cachedPostFilename)
2020-04-01 19:11:39 +00:00
removePostFromCache(postJsonObject, recentPostsCache)
if not postJsonObject.get('object'):
if debug:
pprint(postJsonObject)
2020-04-01 19:11:39 +00:00
print('DEBUG: post ' + postFilename + ' has no object')
return
if not isinstance(postJsonObject['object'], dict):
return
2020-04-01 19:11:39 +00:00
postUrl = postJsonObject['id'].replace('/activity', '') + '/shares'
if not postJsonObject['object'].get('shares'):
if debug:
2020-04-01 19:11:39 +00:00
print('DEBUG: Adding initial shares (announcements) to ' +
2019-11-03 15:27:29 +00:00
postUrl)
2020-04-01 19:11:39 +00:00
announcementsJson = {
2019-08-18 11:07:06 +00:00
"@context": "https://www.w3.org/ns/activitystreams",
'id': postUrl,
'type': 'Collection',
"totalItems": 1,
'items': [{
'type': 'Announce',
2020-03-22 21:16:02 +00:00
'actor': actor
}]
}
2020-04-01 19:11:39 +00:00
postJsonObject['object']['shares'] = announcementsJson
else:
if postJsonObject['object']['shares'].get('items'):
2020-04-01 19:11:39 +00:00
sharesItems = postJsonObject['object']['shares']['items']
for announceItem in sharesItems:
if announceItem.get('actor'):
2020-04-01 19:11:39 +00:00
if announceItem['actor'] == actor:
return
2020-04-01 19:11:39 +00:00
newAnnounce = {
'type': 'Announce',
'actor': actor
}
postJsonObject['object']['shares']['items'].append(newAnnounce)
2020-04-01 19:11:39 +00:00
itlen = len(postJsonObject['object']['shares']['items'])
postJsonObject['object']['shares']['totalItems'] = itlen
else:
if debug:
2020-04-01 19:11:39 +00:00
print('DEBUG: shares (announcements) section of post ' +
'has no items list')
if debug:
print('DEBUG: saving post with shares (announcements) added')
pprint(postJsonObject)
2020-04-01 19:11:39 +00:00
saveJson(postJsonObject, postFilename)
2020-04-01 19:11:39 +00:00
def announcedByPerson(postJsonObject: {}, nickname: str, domain: str) -> bool:
"""Returns True if the given post is announced by the given person
"""
if not postJsonObject.get('object'):
return False
if not isinstance(postJsonObject['object'], dict):
return False
# not to be confused with shared items
if not postJsonObject['object'].get('shares'):
return False
2020-04-01 19:11:39 +00:00
actorMatch = domain + '/users/' + nickname
for item in postJsonObject['object']['shares']['items']:
if item['actor'].endswith(actorMatch):
return True
return False
2020-04-01 19:11:39 +00:00
def createAnnounce(session, baseDir: str, federationList: [],
nickname: str, domain: str, port: int,
toUrl: str, ccUrl: str, httpPrefix: str,
objectUrl: str, saveToFile: bool,
clientToServer: bool,
sendThreads: [], postLog: [],
personCache: {}, cachedWebfingers: {},
debug: bool, projectVersion: str) -> {}:
2019-07-02 09:25:29 +00:00
"""Creates an announce message
Typically toUrl will be https://www.w3.org/ns/activitystreams#Public
2019-07-06 17:00:22 +00:00
and ccUrl might be a specific person favorited or repeated and the
followers url objectUrl is typically the url of the message,
corresponding to url or atomUri in createPostBase
2019-07-02 09:25:29 +00:00
"""
2020-04-01 19:11:39 +00:00
if not urlPermitted(objectUrl, federationList, "inbox:write"):
2019-07-02 10:43:54 +00:00
return None
2019-07-11 17:55:10 +00:00
if ':' in domain:
2020-04-01 19:11:39 +00:00
domain = domain.split(':')[0]
fullDomain = domain
if port:
2020-04-01 19:11:39 +00:00
if port != 80 and port != 443:
if ':' not in domain:
2020-04-01 19:11:39 +00:00
fullDomain = domain + ':' + str(port)
statusNumber, published = getStatusNumber()
newAnnounceId = httpPrefix + '://' + fullDomain + \
'/users/' + nickname + '/statuses/' + statusNumber
atomUriStr = httpPrefix + '://' + fullDomain + '/users/' + nickname + \
'/statuses/' + statusNumber
newAnnounce = {
2019-08-18 11:07:06 +00:00
"@context": "https://www.w3.org/ns/activitystreams",
2019-07-11 17:55:10 +00:00
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
2020-04-01 19:11:39 +00:00
'atomUri': atomUriStr,
2019-07-02 09:25:29 +00:00
'cc': [],
'id': newAnnounceId+'/activity',
'object': objectUrl,
'published': published,
'to': [toUrl],
'type': 'Announce'
}
if ccUrl:
2020-04-01 19:11:39 +00:00
if len(ccUrl) > 0:
newAnnounce['cc'] = [ccUrl]
2019-07-02 09:25:29 +00:00
if saveToFile:
2020-04-01 19:11:39 +00:00
outboxDir = createOutboxDir(nickname, domain, baseDir)
filename = outboxDir + '/' + newAnnounceId.replace('/', '#') + '.json'
saveJson(newAnnounce, filename)
2019-07-11 17:55:10 +00:00
2020-04-01 19:11:39 +00:00
announceNickname = None
announceDomain = None
announcePort = None
2019-10-17 22:26:47 +00:00
if '/users/' in objectUrl or \
'/channel/' in objectUrl or \
'/profile/' in objectUrl:
2020-04-01 19:11:39 +00:00
announceNickname = getNicknameFromActor(objectUrl)
announceDomain, announcePort = getDomainFromActor(objectUrl)
2019-07-11 17:55:10 +00:00
if announceNickname and announceDomain:
2020-04-01 19:11:39 +00:00
sendSignedJson(newAnnounce, session, baseDir,
nickname, domain, port,
announceNickname, announceDomain, announcePort, None,
httpPrefix, True, clientToServer, federationList,
sendThreads, postLog, cachedWebfingers, personCache,
debug, projectVersion)
2020-03-22 21:16:02 +00:00
2019-07-02 09:25:29 +00:00
return newAnnounce
2020-04-01 19:11:39 +00:00
def announcePublic(session, baseDir: str, federationList: [],
nickname: str, domain: str, port: int, httpPrefix: str,
objectUrl: str, clientToServer: bool,
sendThreads: [], postLog: [],
personCache: {}, cachedWebfingers: {},
debug: bool, projectVersion: str) -> {}:
2019-07-02 09:25:29 +00:00
"""Makes a public announcement
"""
2020-04-01 19:11:39 +00:00
fromDomain = domain
if port:
2020-04-01 19:11:39 +00:00
if port != 80 and port != 443:
if ':' not in domain:
2020-04-01 19:11:39 +00:00
fromDomain = domain + ':' + str(port)
toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomain + '/users/' + nickname + \
'/followers'
return createAnnounce(session, baseDir, federationList,
nickname, domain, port,
toUrl, ccUrl, httpPrefix,
objectUrl, True, clientToServer,
sendThreads, postLog,
personCache, cachedWebfingers,
debug, projectVersion)
def repeatPost(session, baseDir: str, federationList: [],
nickname: str, domain: str, port: int, httpPrefix: str,
announceNickname: str, announceDomain: str,
announcePort: int, announceHttpsPrefix: str,
announceStatusNumber: int, clientToServer: bool,
sendThreads: [], postLog: [],
personCache: {}, cachedWebfingers: {},
debug: bool, projectVersion: str) -> {}:
2019-07-02 14:02:58 +00:00
"""Repeats a given status post
2019-07-02 09:52:37 +00:00
"""
2020-04-01 19:11:39 +00:00
announcedDomain = announceDomain
if announcePort:
2020-04-01 19:11:39 +00:00
if announcePort != 80 and announcePort != 443:
if ':' not in announcedDomain:
2020-04-01 19:11:39 +00:00
announcedDomain = announcedDomain + ':' + str(announcePort)
objectUrl = announceHttpsPrefix + '://' + announcedDomain + '/users/' + \
announceNickname + '/statuses/' + str(announceStatusNumber)
return announcePublic(session, baseDir, federationList,
nickname, domain, port, httpPrefix,
objectUrl, clientToServer,
sendThreads, postLog,
personCache, cachedWebfingers,
debug, projectVersion)
def undoAnnounce(session, baseDir: str, federationList: [],
nickname: str, domain: str, port: int,
toUrl: str, ccUrl: str, httpPrefix: str,
objectUrl: str, saveToFile: bool,
clientToServer: bool,
sendThreads: [], postLog: [],
personCache: {}, cachedWebfingers: {},
2019-07-12 09:41:57 +00:00
debug: bool) -> {}:
"""Undoes an announce message
Typically toUrl will be https://www.w3.org/ns/activitystreams#Public
and ccUrl might be a specific person whose post was repeated and the
objectUrl is typically the url of the message which was repeated,
corresponding to url or atomUri in createPostBase
"""
2020-04-01 19:11:39 +00:00
if not urlPermitted(objectUrl, federationList, "inbox:write"):
2019-07-12 09:41:57 +00:00
return None
if ':' in domain:
2020-04-01 19:11:39 +00:00
domain = domain.split(':')[0]
fullDomain = domain
if port:
2020-04-01 19:11:39 +00:00
if port != 80 and port != 443:
if ':' not in domain:
2020-04-01 19:11:39 +00:00
fullDomain = domain + ':' + str(port)
2019-07-12 09:41:57 +00:00
2020-04-01 19:11:39 +00:00
newUndoAnnounce = {
2019-08-18 11:07:06 +00:00
"@context": "https://www.w3.org/ns/activitystreams",
2019-07-12 09:41:57 +00:00
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
'type': 'Undo',
'cc': [],
'to': [toUrl],
'object': {
'actor': httpPrefix+'://'+fullDomain+'/users/'+nickname,
'cc': [],
'object': objectUrl,
'to': [toUrl],
'type': 'Announce'
}
}
if ccUrl:
2020-04-01 19:11:39 +00:00
if len(ccUrl) > 0:
newUndoAnnounce['object']['cc'] = [ccUrl]
2019-07-12 09:41:57 +00:00
2020-04-01 19:11:39 +00:00
announceNickname = None
announceDomain = None
announcePort = None
2019-10-17 22:26:47 +00:00
if '/users/' in objectUrl or \
'/channel/' in objectUrl or \
'/profile/' in objectUrl:
2020-04-01 19:11:39 +00:00
announceNickname = getNicknameFromActor(objectUrl)
announceDomain, announcePort = getDomainFromActor(objectUrl)
2019-07-12 09:41:57 +00:00
if announceNickname and announceDomain:
2020-04-01 19:11:39 +00:00
sendSignedJson(newUndoAnnounce, session, baseDir,
nickname, domain, port,
announceNickname, announceDomain, announcePort,
'https://www.w3.org/ns/activitystreams#Public',
httpPrefix, True, clientToServer, federationList,
sendThreads, postLog, cachedWebfingers,
personCache, debug)
2020-03-22 21:16:02 +00:00
2019-07-12 09:41:57 +00:00
return newUndoAnnounce
2020-04-01 19:11:39 +00:00
def undoAnnouncePublic(session, baseDir: str, federationList: [],
nickname: str, domain: str, port: int, httpPrefix: str,
objectUrl: str, clientToServer: bool,
sendThreads: [], postLog: [],
personCache: {}, cachedWebfingers: {},
2019-07-12 09:41:57 +00:00
debug: bool) -> {}:
"""Undoes a public announcement
"""
2020-04-01 19:11:39 +00:00
fromDomain = domain
if port:
2020-04-01 19:11:39 +00:00
if port != 80 and port != 443:
if ':' not in domain:
2020-04-01 19:11:39 +00:00
fromDomain = domain + ':' + str(port)
toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomain + '/users/' + nickname + \
'/followers'
return undoAnnounce(session, baseDir, federationList,
nickname, domain, port,
toUrl, ccUrl, httpPrefix,
objectUrl, True, clientToServer,
sendThreads, postLog,
personCache, cachedWebfingers,
2019-07-12 09:41:57 +00:00
debug)
2020-04-01 19:11:39 +00:00
def undoRepeatPost(session, baseDir: str, federationList: [],
nickname: str, domain: str, port: int, httpPrefix: str,
announceNickname: str, announceDomain: str,
announcePort: int, announceHttpsPrefix: str,
announceStatusNumber: int, clientToServer: bool,
sendThreads: [], postLog: [],
personCache: {}, cachedWebfingers: {},
2019-07-12 09:41:57 +00:00
debug: bool) -> {}:
"""Undoes a status post repeat
"""
2020-04-01 19:11:39 +00:00
announcedDomain = announceDomain
if announcePort:
2020-04-01 19:11:39 +00:00
if announcePort != 80 and announcePort != 443:
if ':' not in announcedDomain:
2020-04-01 19:11:39 +00:00
announcedDomain = announcedDomain + ':' + str(announcePort)
2019-07-12 09:41:57 +00:00
2020-04-01 19:11:39 +00:00
objectUrl = announceHttpsPrefix + '://' + announcedDomain + '/users/' + \
announceNickname + '/statuses/' + str(announceStatusNumber)
2019-07-12 09:41:57 +00:00
2020-04-01 19:11:39 +00:00
return undoAnnouncePublic(session, baseDir, federationList,
nickname, domain, port, httpPrefix,
objectUrl, clientToServer,
sendThreads, postLog,
personCache, cachedWebfingers,
2019-07-12 09:41:57 +00:00
debug)
2019-07-16 19:07:45 +00:00
2020-04-01 19:11:39 +00:00
def sendAnnounceViaServer(baseDir: str, session,
fromNickname: str, password: str,
fromDomain: str, fromPort: int,
httpPrefix: str, repeatObjectUrl: str,
cachedWebfingers: {}, personCache: {},
debug: bool, projectVersion: str) -> {}:
2019-07-16 19:07:45 +00:00
"""Creates an announce message via c2s
"""
if not session:
print('WARN: No session for sendAnnounceViaServer')
return 6
2020-04-01 19:11:39 +00:00
fromDomainFull = fromDomain
if fromPort:
2020-04-01 19:11:39 +00:00
if fromPort != 80 and fromPort != 443:
if ':' not in fromDomain:
2020-04-01 19:11:39 +00:00
fromDomainFull = fromDomain + ':' + str(fromPort)
2019-07-16 19:07:45 +00:00
2020-04-01 19:11:39 +00:00
toUrl = 'https://www.w3.org/ns/activitystreams#Public'
ccUrl = httpPrefix + '://' + fromDomainFull + '/users/' + fromNickname + \
'/followers'
2019-07-16 19:07:45 +00:00
2020-04-01 19:11:39 +00:00
statusNumber, published = getStatusNumber()
newAnnounceId = httpPrefix + '://' + fromDomainFull + '/users/' + \
fromNickname + '/statuses/' + statusNumber
newAnnounceJson = {
2019-08-18 11:07:06 +00:00
"@context": "https://www.w3.org/ns/activitystreams",
2019-07-16 19:07:45 +00:00
'actor': httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname,
'atomUri': newAnnounceId,
'cc': [ccUrl],
'id': newAnnounceId+'/activity',
'object': repeatObjectUrl,
'published': published,
'to': [toUrl],
'type': 'Announce'
}
2020-04-01 19:11:39 +00:00
handle = httpPrefix + '://' + fromDomainFull + '/@' + fromNickname
2019-07-16 19:07:45 +00:00
# lookup the inbox for the To handle
2020-04-01 19:11:39 +00:00
wfRequest = webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
fromDomain, projectVersion)
2019-07-16 19:07:45 +00:00
if not wfRequest:
if debug:
2020-04-01 19:11:39 +00:00
print('DEBUG: announce webfinger failed for ' + handle)
2019-07-16 19:07:45 +00:00
return 1
2020-04-01 19:11:39 +00:00
postToBox = 'outbox'
2019-07-16 19:07:45 +00:00
# get the actor inbox for the To handle
2020-04-01 19:11:39 +00:00
(inboxUrl, pubKeyId, pubKey, fromPersonId,
sharedInbox, capabilityAcquisition,
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
personCache,
projectVersion, httpPrefix,
fromNickname, fromDomain,
postToBox)
2020-03-22 21:16:02 +00:00
2019-07-16 19:07:45 +00:00
if not inboxUrl:
if debug:
2020-04-01 19:11:39 +00:00
print('DEBUG: No ' + postToBox + ' was found for ' + handle)
2019-07-16 19:07:45 +00:00
return 3
if not fromPersonId:
if debug:
2020-04-01 19:11:39 +00:00
print('DEBUG: No actor was found for ' + handle)
2019-07-16 19:07:45 +00:00
return 4
2020-03-22 21:16:02 +00:00
2020-04-01 19:11:39 +00:00
authHeader = createBasicAuthHeader(fromNickname, password)
2020-03-22 21:16:02 +00:00
2020-04-01 19:11:39 +00:00
headers = {
'host': fromDomain,
'Content-type': 'application/json',
2020-03-22 20:36:19 +00:00
'Authorization': authHeader
}
2020-04-01 19:11:39 +00:00
postResult = postJson(session, newAnnounceJson, [], inboxUrl,
headers, "inbox:write")
if not postResult:
print('WARN: Announce not posted')
2019-07-16 19:07:45 +00:00
if debug:
print('DEBUG: c2s POST announce success')
return newAnnounceJson