mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
b8fbc8057b
commit
198381e99a
|
@ -12,6 +12,7 @@ from webfinger import webfingerHandle
|
|||
from auth import createBasicAuthHeader
|
||||
from posts import getPersonBox
|
||||
from session import postJson
|
||||
from utils import hasObjectString
|
||||
from utils import getFullDomain
|
||||
from utils import getNicknameFromActor
|
||||
from utils import getDomainFromActor
|
||||
|
@ -63,9 +64,7 @@ def outboxAvailability(baseDir: str, nickname: str, messageJson: {},
|
|||
return False
|
||||
if not hasActor(messageJson, debug):
|
||||
return False
|
||||
if not messageJson.get('object'):
|
||||
return False
|
||||
if not isinstance(messageJson['object'], str):
|
||||
if not hasObjectString(messageJson, debug):
|
||||
return False
|
||||
|
||||
actorNickname = getNicknameFromActor(messageJson['actor'])
|
||||
|
|
27
blocking.py
27
blocking.py
|
@ -11,6 +11,7 @@ import os
|
|||
import json
|
||||
import time
|
||||
from datetime import datetime
|
||||
from utils import hasObjectString
|
||||
from utils import hasObjectStringObject
|
||||
from utils import hasObjectStringType
|
||||
from utils import removeDomainPort
|
||||
|
@ -349,13 +350,7 @@ def outboxBlock(baseDir: str, httpPrefix: str,
|
|||
if debug:
|
||||
print('DEBUG: not a block')
|
||||
return False
|
||||
if not messageJson.get('object'):
|
||||
if debug:
|
||||
print('DEBUG: no object in block')
|
||||
return False
|
||||
if not isinstance(messageJson['object'], str):
|
||||
if debug:
|
||||
print('DEBUG: block object is not string')
|
||||
if not hasObjectString(messageJson, debug):
|
||||
return False
|
||||
if debug:
|
||||
print('DEBUG: c2s block request arrived in outbox')
|
||||
|
@ -468,9 +463,8 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
|
|||
if hasObjectDict(postJsonObject):
|
||||
postJsonObj = postJsonObject['object']
|
||||
else:
|
||||
if postJsonObject.get('object'):
|
||||
if isinstance(postJsonObject['object'], str):
|
||||
alsoUpdatePostId = removeIdEnding(postJsonObject['object'])
|
||||
if hasObjectString(postJsonObject, debug):
|
||||
alsoUpdatePostId = removeIdEnding(postJsonObject['object'])
|
||||
|
||||
domainFull = getFullDomain(domain, port)
|
||||
actor = localActorUrl(httpPrefix, nickname, domainFull)
|
||||
|
@ -597,9 +591,8 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
|
|||
if hasObjectDict(postJsonObject):
|
||||
postJsonObj = postJsonObject['object']
|
||||
else:
|
||||
if postJsonObject.get('object'):
|
||||
if isinstance(postJsonObject['object'], str):
|
||||
alsoUpdatePostId = removeIdEnding(postJsonObject['object'])
|
||||
if hasObjectString(postJsonObject, debug):
|
||||
alsoUpdatePostId = removeIdEnding(postJsonObject['object'])
|
||||
|
||||
if postJsonObj.get('conversation'):
|
||||
unmuteConversation(baseDir, nickname, domain,
|
||||
|
@ -697,13 +690,7 @@ def outboxMute(baseDir: str, httpPrefix: str,
|
|||
return
|
||||
if not messageJson['type'] == 'Ignore':
|
||||
return
|
||||
if not messageJson.get('object'):
|
||||
if debug:
|
||||
print('DEBUG: no object in mute')
|
||||
return
|
||||
if not isinstance(messageJson['object'], str):
|
||||
if debug:
|
||||
print('DEBUG: mute object is not string')
|
||||
if not hasObjectString(messageJson, debug):
|
||||
return
|
||||
if debug:
|
||||
print('DEBUG: c2s mute request arrived in outbox')
|
||||
|
|
|
@ -9,6 +9,7 @@ __module_group__ = "ActivityPub"
|
|||
|
||||
import os
|
||||
from datetime import datetime
|
||||
from utils import hasObjectString
|
||||
from utils import removeDomainPort
|
||||
from utils import hasUsersPath
|
||||
from utils import getFullDomain
|
||||
|
@ -126,13 +127,7 @@ def outboxDelete(baseDir: str, httpPrefix: str,
|
|||
if debug:
|
||||
print('DEBUG: not a delete')
|
||||
return
|
||||
if not messageJson.get('object'):
|
||||
if debug:
|
||||
print('DEBUG: no object in delete')
|
||||
return
|
||||
if not isinstance(messageJson['object'], str):
|
||||
if debug:
|
||||
print('DEBUG: delete object is not string')
|
||||
if not hasObjectString(messageJson, debug):
|
||||
return
|
||||
if debug:
|
||||
print('DEBUG: c2s delete request arrived in outbox')
|
||||
|
|
25
inbox.py
25
inbox.py
|
@ -15,6 +15,7 @@ import random
|
|||
from linked_data_sig import verifyJsonSignature
|
||||
from languages import understoodPostLanguage
|
||||
from like import updateLikesCollection
|
||||
from utils import hasObjectString
|
||||
from utils import hasObjectStringObject
|
||||
from utils import getReplyIntervalHours
|
||||
from utils import canReplyTo
|
||||
|
@ -896,13 +897,7 @@ def _receiveLike(recentPostsCache: {},
|
|||
return False
|
||||
if not hasActor(messageJson, debug):
|
||||
return False
|
||||
if not messageJson.get('object'):
|
||||
if debug:
|
||||
print('DEBUG: ' + messageJson['type'] + ' has no object')
|
||||
return False
|
||||
if not isinstance(messageJson['object'], str):
|
||||
if debug:
|
||||
print('DEBUG: ' + messageJson['type'] + ' object is not a string')
|
||||
if not hasObjectString(messageJson, debug):
|
||||
return False
|
||||
if not messageJson.get('to'):
|
||||
if debug:
|
||||
|
@ -1305,13 +1300,7 @@ def _receiveDelete(session, handle: str, isGroup: bool, baseDir: str,
|
|||
return False
|
||||
if debug:
|
||||
print('DEBUG: Delete activity arrived')
|
||||
if not messageJson.get('object'):
|
||||
if debug:
|
||||
print('DEBUG: ' + messageJson['type'] + ' has no object')
|
||||
return False
|
||||
if not isinstance(messageJson['object'], str):
|
||||
if debug:
|
||||
print('DEBUG: ' + messageJson['type'] + ' object is not a string')
|
||||
if not hasObjectString(messageJson, debug):
|
||||
return False
|
||||
domainFull = getFullDomain(domain, port)
|
||||
deletePrefix = httpPrefix + '://' + domainFull + '/'
|
||||
|
@ -1400,13 +1389,7 @@ def _receiveAnnounce(recentPostsCache: {},
|
|||
return False
|
||||
if debug:
|
||||
print('DEBUG: receiving announce on ' + handle)
|
||||
if not messageJson.get('object'):
|
||||
if debug:
|
||||
print('DEBUG: ' + messageJson['type'] + ' has no object')
|
||||
return False
|
||||
if not isinstance(messageJson['object'], str):
|
||||
if debug:
|
||||
print('DEBUG: ' + messageJson['type'] + ' object is not a string')
|
||||
if not hasObjectString(messageJson, debug):
|
||||
return False
|
||||
if not messageJson.get('to'):
|
||||
if debug:
|
||||
|
|
9
like.py
9
like.py
|
@ -9,6 +9,7 @@ __module_group__ = "ActivityPub"
|
|||
|
||||
import os
|
||||
from pprint import pprint
|
||||
from utils import hasObjectString
|
||||
from utils import hasObjectStringObject
|
||||
from utils import hasObjectStringType
|
||||
from utils import removeDomainPort
|
||||
|
@ -345,13 +346,7 @@ def outboxLike(recentPostsCache: {},
|
|||
if debug:
|
||||
print('DEBUG: not a like')
|
||||
return
|
||||
if not messageJson.get('object'):
|
||||
if debug:
|
||||
print('DEBUG: no object in like')
|
||||
return
|
||||
if not isinstance(messageJson['object'], str):
|
||||
if debug:
|
||||
print('DEBUG: like object is not string')
|
||||
if not hasObjectString(messageJson, debug):
|
||||
return
|
||||
if debug:
|
||||
print('DEBUG: c2s like request arrived in outbox')
|
||||
|
|
|
@ -12,6 +12,7 @@ from webfinger import webfingerHandle
|
|||
from auth import createBasicAuthHeader
|
||||
from posts import getPersonBox
|
||||
from session import postJson
|
||||
from utils import hasObjectString
|
||||
from utils import getFullDomain
|
||||
from utils import getNicknameFromActor
|
||||
from utils import getDomainFromActor
|
||||
|
@ -153,9 +154,7 @@ def outboxSkills(baseDir: str, nickname: str, messageJson: {},
|
|||
return False
|
||||
if not hasActor(messageJson, debug):
|
||||
return False
|
||||
if not messageJson.get('object'):
|
||||
return False
|
||||
if not isinstance(messageJson['object'], str):
|
||||
if not hasObjectString(messageJson, debug):
|
||||
return False
|
||||
|
||||
actorNickname = getNicknameFromActor(messageJson['actor'])
|
||||
|
|
22
utils.py
22
utils.py
|
@ -1345,10 +1345,9 @@ def _getPublishedDate(postJsonObject: {}) -> str:
|
|||
published = None
|
||||
if postJsonObject.get('published'):
|
||||
published = postJsonObject['published']
|
||||
elif postJsonObject.get('object'):
|
||||
if isinstance(postJsonObject['object'], dict):
|
||||
if postJsonObject['object'].get('published'):
|
||||
published = postJsonObject['object']['published']
|
||||
elif hasObjectDict(postJsonObject):
|
||||
if postJsonObject['object'].get('published'):
|
||||
published = postJsonObject['object']['published']
|
||||
if not published:
|
||||
return None
|
||||
if not isinstance(published, str):
|
||||
|
@ -3072,3 +3071,18 @@ def hasObjectStringObject(postJsonObject: {}, debug: bool) -> bool:
|
|||
if debug:
|
||||
print('No object field within dict ' + postJsonObject['id'])
|
||||
return False
|
||||
|
||||
|
||||
def hasObjectString(postJsonObject: {}, debug: bool) -> bool:
|
||||
"""Does the given post have an object string field?
|
||||
"""
|
||||
if postJsonObject.get('object'):
|
||||
if isinstance(postJsonObject['object'], str):
|
||||
return True
|
||||
elif debug:
|
||||
if postJsonObject.get('type'):
|
||||
print('DEBUG: ' + postJsonObject['type'] +
|
||||
' object is not a string')
|
||||
if debug:
|
||||
print('No object field within post ' + postJsonObject['id'])
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue