Skip to content

Commit

Permalink
fix(avatar): don't use 'user/avatar' endpoint for generating a temp a…
Browse files Browse the repository at this point in the history
…vatar

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy authored and backportbot[bot] committed Sep 12, 2024
1 parent 418732f commit e91a49f
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions src/components/ConversationSettings/ConversationAvatarEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ import Folder from 'vue-material-design-icons/Folder.vue'
import Palette from 'vue-material-design-icons/Palette.vue'
import Upload from 'vue-material-design-icons/Upload.vue'
import { getRequestToken } from '@nextcloud/auth'
import axios from '@nextcloud/axios'
import { showError } from '@nextcloud/dialogs'
import { FilePickerVue } from '@nextcloud/dialogs/filepicker.js'
import { generateUrl } from '@nextcloud/router'
Expand Down Expand Up @@ -277,24 +275,15 @@ export default {
},
async handleFileChoose(nodes) {
const path = nodes[0]?.path
if (!path) {
const fileid = nodes[0]?.fileid
if (!fileid) {
return
}
this.loading = true
try {
const { data } = await axios.post(generateUrl('/avatar'), { path })
if (data.status === 'success') {
this.loading = false
} else if (data.data === 'notsquare') {
const tempAvatar = generateUrl('/avatar/tmp') + '?requesttoken=' + encodeURIComponent(getRequestToken()) + '#' + Math.floor(Math.random() * 1000)
this.$refs.cropper.replace(tempAvatar)
this.showCropper = true
} else {
showError(data.data.message)
this.cancel()
}
const tempAvatar = generateUrl(`/core/preview?fileId=${fileid}&x=512&y=512&a=1`)
this.$refs.cropper.replace(tempAvatar)
this.showCropper = true
} catch (e) {
showError(t('spreed', 'Error setting conversation picture'))
this.cancel()
Expand Down

0 comments on commit e91a49f

Please sign in to comment.