http files: Accept url put/get urls in both attributes and string content

This commit is contained in:
fiaxh 2017-09-04 19:47:42 +02:00
parent addd5a013f
commit 312372350e

View file

@ -28,7 +28,7 @@ public class UploadStreamModule : XmppStreamModule {
session.send_async.begin(message, null, (obj, res) => { session.send_async.begin(message, null, (obj, res) => {
try { try {
session.send_async.end(res); session.send_async.end(res);
if (message.status_code == 200) { if (message.status_code >= 200 && message.status_code < 300) {
listener(stream, url_down); listener(stream, url_down);
} else { } else {
error_listener(stream, "HTTP status code " + message.status_code.to_string()); 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 }; 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) => { stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
if (iq.is_error()) { if (iq.is_error()) {
error_listener(stream, ""); error_listener(stream, "Error getting upload/download url");
return; return;
} }
string? url_get = null, url_put = null; string? url_get = null, url_put = null;
switch (flag.ns_ver) { // FIXME change back to switch on version in a while (prosody bug)
case NS_URI_0:
url_get = iq.stanza.get_deep_attribute(flag.ns_ver + ":slot", flag.ns_ver + ":get", flag.ns_ver + ":url"); 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"); url_put = iq.stanza.get_deep_attribute(flag.ns_ver + ":slot", flag.ns_ver + ":put", flag.ns_ver + ":url");
break; if (url_get == null && url_put == null) {
case NS_URI:
url_get = iq.stanza.get_deep_string_content(flag.ns_ver + ":slot", flag.ns_ver + ":get"); 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"); url_put = iq.stanza.get_deep_string_content(flag.ns_ver + ":slot", flag.ns_ver + ":put");
break; }
if (url_get == null || url_put == null) {
error_listener(stream, "Error getting upload/download url");
} }
listener(stream, url_get, url_put); listener(stream, url_get, url_put);
}); });