mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-02-02 09:54:29 +00:00
support store/retrieval of additional 'mimetype' field in shortened urls.
'decodeshorturl' now returns an array instead of a single string, so it breaks compatibility. as we've just been playing with the 'blaster' branch of twister-html that's not a big deal.
This commit is contained in:
parent
54b1d9e9a3
commit
11155b622f
@ -8,7 +8,7 @@
|
|||||||
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
|
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
|
||||||
#define CLIENT_VERSION_MAJOR 0
|
#define CLIENT_VERSION_MAJOR 0
|
||||||
#define CLIENT_VERSION_MINOR 9
|
#define CLIENT_VERSION_MINOR 9
|
||||||
#define CLIENT_VERSION_REVISION 36
|
#define CLIENT_VERSION_REVISION 37
|
||||||
#define CLIENT_VERSION_BUILD 0
|
#define CLIENT_VERSION_BUILD 0
|
||||||
|
|
||||||
// Set to true for release, false for prerelease or test build
|
// Set to true for release, false for prerelease or test build
|
||||||
|
@ -4155,8 +4155,8 @@ Value peekpost(const Array& params, bool fHelp)
|
|||||||
"peekpost <username> <k> [field='*'] [timeout_sec=90]\n"
|
"peekpost <username> <k> [field='*'] [timeout_sec=90]\n"
|
||||||
"Peek post from best/faster available source, either\n"
|
"Peek post from best/faster available source, either\n"
|
||||||
"local torrent, DHT or remote torrent (peek extension).\n"
|
"local torrent, DHT or remote torrent (peek extension).\n"
|
||||||
"field is a convenience to return specific post field\n"
|
"field is a convenience to return specific post field(s)\n"
|
||||||
"instead of the whole post (eg. 'url')");
|
"instead of the whole post (eg. 'url' or 'url,mimetype')");
|
||||||
|
|
||||||
boost::shared_ptr<session> ses(m_ses);
|
boost::shared_ptr<session> ses(m_ses);
|
||||||
if( !ses )
|
if( !ses )
|
||||||
@ -4256,9 +4256,25 @@ Value peekpost(const Array& params, bool fHelp)
|
|||||||
} else {
|
} else {
|
||||||
entry const *userpost = vEntry.find_key("userpost");
|
entry const *userpost = vEntry.find_key("userpost");
|
||||||
if( userpost && userpost->type() == entry::dictionary_t ) {
|
if( userpost && userpost->type() == entry::dictionary_t ) {
|
||||||
entry const *f = userpost->find_key(strField);
|
if( strField.find(',') == string::npos ) {
|
||||||
if( f && f->type() == entry::string_t ) {
|
entry const *f = userpost->find_key(strField);
|
||||||
ret = f->string();
|
if( f && f->type() == entry::string_t ) {
|
||||||
|
ret = f->string();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vector<string> fieldList;
|
||||||
|
Array retList;
|
||||||
|
boost::algorithm::split(fieldList,strField,std::bind1st(std::equal_to<char>(),','),
|
||||||
|
boost::algorithm::token_compress_on);
|
||||||
|
BOOST_FOREACH(string const& field, fieldList) {
|
||||||
|
entry const *f = userpost->find_key(field);
|
||||||
|
if( f && f->type() == entry::string_t ) {
|
||||||
|
retList.push_back(f->string());
|
||||||
|
} else {
|
||||||
|
retList.push_back("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = retList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4308,9 +4324,9 @@ Value usernametouid(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
Value newshorturl(const Array& params, bool fHelp)
|
Value newshorturl(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 3)
|
if (fHelp || params.size() < 3 || params.size() > 4)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"newshorturl <username> <k> <url>\n"
|
"newshorturl <username> <k> <url> [mimetype]\n"
|
||||||
"Shorten URL, create a post containing it add to swarm.\n"
|
"Shorten URL, create a post containing it add to swarm.\n"
|
||||||
"Returns the shortened twister URI (multiple options may be returned)");
|
"Returns the shortened twister URI (multiple options may be returned)");
|
||||||
|
|
||||||
@ -4319,6 +4335,9 @@ Value newshorturl(const Array& params, bool fHelp)
|
|||||||
string strUsername = params[0].get_str();
|
string strUsername = params[0].get_str();
|
||||||
int k = params[1].get_int();
|
int k = params[1].get_int();
|
||||||
string strUrl = params[2].get_str();
|
string strUrl = params[2].get_str();
|
||||||
|
string strMimeType;
|
||||||
|
if( params.size() > 3 )
|
||||||
|
strMimeType = params[3].get_str();
|
||||||
|
|
||||||
Array paramsSub;
|
Array paramsSub;
|
||||||
Value res;
|
Value res;
|
||||||
@ -4328,6 +4347,8 @@ Value newshorturl(const Array& params, bool fHelp)
|
|||||||
paramsSub.push_back(k);
|
paramsSub.push_back(k);
|
||||||
Object fields;
|
Object fields;
|
||||||
fields.push_back(Pair("url",strUrl));
|
fields.push_back(Pair("url",strUrl));
|
||||||
|
if( strMimeType.size() )
|
||||||
|
fields.push_back(Pair("mimetype",strMimeType));
|
||||||
paramsSub.push_back(fields);
|
paramsSub.push_back(fields);
|
||||||
res = newpostcustom(paramsSub,false);
|
res = newpostcustom(paramsSub,false);
|
||||||
|
|
||||||
@ -4354,7 +4375,7 @@ Value decodeshorturl(const Array& params, bool fHelp)
|
|||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"decodeshorturl <twist:xxx> [timeout_sec=90]\n"
|
"decodeshorturl <twist:xxx> [timeout_sec=90]\n"
|
||||||
"Decodes a shortened URL by twister. May take some time to complete, like dhtget etc.\n"
|
"Decodes a shortened URL by twister. May take some time to complete, like dhtget etc.\n"
|
||||||
"Returns the original URL or error if not found, timeout");
|
"Returns the original [URL,mimetype] or error if not found, timeout");
|
||||||
|
|
||||||
string strTwistURI = params[0].get_str();
|
string strTwistURI = params[0].get_str();
|
||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
@ -4386,7 +4407,7 @@ Value decodeshorturl(const Array& params, bool fHelp)
|
|||||||
paramsSub.clear();
|
paramsSub.clear();
|
||||||
paramsSub.push_back(strUsername);
|
paramsSub.push_back(strUsername);
|
||||||
paramsSub.push_back(k);
|
paramsSub.push_back(k);
|
||||||
paramsSub.push_back("url");
|
paramsSub.push_back("url,mimetype");
|
||||||
if(timeout) {
|
if(timeout) {
|
||||||
paramsSub.push_back(timeout);
|
paramsSub.push_back(timeout);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user