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) => {
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:
// 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");
break;
case NS_URI:
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");
break;
}
if (url_get == null || url_put == null) {
error_listener(stream, "Error getting upload/download url");
}
listener(stream, url_get, url_put);
});