mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			Checking for self-announces using a function
							parent
							
								
									ea6571da4e
								
							
						
					
					
						commit
						efe1b54b38
					
				
							
								
								
									
										20
									
								
								announce.py
								
								
								
								
							
							
						
						
									
										20
									
								
								announce.py
								
								
								
								
							| 
						 | 
				
			
			@ -41,7 +41,7 @@ def outboxAnnounce(recentPostsCache: {},
 | 
			
		|||
    if messageJson['type'] == 'Announce':
 | 
			
		||||
        if not isinstance(messageJson['object'], str):
 | 
			
		||||
            return False
 | 
			
		||||
        if messageJson['actor'] in messageJson['object']:
 | 
			
		||||
        if isSelfAnnounce(messageJson):
 | 
			
		||||
            return False
 | 
			
		||||
        nickname = getNicknameFromActor(messageJson['actor'])
 | 
			
		||||
        if not nickname:
 | 
			
		||||
| 
						 | 
				
			
			@ -390,3 +390,21 @@ def outboxUndoAnnounce(recentPostsCache: {},
 | 
			
		|||
                                messageJson['actor'], domain, debug)
 | 
			
		||||
    if debug:
 | 
			
		||||
        print('DEBUG: post undo announce via c2s - ' + postFilename)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def isSelfAnnounce(postJsonObject: {}) -> bool:
 | 
			
		||||
    """Is the given post a self announce?
 | 
			
		||||
    """
 | 
			
		||||
    if not postJsonObject.get('actor'):
 | 
			
		||||
        return False
 | 
			
		||||
    if not postJsonObject.get('type'):
 | 
			
		||||
        return False
 | 
			
		||||
    if postJsonObject['type'] != 'Announce':
 | 
			
		||||
        return False
 | 
			
		||||
    if not postJsonObject.get('object'):
 | 
			
		||||
        return False
 | 
			
		||||
    if not isinstance(postJsonObject['actor'], str):
 | 
			
		||||
        return False
 | 
			
		||||
    if not isinstance(postJsonObject['object'], str):
 | 
			
		||||
        return False
 | 
			
		||||
    return postJsonObject['actor'] in postJsonObject['object']
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										3
									
								
								inbox.py
								
								
								
								
							
							
						
						
									
										3
									
								
								inbox.py
								
								
								
								
							| 
						 | 
				
			
			@ -80,6 +80,7 @@ from delete import removeOldHashtags
 | 
			
		|||
from categories import guessHashtagCategory
 | 
			
		||||
from context import hasValidContext
 | 
			
		||||
from speaker import updateSpeaker
 | 
			
		||||
from announce import isSelfAnnounce
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
 | 
			
		||||
| 
						 | 
				
			
			@ -1359,7 +1360,7 @@ def _receiveAnnounce(recentPostsCache: {},
 | 
			
		|||
                  '"users" or "profile" missing from actor in ' +
 | 
			
		||||
                  messageJson['type'])
 | 
			
		||||
        return False
 | 
			
		||||
    if messageJson['actor'] in messageJson['object']:
 | 
			
		||||
    if isSelfAnnounce(messageJson):
 | 
			
		||||
        if debug:
 | 
			
		||||
            print('DEBUG: self-boost rejected')
 | 
			
		||||
        return False
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,6 +31,7 @@ from webapp_column_left import getLeftColumnContent
 | 
			
		|||
from webapp_column_right import getRightColumnContent
 | 
			
		||||
from webapp_headerbuttons import headerButtonsTimeline
 | 
			
		||||
from posts import isModerator
 | 
			
		||||
from announce import isSelfAnnounce
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _logTimelineTiming(enableTimingLog: bool, timelineStartTime,
 | 
			
		||||
| 
						 | 
				
			
			@ -684,6 +685,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
 | 
			
		|||
                # is the actor who sent this post snoozed?
 | 
			
		||||
                if isPersonSnoozed(baseDir, nickname, domain, item['actor']):
 | 
			
		||||
                    continue
 | 
			
		||||
                if isSelfAnnounce(item):
 | 
			
		||||
                    continue
 | 
			
		||||
 | 
			
		||||
                # is the post in the memory cache of recent ones?
 | 
			
		||||
                currTlStr = None
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue