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 <[email protected]>
  • Loading branch information
Antreesy committed Sep 11, 2024
1 parent 7c932c8 commit 41f8af4
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 @@ -110,8 +110,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 { t } from '@nextcloud/l10n'
Expand Down Expand Up @@ -268,24 +266,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 41f8af4

Please sign in to comment.