Extra media check

main2
Bob Mottram 2019-09-28 13:27:48 +01:00
parent 588f42a896
commit 0b2a7c1676
1 changed files with 3 additions and 6 deletions

View File

@ -1704,12 +1704,9 @@ def isImageMedia(postJsonObject: {}) -> bool:
return False return False
if not isinstance(postJsonObject['object']['attachment'], list): if not isinstance(postJsonObject['object']['attachment'], list):
return False return False
if len(postJsonObject['object']['attachment'])==0:
return False
for attach in postJsonObject['object']['attachment']: for attach in postJsonObject['object']['attachment']:
if attach.get('mediaType') and attach.get('url'): if attach.get('mediaType') and attach.get('url'):
mediaType=attach['mediaType'] if attach['mediaType'].startswith('image/'):
if mediaType.startswith('image/'):
return True return True
return False return False
@ -1742,7 +1739,7 @@ def createBoxBase(baseDir: str,boxname: str, \
if boxname!='dm' and boxname!='tlreplies' and boxname!='tlmedia': if boxname!='dm' and boxname!='tlreplies' and boxname!='tlmedia':
boxDir = createPersonDir(nickname,domain,baseDir,boxname) boxDir = createPersonDir(nickname,domain,baseDir,boxname)
else: else:
# extract DMs or replies from the inbox # extract DMs or replies or media from the inbox
boxDir = createPersonDir(nickname,domain,baseDir,'inbox') boxDir = createPersonDir(nickname,domain,baseDir,'inbox')
sharedBoxDir=None sharedBoxDir=None
if boxname=='inbox' or boxname=='tlreplies' or boxname=='tlmedia': if boxname=='inbox' or boxname=='tlreplies' or boxname=='tlmedia':
@ -1889,7 +1886,7 @@ def createBoxBase(baseDir: str,boxname: str, \
if boxActor not in postStr: if boxActor not in postStr:
isPost=False isPost=False
elif boxname=='tlmedia': elif boxname=='tlmedia':
if 'image/' not in postStr: if 'mediaType' not in postStr or 'image/' not in postStr:
isPost=False isPost=False
if isPost: if isPost: