Correctly display error when HTTP File Upload isn’t supported by the server.

This commit is contained in:
Emmanuel Gil Peyrot 2018-11-02 04:47:59 +01:00 committed by JC Brand
parent 0d4603d80d
commit 5cd7ccb3ef
2 changed files with 22 additions and 4 deletions

13
dist/converse.js vendored
View File

@ -70983,8 +70983,17 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
async sendFiles(files) {
const result = await _converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain),
item = result.pop(),
data = item.dataforms.where({
item = result.pop();
if (!item) {
this.messages.create({
'message': __("Sorry, looks like file upload is not supported by your server."),
'type': 'error'
});
return;
}
const data = item.dataforms.where({
'FORM_TYPE': {
'value': Strophe.NS.HTTPUPLOAD,
'type': "hidden"

View File

@ -418,8 +418,17 @@ converse.plugins.add('converse-chatboxes', {
async sendFiles (files) {
const result = await _converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain),
item = result.pop(),
data = item.dataforms.where({'FORM_TYPE': {'value': Strophe.NS.HTTPUPLOAD, 'type': "hidden"}}).pop(),
item = result.pop();
if (!item) {
this.messages.create({
'message': __("Sorry, looks like file upload is not supported by your server."),
'type': 'error'
});
return;
}
const data = item.dataforms.where({'FORM_TYPE': {'value': Strophe.NS.HTTPUPLOAD, 'type': "hidden"}}).pop(),
max_file_size = window.parseInt(_.get(data, 'attributes.max-file-size.value')),
slot_request_url = _.get(item, 'id');