Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable28] fix(avatar): don't use 'user/avatar' endpoint for generating a temp avatar #13287

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading