aboutsummaryrefslogtreecommitdiff
path: root/plugins/http-files
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-09-04 19:47:42 +0200
committerfiaxh <git@mx.ax.lt>2017-09-05 19:13:30 +0200
commit312372350e24d1ebd8afbb0029fac04f2b64eb83 (patch)
tree02cf6c8fb5f4361641e7d72f437192dbe2527337 /plugins/http-files
parentaddd5a013fe2e957e228ec4c670359c701745184 (diff)
downloaddino-312372350e24d1ebd8afbb0029fac04f2b64eb83.tar.gz
dino-312372350e24d1ebd8afbb0029fac04f2b64eb83.zip
http files: Accept url put/get urls in both attributes and string content
Diffstat (limited to 'plugins/http-files')
-rw-r--r--plugins/http-files/src/upload_stream_module.vala22
1 files changed, 11 insertions, 11 deletions
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);
});