mirror of https://gitlab.com/bashrc2/epicyon
Remove contentmap for patch posts
parent
802fa62e03
commit
ddb9d4fd82
17
git.py
17
git.py
|
@ -47,7 +47,7 @@ def isGitPatch(baseDir: str, nickname: str, domain: str,
|
||||||
"""Is the given post content a git patch?
|
"""Is the given post content a git patch?
|
||||||
"""
|
"""
|
||||||
if messageType != 'Note' and \
|
if messageType != 'Note' and \
|
||||||
messageType != 'Commit':
|
messageType != 'Patch':
|
||||||
return False
|
return False
|
||||||
# must have a subject line
|
# must have a subject line
|
||||||
if not subject:
|
if not subject:
|
||||||
|
@ -91,10 +91,10 @@ def getGitHash(patchStr: str) -> str:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def convertPostToCommit(baseDir: str, nickname: str, domain: str,
|
def convertPostToPatch(baseDir: str, nickname: str, domain: str,
|
||||||
postJsonObject: {}) -> bool:
|
postJsonObject: {}) -> bool:
|
||||||
"""Detects whether the given post contains a patch
|
"""Detects whether the given post contains a patch
|
||||||
and if so then converts it to a Commit ActivityPub type
|
and if so then converts it to a Patch ActivityPub type
|
||||||
"""
|
"""
|
||||||
if not postJsonObject.get('object'):
|
if not postJsonObject.get('object'):
|
||||||
return False
|
return False
|
||||||
|
@ -102,7 +102,7 @@ def convertPostToCommit(baseDir: str, nickname: str, domain: str,
|
||||||
return False
|
return False
|
||||||
if not postJsonObject['object'].get('type'):
|
if not postJsonObject['object'].get('type'):
|
||||||
return False
|
return False
|
||||||
if postJsonObject['object']['type'] == 'Commit':
|
if postJsonObject['object']['type'] == 'Patch':
|
||||||
return True
|
return True
|
||||||
if not postJsonObject['object'].get('summary'):
|
if not postJsonObject['object'].get('summary'):
|
||||||
return False
|
return False
|
||||||
|
@ -120,7 +120,7 @@ def convertPostToCommit(baseDir: str, nickname: str, domain: str,
|
||||||
commitHash = getGitHash(patchStr)
|
commitHash = getGitHash(patchStr)
|
||||||
if not commitHash:
|
if not commitHash:
|
||||||
return False
|
return False
|
||||||
postJsonObject['object']['type'] = 'Commit'
|
postJsonObject['object']['type'] = 'Patch'
|
||||||
# add a commitedBy parameter
|
# add a commitedBy parameter
|
||||||
if not postJsonObject['object'].get('committedBy'):
|
if not postJsonObject['object'].get('committedBy'):
|
||||||
postJsonObject['object']['committedBy'] = \
|
postJsonObject['object']['committedBy'] = \
|
||||||
|
@ -130,7 +130,10 @@ def convertPostToCommit(baseDir: str, nickname: str, domain: str,
|
||||||
"mediaType": "text/plain",
|
"mediaType": "text/plain",
|
||||||
"content": patchStr
|
"content": patchStr
|
||||||
}
|
}
|
||||||
print('Converted post to Commit type')
|
# remove content map
|
||||||
|
if postJsonObject['object'].get('contentMap'):
|
||||||
|
del postJsonObject['object']['contentMap']
|
||||||
|
print('Converted post to Patch ActivityPub type')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ def postMessageToOutbox(messageJson: {}, postToNickname: str,
|
||||||
messageJson['type'] == 'Question' or \
|
messageJson['type'] == 'Question' or \
|
||||||
messageJson['type'] == 'Note' or \
|
messageJson['type'] == 'Note' or \
|
||||||
messageJson['type'] == 'Article' or \
|
messageJson['type'] == 'Article' or \
|
||||||
messageJson['type'] == 'Commit' or \
|
messageJson['type'] == 'Patch' or \
|
||||||
messageJson['type'] == 'Announce':
|
messageJson['type'] == 'Announce':
|
||||||
indexes = [outboxName, "inbox"]
|
indexes = [outboxName, "inbox"]
|
||||||
for boxNameIndex in indexes:
|
for boxNameIndex in indexes:
|
||||||
|
|
10
posts.py
10
posts.py
|
@ -49,7 +49,7 @@ from auth import createBasicAuthHeader
|
||||||
from config import getConfigParam
|
from config import getConfigParam
|
||||||
from blocking import isBlocked
|
from blocking import isBlocked
|
||||||
from filters import isFiltered
|
from filters import isFiltered
|
||||||
from git import convertPostToCommit
|
from git import convertPostToPatch
|
||||||
# try:
|
# try:
|
||||||
# from BeautifulSoup import BeautifulSoup
|
# from BeautifulSoup import BeautifulSoup
|
||||||
# except ImportError:
|
# except ImportError:
|
||||||
|
@ -796,9 +796,9 @@ def createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
modFile.write(newPostId + '\n')
|
modFile.write(newPostId + '\n')
|
||||||
modFile.close()
|
modFile.close()
|
||||||
|
|
||||||
# If a commit has been posted - i.e. the output from
|
# If a patch has been posted - i.e. the output from
|
||||||
# git format-patch - then convert the activitypub type
|
# git format-patch - then convert the activitypub type
|
||||||
convertPostToCommit(baseDir, nickname, domain, newPost)
|
convertPostToPatch(baseDir, nickname, domain, newPost)
|
||||||
|
|
||||||
if schedulePost:
|
if schedulePost:
|
||||||
if eventDate and eventTime:
|
if eventDate and eventTime:
|
||||||
|
@ -2256,7 +2256,7 @@ def isDM(postJsonObject: {}) -> bool:
|
||||||
if not isinstance(postJsonObject['object'], dict):
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
return False
|
return False
|
||||||
if postJsonObject['object']['type'] != 'Note' and \
|
if postJsonObject['object']['type'] != 'Note' and \
|
||||||
postJsonObject['object']['type'] != 'Commit' and \
|
postJsonObject['object']['type'] != 'Patch' and \
|
||||||
postJsonObject['object']['type'] != 'Article':
|
postJsonObject['object']['type'] != 'Article':
|
||||||
return False
|
return False
|
||||||
if postJsonObject['object'].get('moderationStatus'):
|
if postJsonObject['object'].get('moderationStatus'):
|
||||||
|
@ -2433,7 +2433,7 @@ def addPostStringToTimeline(postStr: str, boxname: str,
|
||||||
# must be a "Note" or "Announce" type
|
# must be a "Note" or "Announce" type
|
||||||
if ('"Note"' in postStr or
|
if ('"Note"' in postStr or
|
||||||
'"Article"' in postStr or
|
'"Article"' in postStr or
|
||||||
'"Commit"' in postStr or
|
'"Patch"' in postStr or
|
||||||
'"Announce"' in postStr or
|
'"Announce"' in postStr or
|
||||||
('"Question"' in postStr and
|
('"Question"' in postStr and
|
||||||
('"Create"' in postStr or '"Update"' in postStr))):
|
('"Create"' in postStr or '"Update"' in postStr))):
|
||||||
|
|
Loading…
Reference in New Issue