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

@ -13229,6 +13229,10 @@ class PubServer(BaseHTTPRequestHandler):
# show media # show media
# Note that this comes before the busy flag to avoid conflicts # 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: if '/media/' in self.path:
self._showMedia(callingDomain, self._showMedia(callingDomain,
self.path, self.server.baseDir, self.path, self.server.baseDir,

View File

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

View File

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

View File

@ -1299,7 +1299,9 @@ def testPostMessageBetweenServers(baseDir: str) -> None:
assert attached.get('type') assert attached.get('type')
assert attached.get('url') assert attached.get('url')
assert attached['mediaType'] == 'image/png' 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['url'].endswith('.png')
assert attached.get('width') assert attached.get('width')
assert attached.get('height') assert attached.get('height')