Media path same as mastodon

merge-requests/30/head
Bob Mottram 2021-10-12 19:20:40 +01:00
parent 6a9cd38912
commit dccb22c393
4 changed files with 14 additions and 2 deletions

View File

@ -11387,7 +11387,7 @@ class PubServer(BaseHTTPRequestHandler):
'/system/accounts/headers/' not in path and \
'/accounts/avatars/' not in path and \
'/accounts/headers/' not in path:
return False
return False
if not isImageFile(path):
return False
if '/system/accounts/avatars/' in path:
@ -13229,6 +13229,10 @@ class PubServer(BaseHTTPRequestHandler):
# show media
# Note that this comes before the busy flag to avoid conflicts
# replace mastoson-style media path
if '/system/media_attachments/files/' in self.path:
self.path = self.path.replace('/system/media_attachments/files/',
'/media/')
if '/media/' in self.path:
self._showMedia(callingDomain,
self.path, self.server.baseDir,

View File

@ -325,6 +325,8 @@ def attachMedia(baseDir: str, httpPrefix: str,
createMediaDirs(baseDir, mPath)
mediaFilename = baseDir + '/' + mediaPath
mediaPath = \
mediaPath.replace('media/', 'system/media_attachments/files/', 1)
attachmentJson = {
'mediaType': mediaType,
'name': description,

View File

@ -337,6 +337,10 @@ def postMessageToOutbox(session, translate: {},
# change the url of the attachment
attach['url'] = \
httpPrefix + '://' + domainFull + '/' + mediaPath
attach['url'] = \
attach['url'].replace('/media/',
'/system/' +
'media_attachments/files/')
permittedOutboxTypes = ('Create', 'Announce', 'Like', 'Follow', 'Undo',
'Update', 'Add', 'Remove', 'Block', 'Delete',

View File

@ -1299,7 +1299,9 @@ def testPostMessageBetweenServers(baseDir: str) -> None:
assert attached.get('type')
assert attached.get('url')
assert attached['mediaType'] == 'image/png'
assert '/media/' in attached['url']
if not '/system/media_attachments/files/' in attached['url']:
print(attached['url'])
assert '/system/media_attachments/files/' in attached['url']
assert attached['url'].endswith('.png')
assert attached.get('width')
assert attached.get('height')