mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-30 03:09:53 +01:00
fix: hack uploader to handle a response from v3 write api
This commit is contained in:
@@ -65,7 +65,9 @@ define('uploader', ['jquery-form'], function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.ajaxSubmit = function (uploadModal, callback) {
|
module.ajaxSubmit = function (uploadModal, callback) {
|
||||||
uploadModal.find('#uploadForm').ajaxSubmit({
|
const uploadForm = uploadModal.find('#uploadForm');
|
||||||
|
const v3 = uploadForm.attr('action').startsWith(config.relative_path + '/api/v3/');
|
||||||
|
uploadForm.ajaxSubmit({
|
||||||
headers: {
|
headers: {
|
||||||
'x-csrf-token': config.csrf_token,
|
'x-csrf-token': config.csrf_token,
|
||||||
},
|
},
|
||||||
@@ -79,6 +81,17 @@ define('uploader', ['jquery-form'], function () {
|
|||||||
success: function (response) {
|
success: function (response) {
|
||||||
response = maybeParse(response);
|
response = maybeParse(response);
|
||||||
|
|
||||||
|
// Appropriately handle v3 API responses
|
||||||
|
if (v3) {
|
||||||
|
if (response.status.code === 'ok') {
|
||||||
|
response = response.response.images;
|
||||||
|
} else {
|
||||||
|
response = {
|
||||||
|
error: response.status.code,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
return showAlert(uploadModal, 'error', response.error);
|
return showAlert(uploadModal, 'error', response.error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user