From 312372350e24d1ebd8afbb0029fac04f2b64eb83 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 4 Sep 2017 19:47:42 +0200 Subject: http files: Accept url put/get urls in both attributes and string content --- plugins/http-files/src/upload_stream_module.vala | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'plugins/http-files') diff --git a/plugins/http-files/src/upload_stream_module.vala b/plugins/http-files/src/upload_stream_module.vala index 2e794593..db2e655b 100644 --- a/plugins/http-files/src/upload_stream_module.vala +++ b/plugins/http-files/src/upload_stream_module.vala @@ -28,7 +28,7 @@ public class UploadStreamModule : XmppStreamModule { session.send_async.begin(message, null, (obj, res) => { try { session.send_async.end(res); - if (message.status_code == 200) { + if (message.status_code >= 200 && message.status_code < 300) { listener(stream, url_down); } else { error_listener(stream, "HTTP status code " + message.status_code.to_string()); @@ -65,19 +65,19 @@ public class UploadStreamModule : XmppStreamModule { Iq.Stanza iq = new Iq.Stanza.get(request_node) { to=flag.file_store_jid }; stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => { if (iq.is_error()) { - error_listener(stream, ""); + error_listener(stream, "Error getting upload/download url"); return; } string? url_get = null, url_put = null; - switch (flag.ns_ver) { - case NS_URI_0: - url_get = iq.stanza.get_deep_attribute(flag.ns_ver + ":slot", flag.ns_ver + ":get", flag.ns_ver + ":url"); - url_put = iq.stanza.get_deep_attribute(flag.ns_ver + ":slot", flag.ns_ver + ":put", flag.ns_ver + ":url"); - break; - case NS_URI: - url_get = iq.stanza.get_deep_string_content(flag.ns_ver + ":slot", flag.ns_ver + ":get"); - url_put = iq.stanza.get_deep_string_content(flag.ns_ver + ":slot", flag.ns_ver + ":put"); - break; + // FIXME change back to switch on version in a while (prosody bug) + url_get = iq.stanza.get_deep_attribute(flag.ns_ver + ":slot", flag.ns_ver + ":get", flag.ns_ver + ":url"); + url_put = iq.stanza.get_deep_attribute(flag.ns_ver + ":slot", flag.ns_ver + ":put", flag.ns_ver + ":url"); + if (url_get == null && url_put == null) { + url_get = iq.stanza.get_deep_string_content(flag.ns_ver + ":slot", flag.ns_ver + ":get"); + url_put = iq.stanza.get_deep_string_content(flag.ns_ver + ":slot", flag.ns_ver + ":put"); + } + if (url_get == null || url_put == null) { + error_listener(stream, "Error getting upload/download url"); } listener(stream, url_get, url_put); }); -- cgit v1.2.3-70-g09d2