mirror of https://gitlab.com/bashrc2/epicyon
Equality check
parent
ffd0e15fa2
commit
9510ac8bf8
36
announce.py
36
announce.py
|
@ -27,6 +27,24 @@ from webfinger import webfingerHandle
|
||||||
from auth import createBasicAuthHeader
|
from auth import createBasicAuthHeader
|
||||||
|
|
||||||
|
|
||||||
|
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']
|
||||||
|
|
||||||
|
|
||||||
def outboxAnnounce(recentPostsCache: {},
|
def outboxAnnounce(recentPostsCache: {},
|
||||||
baseDir: str, messageJson: {}, debug: bool) -> bool:
|
baseDir: str, messageJson: {}, debug: bool) -> bool:
|
||||||
""" Adds or removes announce entries from the shares collection
|
""" Adds or removes announce entries from the shares collection
|
||||||
|
@ -393,21 +411,3 @@ def outboxUndoAnnounce(recentPostsCache: {},
|
||||||
messageJson['actor'], domain, debug)
|
messageJson['actor'], domain, debug)
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: post undo announce via c2s - ' + postFilename)
|
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']
|
|
||||||
|
|
|
@ -402,7 +402,7 @@ def postMessageToOutbox(session, translate: {},
|
||||||
continue
|
continue
|
||||||
# avoid duplicates of the message if already going
|
# avoid duplicates of the message if already going
|
||||||
# back to the inbox of the same account
|
# back to the inbox of the same account
|
||||||
if selfActor not in messageJson['to']:
|
if messageJson['to'] != selfActor:
|
||||||
# show sent post within the inbox,
|
# show sent post within the inbox,
|
||||||
# as is the typical convention
|
# as is the typical convention
|
||||||
inboxUpdateIndex(boxNameIndex, baseDir,
|
inboxUpdateIndex(boxNameIndex, baseDir,
|
||||||
|
|
Loading…
Reference in New Issue