mirror of https://gitlab.com/bashrc2/epicyon
Tidying of checking for git patches
parent
27cf80dce2
commit
a8d76b4d18
57
inbox.py
57
inbox.py
|
@ -2681,6 +2681,38 @@ def _lowFrequencyPostNotification(baseDir: str, httpPrefix: str, nickname: str,
|
||||||
_notifyPostArrival(baseDir, handle, postLink)
|
_notifyPostArrival(baseDir, handle, postLink)
|
||||||
|
|
||||||
|
|
||||||
|
def _checkForGitPatches(baseDir: str, nickname: str, domain: str,
|
||||||
|
handle: str, jsonObj: {}) -> int:
|
||||||
|
"""check for incoming git patches
|
||||||
|
"""
|
||||||
|
if not jsonObj:
|
||||||
|
return 0
|
||||||
|
if not jsonObj.get('content'):
|
||||||
|
return 0
|
||||||
|
if not jsonObj.get('summary'):
|
||||||
|
return 0
|
||||||
|
if not jsonObj.get('attributedTo'):
|
||||||
|
return 0
|
||||||
|
attributedTo = jsonObj['attributedTo']
|
||||||
|
if not isinstance(attributedTo, str):
|
||||||
|
return 0
|
||||||
|
fromNickname = getNicknameFromActor(attributedTo)
|
||||||
|
fromDomain, fromPort = getDomainFromActor(attributedTo)
|
||||||
|
fromDomainFull = getFullDomain(fromDomain, fromPort)
|
||||||
|
if receiveGitPatch(baseDir, nickname, domain,
|
||||||
|
jsonObj['type'], jsonObj['summary'],
|
||||||
|
jsonObj['content'],
|
||||||
|
fromNickname, fromDomainFull):
|
||||||
|
_gitPatchNotify(baseDir, handle,
|
||||||
|
jsonObj['summary'], jsonObj['content'],
|
||||||
|
fromNickname, fromDomainFull)
|
||||||
|
return 1
|
||||||
|
elif '[PATCH]' in jsonObj['content']:
|
||||||
|
print('WARN: git patch not accepted - ' + jsonObj['summary'])
|
||||||
|
return 2
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
session, keyId: str, handle: str, messageJson: {},
|
session, keyId: str, handle: str, messageJson: {},
|
||||||
baseDir: str, httpPrefix: str, sendThreads: [],
|
baseDir: str, httpPrefix: str, sendThreads: [],
|
||||||
|
@ -2885,28 +2917,9 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
jsonObj = None
|
jsonObj = None
|
||||||
else:
|
else:
|
||||||
jsonObj = postJsonObject
|
jsonObj = postJsonObject
|
||||||
# check for incoming git patches
|
|
||||||
if jsonObj:
|
if _checkForGitPatches(baseDir, nickname, domain,
|
||||||
if jsonObj.get('content') and \
|
handle, jsonObj) == 2:
|
||||||
jsonObj.get('summary') and \
|
|
||||||
jsonObj.get('attributedTo'):
|
|
||||||
attributedTo = jsonObj['attributedTo']
|
|
||||||
if isinstance(attributedTo, str):
|
|
||||||
fromNickname = getNicknameFromActor(attributedTo)
|
|
||||||
fromDomain, fromPort = getDomainFromActor(attributedTo)
|
|
||||||
fromDomain = getFullDomain(fromDomain, fromPort)
|
|
||||||
if receiveGitPatch(baseDir, nickname, domain,
|
|
||||||
jsonObj['type'],
|
|
||||||
jsonObj['summary'],
|
|
||||||
jsonObj['content'],
|
|
||||||
fromNickname, fromDomain):
|
|
||||||
_gitPatchNotify(baseDir, handle,
|
|
||||||
jsonObj['summary'],
|
|
||||||
jsonObj['content'],
|
|
||||||
fromNickname, fromDomain)
|
|
||||||
elif '[PATCH]' in jsonObj['content']:
|
|
||||||
print('WARN: git patch not accepted - ' +
|
|
||||||
jsonObj['summary'])
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# replace YouTube links, so they get less tracking data
|
# replace YouTube links, so they get less tracking data
|
||||||
|
|
Loading…
Reference in New Issue