mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
8e6084d42d
commit
614e274e24
|
@ -15,11 +15,11 @@ from utils import getDomainFromActor
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import domainPermitted
|
from utils import domainPermitted
|
||||||
from utils import followPerson
|
from utils import followPerson
|
||||||
from utils import hasObjectDict
|
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
from utils import hasGroupType
|
from utils import hasGroupType
|
||||||
from utils import localActorUrl
|
from utils import localActorUrl
|
||||||
from utils import hasActor
|
from utils import hasActor
|
||||||
|
from utils import hasObjectStringType
|
||||||
|
|
||||||
|
|
||||||
def _createAcceptReject(baseDir: str, federationList: [],
|
def _createAcceptReject(baseDir: str, federationList: [],
|
||||||
|
@ -78,9 +78,7 @@ def _acceptFollow(baseDir: str, domain: str, messageJson: {},
|
||||||
federationList: [], debug: bool) -> None:
|
federationList: [], debug: bool) -> None:
|
||||||
"""Receiving a follow Accept activity
|
"""Receiving a follow Accept activity
|
||||||
"""
|
"""
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
return
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
return
|
return
|
||||||
if not messageJson['object']['type'] == 'Follow':
|
if not messageJson['object']['type'] == 'Follow':
|
||||||
if not messageJson['object']['type'] == 'Join':
|
if not messageJson['object']['type'] == 'Join':
|
||||||
|
|
14
announce.py
14
announce.py
|
@ -9,7 +9,6 @@ __module_group__ = "ActivityPub"
|
||||||
|
|
||||||
from utils import hasGroupType
|
from utils import hasGroupType
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import hasObjectDict
|
|
||||||
from utils import removeIdEnding
|
from utils import removeIdEnding
|
||||||
from utils import hasUsersPath
|
from utils import hasUsersPath
|
||||||
from utils import getFullDomain
|
from utils import getFullDomain
|
||||||
|
@ -25,6 +24,7 @@ from utils import updateAnnounceCollection
|
||||||
from utils import localActorUrl
|
from utils import localActorUrl
|
||||||
from utils import replaceUsersWithAt
|
from utils import replaceUsersWithAt
|
||||||
from utils import hasActor
|
from utils import hasActor
|
||||||
|
from utils import hasObjectStringType
|
||||||
from posts import sendSignedJson
|
from posts import sendSignedJson
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
from session import postJson
|
from session import postJson
|
||||||
|
@ -81,9 +81,7 @@ def outboxAnnounce(recentPostsCache: {},
|
||||||
nickname, domain, debug)
|
nickname, domain, debug)
|
||||||
return True
|
return True
|
||||||
elif messageJson['type'] == 'Undo':
|
elif messageJson['type'] == 'Undo':
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
return False
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
return False
|
return False
|
||||||
if messageJson['object']['type'] == 'Announce':
|
if messageJson['object']['type'] == 'Announce':
|
||||||
if not isinstance(messageJson['object']['object'], str):
|
if not isinstance(messageJson['object']['object'], str):
|
||||||
|
@ -397,13 +395,7 @@ def outboxUndoAnnounce(recentPostsCache: {},
|
||||||
return
|
return
|
||||||
if not messageJson['type'] == 'Undo':
|
if not messageJson['type'] == 'Undo':
|
||||||
return
|
return
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
if debug:
|
|
||||||
print('DEBUG: undo like object is not dict')
|
|
||||||
return
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: undo like - no type')
|
|
||||||
return
|
return
|
||||||
if not messageJson['object']['type'] == 'Announce':
|
if not messageJson['object']['type'] == 'Announce':
|
||||||
if debug:
|
if debug:
|
||||||
|
|
13
blocking.py
13
blocking.py
|
@ -11,6 +11,7 @@ import os
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from utils import hasObjectStringType
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
|
@ -402,14 +403,8 @@ def outboxUndoBlock(baseDir: str, httpPrefix: str,
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: not an undo block')
|
print('DEBUG: not an undo block')
|
||||||
return
|
return
|
||||||
if not hasObjectDict(messageJson):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: undo block object is not string')
|
|
||||||
return
|
|
||||||
|
|
||||||
if not messageJson['object'].get('type'):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
if debug:
|
|
||||||
print('DEBUG: undo block - no type')
|
|
||||||
return
|
return
|
||||||
if not messageJson['object']['type'] == 'Block':
|
if not messageJson['object']['type'] == 'Block':
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -762,9 +757,7 @@ def outboxUndoMute(baseDir: str, httpPrefix: str,
|
||||||
return
|
return
|
||||||
if not messageJson['type'] == 'Undo':
|
if not messageJson['type'] == 'Undo':
|
||||||
return
|
return
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
return
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
return
|
return
|
||||||
if messageJson['object']['type'] != 'Ignore':
|
if messageJson['object']['type'] != 'Ignore':
|
||||||
return
|
return
|
||||||
|
|
17
bookmarks.py
17
bookmarks.py
|
@ -27,6 +27,7 @@ from utils import hasObjectDict
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
from utils import localActorUrl
|
from utils import localActorUrl
|
||||||
from utils import hasActor
|
from utils import hasActor
|
||||||
|
from utils import hasObjectStringType
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
from session import postJson
|
from session import postJson
|
||||||
|
|
||||||
|
@ -542,17 +543,11 @@ def outboxBookmark(recentPostsCache: {},
|
||||||
return
|
return
|
||||||
if not hasActor(messageJson, debug):
|
if not hasActor(messageJson, debug):
|
||||||
return
|
return
|
||||||
if not hasObjectDict(messageJson):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: no object in bookmark Add')
|
|
||||||
return
|
|
||||||
if not messageJson.get('target'):
|
if not messageJson.get('target'):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: no target in bookmark Add')
|
print('DEBUG: no target in bookmark Add')
|
||||||
return
|
return
|
||||||
if not messageJson['object'].get('type'):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
if debug:
|
|
||||||
print('DEBUG: no object type in bookmark Add')
|
|
||||||
return
|
return
|
||||||
if not isinstance(messageJson['target'], str):
|
if not isinstance(messageJson['target'], str):
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -604,17 +599,11 @@ def outboxUndoBookmark(recentPostsCache: {},
|
||||||
return
|
return
|
||||||
if not hasActor(messageJson, debug):
|
if not hasActor(messageJson, debug):
|
||||||
return
|
return
|
||||||
if not hasObjectDict(messageJson):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: no object in unbookmark Remove')
|
|
||||||
return
|
|
||||||
if not messageJson.get('target'):
|
if not messageJson.get('target'):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: no target in unbookmark Remove')
|
print('DEBUG: no target in unbookmark Remove')
|
||||||
return
|
return
|
||||||
if not messageJson['object'].get('type'):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
if debug:
|
|
||||||
print('DEBUG: no object type in bookmark Remove')
|
|
||||||
return
|
return
|
||||||
if not isinstance(messageJson['target'], str):
|
if not isinstance(messageJson['target'], str):
|
||||||
if debug:
|
if debug:
|
||||||
|
|
|
@ -9,9 +9,9 @@ __module_group__ = "ActivityPub"
|
||||||
|
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
import os
|
import os
|
||||||
|
from utils import hasObjectStringType
|
||||||
from utils import hasActor
|
from utils import hasActor
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import hasObjectDict
|
|
||||||
from utils import hasUsersPath
|
from utils import hasUsersPath
|
||||||
from utils import getFullDomain
|
from utils import getFullDomain
|
||||||
from utils import isSystemAccount
|
from utils import isSystemAccount
|
||||||
|
@ -1488,9 +1488,7 @@ def outboxUndoFollow(baseDir: str, messageJson: {}, debug: bool) -> None:
|
||||||
return
|
return
|
||||||
if not messageJson['type'] == 'Undo':
|
if not messageJson['type'] == 'Undo':
|
||||||
return
|
return
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
return
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
return
|
return
|
||||||
if not messageJson['object']['type'] == 'Follow':
|
if not messageJson['object']['type'] == 'Follow':
|
||||||
if not messageJson['object']['type'] == 'Join':
|
if not messageJson['object']['type'] == 'Join':
|
||||||
|
|
6
git.py
6
git.py
|
@ -9,8 +9,8 @@ __module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import html
|
import html
|
||||||
from utils import hasObjectDict
|
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
|
from utils import hasObjectStringType
|
||||||
|
|
||||||
|
|
||||||
def _gitFormatContent(content: str) -> str:
|
def _gitFormatContent(content: str) -> str:
|
||||||
|
@ -115,9 +115,7 @@ def convertPostToPatch(baseDir: str, nickname: str, domain: str,
|
||||||
"""Detects whether the given post contains a patch
|
"""Detects whether the given post contains a patch
|
||||||
and if so then converts it to a Patch ActivityPub type
|
and if so then converts it to a Patch ActivityPub type
|
||||||
"""
|
"""
|
||||||
if not hasObjectDict(postJsonObject):
|
if not hasObjectStringType(postJsonObject, False):
|
||||||
return False
|
|
||||||
if not postJsonObject['object'].get('type'):
|
|
||||||
return False
|
return False
|
||||||
if postJsonObject['object']['type'] == 'Patch':
|
if postJsonObject['object']['type'] == 'Patch':
|
||||||
return True
|
return True
|
||||||
|
|
47
inbox.py
47
inbox.py
|
@ -49,6 +49,7 @@ from utils import saveJson
|
||||||
from utils import undoLikesCollectionEntry
|
from utils import undoLikesCollectionEntry
|
||||||
from utils import hasGroupType
|
from utils import hasGroupType
|
||||||
from utils import localActorUrl
|
from utils import localActorUrl
|
||||||
|
from utils import hasObjectStringType
|
||||||
from categories import getHashtagCategories
|
from categories import getHashtagCategories
|
||||||
from categories import setHashtagCategory
|
from categories import setHashtagCategory
|
||||||
from httpsig import verifyPostHeaders
|
from httpsig import verifyPostHeaders
|
||||||
|
@ -692,18 +693,7 @@ def _receiveUndo(session, baseDir: str, httpPrefix: str,
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: "users" or "profile" missing from actor')
|
print('DEBUG: "users" or "profile" missing from actor')
|
||||||
return False
|
return False
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
if debug:
|
|
||||||
print('DEBUG: ' + messageJson['type'] + ' has no object')
|
|
||||||
return False
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: ' + messageJson['type'] + ' has no object type')
|
|
||||||
return False
|
|
||||||
if not isinstance(messageJson['object']['type'], str):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: ' + messageJson['type'] +
|
|
||||||
' type within object is not a string')
|
|
||||||
return False
|
return False
|
||||||
if not messageJson['object'].get('object'):
|
if not messageJson['object'].get('object'):
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -850,18 +840,7 @@ def _receiveUpdate(recentPostsCache: {}, session, baseDir: str,
|
||||||
return False
|
return False
|
||||||
if not hasActor(messageJson, debug):
|
if not hasActor(messageJson, debug):
|
||||||
return False
|
return False
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
if debug:
|
|
||||||
print('DEBUG: ' + messageJson['type'] + ' has no object')
|
|
||||||
return False
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: ' + messageJson['type'] + ' object has no type')
|
|
||||||
return False
|
|
||||||
if not isinstance(messageJson['object']['type'], str):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: ' + messageJson['type'] +
|
|
||||||
' object type is not string')
|
|
||||||
return False
|
return False
|
||||||
if not hasUsersPath(messageJson['actor']):
|
if not hasUsersPath(messageJson['actor']):
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1031,9 +1010,7 @@ def _receiveUndoLike(recentPostsCache: {},
|
||||||
return False
|
return False
|
||||||
if not hasActor(messageJson, debug):
|
if not hasActor(messageJson, debug):
|
||||||
return False
|
return False
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
return False
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
return False
|
return False
|
||||||
if messageJson['object']['type'] != 'Like':
|
if messageJson['object']['type'] != 'Like':
|
||||||
return False
|
return False
|
||||||
|
@ -1133,17 +1110,11 @@ def _receiveBookmark(recentPostsCache: {},
|
||||||
return False
|
return False
|
||||||
if not hasActor(messageJson, debug):
|
if not hasActor(messageJson, debug):
|
||||||
return False
|
return False
|
||||||
if not hasObjectDict(messageJson):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: no object in inbox bookmark Add')
|
|
||||||
return False
|
|
||||||
if not messageJson.get('target'):
|
if not messageJson.get('target'):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: no target in inbox bookmark Add')
|
print('DEBUG: no target in inbox bookmark Add')
|
||||||
return False
|
return False
|
||||||
if not messageJson['object'].get('type'):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
if debug:
|
|
||||||
print('DEBUG: no object type in inbox bookmark Add')
|
|
||||||
return False
|
return False
|
||||||
if not isinstance(messageJson['target'], str):
|
if not isinstance(messageJson['target'], str):
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1247,17 +1218,11 @@ def _receiveUndoBookmark(recentPostsCache: {},
|
||||||
return False
|
return False
|
||||||
if not hasActor(messageJson, debug):
|
if not hasActor(messageJson, debug):
|
||||||
return False
|
return False
|
||||||
if not hasObjectDict(messageJson):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: no object in inbox undo bookmark Remove')
|
|
||||||
return False
|
|
||||||
if not messageJson.get('target'):
|
if not messageJson.get('target'):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: no target in inbox undo bookmark Remove')
|
print('DEBUG: no target in inbox undo bookmark Remove')
|
||||||
return False
|
return False
|
||||||
if not messageJson['object'].get('type'):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
if debug:
|
|
||||||
print('DEBUG: no object type in inbox bookmark Remove')
|
|
||||||
return False
|
return False
|
||||||
if not isinstance(messageJson['target'], str):
|
if not isinstance(messageJson['target'], str):
|
||||||
if debug:
|
if debug:
|
||||||
|
|
9
like.py
9
like.py
|
@ -9,6 +9,7 @@ __module_group__ = "ActivityPub"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
from utils import hasObjectStringType
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
from utils import hasUsersPath
|
from utils import hasUsersPath
|
||||||
|
@ -380,13 +381,7 @@ def outboxUndoLike(recentPostsCache: {},
|
||||||
return
|
return
|
||||||
if not messageJson['type'] == 'Undo':
|
if not messageJson['type'] == 'Undo':
|
||||||
return
|
return
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
if debug:
|
|
||||||
print('DEBUG: undo like object is not dict')
|
|
||||||
return
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: undo like - no type')
|
|
||||||
return
|
return
|
||||||
if not messageJson['object']['type'] == 'Like':
|
if not messageJson['object']['type'] == 'Like':
|
||||||
if debug:
|
if debug:
|
||||||
|
|
|
@ -16,6 +16,7 @@ from posts import outboxMessageCreateWrap
|
||||||
from posts import savePostToBox
|
from posts import savePostToBox
|
||||||
from posts import sendToFollowersThread
|
from posts import sendToFollowersThread
|
||||||
from posts import sendToNamedAddresses
|
from posts import sendToNamedAddresses
|
||||||
|
from utils import hasObjectStringType
|
||||||
from utils import getBaseContentFromPost
|
from utils import getBaseContentFromPost
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
from utils import getLocalNetworkAddresses
|
from utils import getLocalNetworkAddresses
|
||||||
|
@ -73,13 +74,7 @@ def _outboxPersonReceiveUpdate(recentPostsCache: {},
|
||||||
return
|
return
|
||||||
if messageJson['type'] != 'Update':
|
if messageJson['type'] != 'Update':
|
||||||
return
|
return
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
if debug:
|
|
||||||
print('DEBUG: c2s actor update object is not dict')
|
|
||||||
return
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: c2s actor update - no type')
|
|
||||||
return
|
return
|
||||||
if not isinstance(messageJson['object']['type'], str):
|
if not isinstance(messageJson['object']['type'], str):
|
||||||
if debug:
|
if debug:
|
||||||
|
|
22
posts.py
22
posts.py
|
@ -32,6 +32,7 @@ from webfinger import webfingerHandle
|
||||||
from httpsig import createSignedHeader
|
from httpsig import createSignedHeader
|
||||||
from siteactive import siteIsActive
|
from siteactive import siteIsActive
|
||||||
from languages import understoodPostLanguage
|
from languages import understoodPostLanguage
|
||||||
|
from utils import hasObjectStringType
|
||||||
from utils import removeIdEnding
|
from utils import removeIdEnding
|
||||||
from utils import replaceUsersWithAt
|
from utils import replaceUsersWithAt
|
||||||
from utils import hasGroupType
|
from utils import hasGroupType
|
||||||
|
@ -2711,13 +2712,14 @@ def _isProfileUpdate(postJsonObject: {}) -> bool:
|
||||||
"""Is the given post a profile update?
|
"""Is the given post a profile update?
|
||||||
for actor updates there is no 'to' within the object
|
for actor updates there is no 'to' within the object
|
||||||
"""
|
"""
|
||||||
if postJsonObject['object'].get('type') and postJsonObject.get('type'):
|
if postJsonObject.get('type'):
|
||||||
if (postJsonObject['type'] == 'Update' and
|
if hasObjectStringType(postJsonObject, False):
|
||||||
(postJsonObject['object']['type'] == 'Person' or
|
if (postJsonObject['type'] == 'Update' and
|
||||||
postJsonObject['object']['type'] == 'Application' or
|
(postJsonObject['object']['type'] == 'Person' or
|
||||||
postJsonObject['object']['type'] == 'Group' or
|
postJsonObject['object']['type'] == 'Application' or
|
||||||
postJsonObject['object']['type'] == 'Service')):
|
postJsonObject['object']['type'] == 'Group' or
|
||||||
return True
|
postJsonObject['object']['type'] == 'Service')):
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -2752,7 +2754,7 @@ def sendToNamedAddresses(session, baseDir: str,
|
||||||
pprint(postJsonObject)
|
pprint(postJsonObject)
|
||||||
print('DEBUG: ' +
|
print('DEBUG: ' +
|
||||||
'no "to" field when sending to named addresses')
|
'no "to" field when sending to named addresses')
|
||||||
if postJsonObject['object'].get('type'):
|
if hasObjectStringType(postJsonObject, debug):
|
||||||
if postJsonObject['object']['type'] == 'Follow' or \
|
if postJsonObject['object']['type'] == 'Follow' or \
|
||||||
postJsonObject['object']['type'] == 'Join':
|
postJsonObject['object']['type'] == 'Join':
|
||||||
if isinstance(postJsonObject['object']['object'], str):
|
if isinstance(postJsonObject['object']['object'], str):
|
||||||
|
@ -2897,9 +2899,7 @@ def _sendingProfileUpdate(postJsonObject: {}) -> bool:
|
||||||
"""
|
"""
|
||||||
if postJsonObject['type'] != 'Update':
|
if postJsonObject['type'] != 'Update':
|
||||||
return False
|
return False
|
||||||
if not hasObjectDict(postJsonObject):
|
if not hasObjectStringType(postJsonObject, False):
|
||||||
return False
|
|
||||||
if not postJsonObject['object'].get('type'):
|
|
||||||
return False
|
return False
|
||||||
activityType = postJsonObject['object']['type']
|
activityType = postJsonObject['object']['type']
|
||||||
if activityType == 'Person' or \
|
if activityType == 'Person' or \
|
||||||
|
|
14
shares.py
14
shares.py
|
@ -22,6 +22,7 @@ from posts import getPersonBox
|
||||||
from session import postJson
|
from session import postJson
|
||||||
from session import postImage
|
from session import postImage
|
||||||
from session import createSession
|
from session import createSession
|
||||||
|
from utils import hasObjectStringType
|
||||||
from utils import dateStringToSeconds
|
from utils import dateStringToSeconds
|
||||||
from utils import dateSecondsToString
|
from utils import dateSecondsToString
|
||||||
from utils import getConfigParam
|
from utils import getConfigParam
|
||||||
|
@ -30,7 +31,6 @@ from utils import validNickname
|
||||||
from utils import loadJson
|
from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
from utils import getImageExtensions
|
from utils import getImageExtensions
|
||||||
from utils import hasObjectDict
|
|
||||||
from utils import removeDomainPort
|
from utils import removeDomainPort
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
|
@ -1030,11 +1030,7 @@ def outboxShareUpload(baseDir: str, httpPrefix: str,
|
||||||
return
|
return
|
||||||
if not messageJson['type'] == 'Add':
|
if not messageJson['type'] == 'Add':
|
||||||
return
|
return
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
return
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: undo block - no type')
|
|
||||||
return
|
return
|
||||||
if not messageJson['object']['type'] == 'Offer':
|
if not messageJson['object']['type'] == 'Offer':
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1103,11 +1099,7 @@ def outboxUndoShareUpload(baseDir: str, httpPrefix: str,
|
||||||
return
|
return
|
||||||
if not messageJson['type'] == 'Remove':
|
if not messageJson['type'] == 'Remove':
|
||||||
return
|
return
|
||||||
if not hasObjectDict(messageJson):
|
if not hasObjectStringType(messageJson, debug):
|
||||||
return
|
|
||||||
if not messageJson['object'].get('type'):
|
|
||||||
if debug:
|
|
||||||
print('DEBUG: undo block - no type')
|
|
||||||
return
|
return
|
||||||
if not messageJson['object']['type'] == 'Offer':
|
if not messageJson['object']['type'] == 'Offer':
|
||||||
if debug:
|
if debug:
|
||||||
|
|
21
utils.py
21
utils.py
|
@ -2037,7 +2037,7 @@ def isBlogPost(postJsonObject: {}) -> bool:
|
||||||
return False
|
return False
|
||||||
if not hasObjectDict(postJsonObject):
|
if not hasObjectDict(postJsonObject):
|
||||||
return False
|
return False
|
||||||
if not postJsonObject['object'].get('type'):
|
if not hasObjectStringType(postJsonObject, False):
|
||||||
return False
|
return False
|
||||||
if not postJsonObject['object'].get('content'):
|
if not postJsonObject['object'].get('content'):
|
||||||
return False
|
return False
|
||||||
|
@ -3034,3 +3034,22 @@ def hasActor(postJsonObject: {}, debug: bool) -> bool:
|
||||||
msg += ' ' + postJsonObject['id']
|
msg += ' ' + postJsonObject['id']
|
||||||
print(msg)
|
print(msg)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def hasObjectStringType(postJsonObject: {}, debug: bool) -> bool:
|
||||||
|
"""Dies the given post have a type field within an object dict?
|
||||||
|
"""
|
||||||
|
if not hasObjectDict(postJsonObject):
|
||||||
|
if debug:
|
||||||
|
print('hasObjectStringType no object found')
|
||||||
|
return False
|
||||||
|
if postJsonObject['object'].get('type'):
|
||||||
|
if isinstance(postJsonObject['object']['type'], str):
|
||||||
|
return True
|
||||||
|
elif debug:
|
||||||
|
if postJsonObject.get('type'):
|
||||||
|
print('DEBUG: ' + postJsonObject['type'] +
|
||||||
|
' type within object is not a string')
|
||||||
|
if debug:
|
||||||
|
print('No type field within object ' + postJsonObject['id'])
|
||||||
|
return False
|
||||||
|
|
Loading…
Reference in New Issue