mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			ActivityPub signoff added to patches
							parent
							
								
									c233306b23
								
							
						
					
					
						commit
						5dcc60aa7c
					
				
							
								
								
									
										22
									
								
								git.py
								
								
								
								
							
							
						
						
									
										22
									
								
								git.py
								
								
								
								
							| 
						 | 
				
			
			@ -70,8 +70,26 @@ def isGitPatch(baseDir: str, nickname: str, domain: str,
 | 
			
		|||
    return True
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def gitAddFromHandle(contentStr: str, handle: str) -> str:
 | 
			
		||||
    """Adds the activitypub handle of the sender to the patch
 | 
			
		||||
    """
 | 
			
		||||
    fromStr = 'AP-signed-off-by: '
 | 
			
		||||
    if fromStr in contentStr:
 | 
			
		||||
        return contentStr
 | 
			
		||||
 | 
			
		||||
    prevContentStr = contentStr
 | 
			
		||||
    patchLines = prevContentStr.split('\n')
 | 
			
		||||
    contentStr = ''
 | 
			
		||||
    for line in patchLines:
 | 
			
		||||
        contentStr += line + '\n'
 | 
			
		||||
        if line.startswith('From:'):
 | 
			
		||||
            contentStr += fromStr + handle + '\n'
 | 
			
		||||
    return contentStr
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def receiveGitPatch(baseDir: str, nickname: str, domain: str,
 | 
			
		||||
                    subject: str, content: str) -> bool:
 | 
			
		||||
                    subject: str, content: str,
 | 
			
		||||
                    fromNickname: str, fromDomain: str) -> bool:
 | 
			
		||||
    """Receive a git patch
 | 
			
		||||
    """
 | 
			
		||||
    if not isGitPatch(baseDir, nickname, domain,
 | 
			
		||||
| 
						 | 
				
			
			@ -105,6 +123,8 @@ def receiveGitPatch(baseDir: str, nickname: str, domain: str,
 | 
			
		|||
            break
 | 
			
		||||
    if not patchFilename:
 | 
			
		||||
        return False
 | 
			
		||||
    contentStr = \
 | 
			
		||||
        gitAddFromHandle(contentStr, '@' + fromNickname + '@' + fromDomain)
 | 
			
		||||
    with open(patchFilename, "w") as patchFile:
 | 
			
		||||
        patchFile.write(contentStr)
 | 
			
		||||
        patchNotifyFilename = \
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								inbox.py
								
								
								
								
							
							
						
						
									
										13
									
								
								inbox.py
								
								
								
								
							| 
						 | 
				
			
			@ -2048,12 +2048,19 @@ def inboxAfterCapabilities(recentPostsCache: {}, maxRecentPosts: int,
 | 
			
		|||
 | 
			
		||||
        # check for incoming git patches
 | 
			
		||||
        if isinstance(postJsonObject['object'], dict):
 | 
			
		||||
            pprint(postJsonObject)
 | 
			
		||||
            if postJsonObject['object'].get('content') and \
 | 
			
		||||
               postJsonObject['object'].get('summary'):
 | 
			
		||||
               postJsonObject['object'].get('summary') and \
 | 
			
		||||
               postJsonObject['object'].get('attributedTo'):
 | 
			
		||||
                attributedTo = postJsonObject['object']['attributedTo']
 | 
			
		||||
                fromNickname = getNicknameFromActor(attributedTo)
 | 
			
		||||
                fromDomain, fromPort = getDomainFromActor(attributedTo)
 | 
			
		||||
                if fromPort:
 | 
			
		||||
                    if fromPort != 80 and fromPort != 443:
 | 
			
		||||
                        fromDomain += ':' + str(fromPort)
 | 
			
		||||
                if receiveGitPatch(baseDir, nickname, domain,
 | 
			
		||||
                                   postJsonObject['object']['summary'],
 | 
			
		||||
                                   postJsonObject['object']['content']):
 | 
			
		||||
                                   postJsonObject['object']['content'],
 | 
			
		||||
                                   fromNickname, fromDomain):
 | 
			
		||||
                    gitPatchNotify(baseDir, handle,
 | 
			
		||||
                                   postJsonObject['object']['summary'],
 | 
			
		||||
                                   postJsonObject['object']['content'])
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue