Commit ActivityPub type

main
Bob Mottram 2020-05-03 10:56:29 +00:00
parent 7c6b2fd05f
commit 08f19f2e8d
4 changed files with 8 additions and 0 deletions

4
git.py
View File

@ -41,9 +41,13 @@ def getGitProjectName(baseDir: str, nickname: str, domain: str,
def isGitPatch(baseDir: str, nickname: str, domain: str,
messageType: str,
subject: str, content: str) -> bool:
"""Is the given post content a git patch?
"""
if messageType != 'Note' and \
messageType != 'Commit':
return False
# must have a subject line
if not subject:
return False

View File

@ -1581,6 +1581,7 @@ def validPostContent(baseDir: str, nickname: str, domain: str,
if 'Z' not in messageJson['object']['published']:
return False
if isGitPatch(baseDir, nickname, domain,
messageJson['object']['type'],
messageJson['object']['summary'],
messageJson['object']['content']):
return True

View File

@ -188,6 +188,7 @@ def postMessageToOutbox(messageJson: {}, postToNickname: str,
messageJson['type'] == 'Question' or \
messageJson['type'] == 'Note' or \
messageJson['type'] == 'Article' or \
messageJson['type'] == 'Commit' or \
messageJson['type'] == 'Announce':
indexes = [outboxName, "inbox"]
for boxNameIndex in indexes:

View File

@ -2251,6 +2251,7 @@ def isDM(postJsonObject: {}) -> bool:
if not isinstance(postJsonObject['object'], dict):
return False
if postJsonObject['object']['type'] != 'Note' and \
postJsonObject['object']['type'] != 'Commit' and \
postJsonObject['object']['type'] != 'Article':
return False
if postJsonObject['object'].get('moderationStatus'):
@ -2427,6 +2428,7 @@ def addPostStringToTimeline(postStr: str, boxname: str,
# must be a "Note" or "Announce" type
if ('"Note"' in postStr or
'"Article"' in postStr or
'"Commit"' in postStr or
'"Announce"' in postStr or
('"Question"' in postStr and
('"Create"' in postStr or '"Update"' in postStr))):