BastliBridge

A bot framework bridgin multiple IM protocols, and mail
git clone git://xatko.vsos.ethz.ch/BastliBridge.git
Log | Files | Refs | Submodules

commit baa96fabfde1be03ff37c1b68bcc1dc4318f9791
parent 025f8c9b95c63865497de78941db764ca8f238ce
Author: Dominik Schmidt <das1993@hotmail.com>
Date:   Mon,  9 Oct 2017 15:37:24 +0200

Return JSONValue instead of only the path on getFile call.

Diffstat:
src/bastlibridge/telegram.d | 4++--
src/proxy.d | 15++++-----------
2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/src/bastlibridge/telegram.d b/src/bastlibridge/telegram.d @@ -305,7 +305,7 @@ struct Telegram{ return _botName; } - string getFile(in char[] file_id){ + JSONValue getFile(in char[] file_id){ JSONValue j; j.object=null; j["file_id"]=file_id; @@ -317,7 +317,7 @@ struct Telegram{ j=r.get; auto v="file_path" in j; if(v) - return v.str; + return j; else throw new TelegramException(cast(string)("Path of file "~file_id~" was not found")); } diff --git a/src/proxy.d b/src/proxy.d @@ -81,20 +81,12 @@ void handleClient(Socket newsock){ not_found(); } else{ - string path; + JSONValue file; try{ - path=telegram.getFile(req.url[2..$]); - if(path.length==0){ - not_found(); - return; - } + file=telegram.getFile(req.url[2..$]); } catch(TelegramException e){ - res.response(404, "Not Found"); - res.header("Connection", "close"); - res.header("Content-Type", "text/plain"); - res.data(fof); - res.perform(newsock); + not_found(); return; } catch(Exception e){ @@ -105,6 +97,7 @@ void handleClient(Socket newsock){ res.perform(newsock); return; } + string path=file["file_path"].str; static HttpRequest!void r2; r2.request("GET", chain("file/bot", telegram.token, "/", path)); r2.header("Host", telegram.ApiAddr);