merge-requests/30/head
Bob Mottram 2021-07-04 18:55:29 +01:00
parent e30829416d
commit 83b1bfb293
3 changed files with 14 additions and 15 deletions

View File

@ -27,6 +27,7 @@ from utils import saveJson
from utils import isSuspended
from utils import containsInvalidChars
from utils import removeHtml
from utils import isAccountDir
from blocking import isBlockedDomain
from blocking import isBlockedHashtag
from filters import isFiltered
@ -964,9 +965,7 @@ def _addBlogsToNewswire(baseDir: str, domain: str, newswire: {},
# go through each account
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
for handle in dirs:
if '@' not in handle:
continue
if 'inbox@' in handle or 'news@' in handle:
if not isAccountDir(handle):
continue
nickname = handle.split('@')[0]

View File

@ -13,6 +13,7 @@ import datetime
from utils import hasObjectDict
from utils import getStatusNumber
from utils import loadJson
from utils import isAccountDir
from outbox import postMessageToOutbox
@ -116,8 +117,8 @@ def _updatePostSchedule(baseDir: str, handle: str, httpd,
continue
# move to the outbox
outboxPostFilename = \
postFilename.replace('/scheduled/', '/outbox/')
outboxPostFilename = postFilename.replace('/scheduled/',
'/outbox/')
os.rename(postFilename, outboxPostFilename)
print('Scheduled post sent ' + postId)
@ -144,9 +145,7 @@ def runPostSchedule(baseDir: str, httpd, maxScheduledPosts: int):
for account in dirs:
if '@' not in account:
continue
if account.startswith('inbox@'):
continue
if account.startswith('news@'):
if not isAccountDir(account):
continue
# scheduled posts index for this account
scheduleIndexFilename = \

View File

@ -10,6 +10,7 @@ __module_group__ = "Core"
import os
import requests
from utils import urlPermitted
from utils import isImageFile
import json
from socket import error as SocketError
import errno
@ -257,11 +258,7 @@ def postImage(session, attachImageFilename: str, federationList: [],
print('postJson: ' + inboxUrl + ' not permitted')
return None
if not (attachImageFilename.endswith('.jpg') or
attachImageFilename.endswith('.jpeg') or
attachImageFilename.endswith('.png') or
attachImageFilename.endswith('.svg') or
attachImageFilename.endswith('.gif')):
if not isImageFile(attachImageFilename):
print('Image must be png, jpg, gif or svg')
return None
if not os.path.isfile(attachImageFilename):
@ -270,9 +267,13 @@ def postImage(session, attachImageFilename: str, federationList: [],
contentType = 'image/jpeg'
if attachImageFilename.endswith('.png'):
contentType = 'image/png'
if attachImageFilename.endswith('.gif'):
elif attachImageFilename.endswith('.gif'):
contentType = 'image/gif'
if attachImageFilename.endswith('.svg'):
elif attachImageFilename.endswith('.webp'):
contentType = 'image/webp'
elif attachImageFilename.endswith('.avif'):
contentType = 'image/avif'
elif attachImageFilename.endswith('.svg'):
contentType = 'image/svg+xml'
headers['Content-type'] = contentType