From 20ada3149840d81c471fb96b929ded5760f5234e Mon Sep 17 00:00:00 2001 From: lain Date: Thu, 25 Jun 2020 09:51:26 +0200 Subject: [PATCH] Normalizing: Natively use attachments. --- src/components/attachment/attachment.js | 4 ++-- src/components/attachment/attachment.vue | 2 +- src/modules/media_viewer.js | 2 +- .../entity_normalizer.service.js | 18 +----------------- src/services/file_type/file_type.service.js | 2 +- .../notification_utils/notification_utils.js | 2 +- 6 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index b832e10f..528c3691 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -20,7 +20,7 @@ const Attachment = { hideNsfwLocal: this.$store.getters.mergedConfig.hideNsfw, preloadImage: this.$store.getters.mergedConfig.preloadImage, loading: false, - img: fileTypeService.fileType(this.attachment.mimetype) === 'image' && document.createElement('img'), + img: fileTypeService.fileType(this.attachment.pleroma.mime_type) === 'image' && document.createElement('img'), modalOpen: false, showHidden: false } @@ -37,7 +37,7 @@ const Attachment = { return this.$store.state.instance.mediaProxyAvailable ? '' : 'no-referrer' }, type () { - return fileTypeService.fileType(this.attachment.mimetype) + return fileTypeService.fileType(this.attachment.pleroma.mime_type) }, hidden () { return this.nsfw && this.hideNsfwLocal && !this.showHidden diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index a7e217c1..fdd87d2c 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -56,7 +56,7 @@ > diff --git a/src/modules/media_viewer.js b/src/modules/media_viewer.js index a24b408d..b2e1d433 100644 --- a/src/modules/media_viewer.js +++ b/src/modules/media_viewer.js @@ -21,7 +21,7 @@ const mediaViewer = { actions: { setMedia ({ commit }, attachments) { const media = attachments.filter(attachment => { - const type = fileTypeService.fileType(attachment.mimetype) + const type = fileTypeService.fileType(attachment.pleroma.mime_type) return type === 'image' || type === 'video' }) commit('setMedia', media) diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 3bdb92f3..1d08586f 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -192,23 +192,7 @@ export const parseUser = (data) => { } export const parseAttachment = (data) => { - const output = {} - const masto = !data.hasOwnProperty('oembed') - - if (masto) { - // Not exactly same... - output.mimetype = data.pleroma ? data.pleroma.mime_type : data.type - output.meta = data.meta // not present in BE yet - output.id = data.id - } else { - output.mimetype = data.mimetype - // output.meta = ??? missing - } - - output.url = data.url - output.description = data.description - - return output + return data } export const addEmojis = (string, emojis) => { const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g diff --git a/src/services/file_type/file_type.service.js b/src/services/file_type/file_type.service.js index 2a046bec..f6ef8300 100644 --- a/src/services/file_type/file_type.service.js +++ b/src/services/file_type/file_type.service.js @@ -22,7 +22,7 @@ const fileType = mimetype => { } const fileMatchesSomeType = (types, file) => - types.some(type => fileType(file.mimetype) === type) + types.some(type => fileType(file.pleroma.mime_type) === type) const fileTypeService = { fileType, diff --git a/src/services/notification_utils/notification_utils.js b/src/services/notification_utils/notification_utils.js index 5cc19215..75b406bf 100644 --- a/src/services/notification_utils/notification_utils.js +++ b/src/services/notification_utils/notification_utils.js @@ -81,7 +81,7 @@ export const prepareNotificationObject = (notification, i18n) => { // Shows first attached non-nsfw image, if any. Should add configuration for this somehow... if (status && status.attachments && status.attachments.length > 0 && !status.nsfw && - status.attachments[0].mimetype.startsWith('image/')) { + status.attachments[0].pleroma.mime_type.startsWith('image/')) { notifObj.image = status.attachments[0].url }