mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd: Reverse arguments for url::encode()/decode(); minor reorg.
This commit is contained in:
parent
2caf425fde
commit
6de17431ff
35 changed files with 173 additions and 163 deletions
|
@ -32,10 +32,10 @@ namespace ircd::rfc3986
|
|||
void valid_remote(const string_view &); // host + optional :port
|
||||
bool valid_remote(std::nothrow_t, const string_view &);
|
||||
|
||||
string_view encode(const string_view &url, const mutable_buffer &);
|
||||
string_view decode(const string_view &url, const mutable_buffer &);
|
||||
string_view encode(const mutable_buffer &, const string_view &url);
|
||||
string_view encode(const mutable_buffer &, const json::members &);
|
||||
|
||||
string_view form_encode(const mutable_buffer &out, const json::members &);
|
||||
string_view decode(const mutable_buffer &, const string_view &url);
|
||||
}
|
||||
|
||||
namespace ircd
|
||||
|
|
44
ircd/m/v1.cc
44
ircd/m/v1.cc
|
@ -114,7 +114,7 @@ ircd::m::v1::send::send(const string_view &txnid,
|
|||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||
{
|
||||
urlbuf, "/_matrix/federation/v1/send/%s/",
|
||||
url::encode(txnid, txnidbuf),
|
||||
url::encode(txnidbuf, txnid),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -179,11 +179,11 @@ ircd::m::v1::public_rooms::public_rooms(const net::hostport &remote,
|
|||
|
||||
if(opts.since)
|
||||
qss << "&since="
|
||||
<< url::encode(opts.since, since);
|
||||
<< url::encode(since, opts.since);
|
||||
|
||||
if(opts.third_party_instance_id)
|
||||
qss << "&third_party_instance_id="
|
||||
<< url::encode(opts.third_party_instance_id, tpid);
|
||||
<< url::encode(tpid, opts.third_party_instance_id);
|
||||
|
||||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||
{
|
||||
|
@ -255,7 +255,7 @@ ircd::m::v1::frontfill::frontfill(const room::id &room_id,
|
|||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||
{
|
||||
urlbuf, "/_matrix/federation/v1/get_missing_events/%s/",
|
||||
url::encode(room_id, ridbuf)
|
||||
url::encode(ridbuf, room_id)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -365,9 +365,9 @@ ircd::m::v1::backfill::backfill(const room::id &room_id,
|
|||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||
{
|
||||
urlbuf, "/_matrix/federation/v1/backfill/%s/?limit=%zu&v=%s",
|
||||
url::encode(room_id, ridbuf),
|
||||
url::encode(ridbuf, room_id),
|
||||
opts.limit,
|
||||
url::encode(opts.event_id, eidbuf),
|
||||
url::encode(eidbuf, opts.event_id),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -438,8 +438,8 @@ ircd::m::v1::state::state(const room::id &room_id,
|
|||
{
|
||||
urlbuf, "/_matrix/federation/v1/%s/%s/?event_id=%s",
|
||||
opts.ids_only? "state_ids" : "state",
|
||||
url::encode(room_id, ridbuf),
|
||||
url::encode(opts.event_id, eidbuf),
|
||||
url::encode(ridbuf, room_id),
|
||||
url::encode(eidbuf, opts.event_id),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -504,8 +504,8 @@ ircd::m::v1::event_auth::event_auth(const m::room::id &room_id,
|
|||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||
{
|
||||
urlbuf, "/_matrix/federation/v1/event_auth/%s/%s",
|
||||
url::encode(room_id, ridbuf),
|
||||
url::encode(event_id, eidbuf),
|
||||
url::encode(ridbuf, room_id),
|
||||
url::encode(eidbuf, event_id),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -568,7 +568,7 @@ ircd::m::v1::event::event(const m::event::id &event_id,
|
|||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||
{
|
||||
urlbuf, "/_matrix/federation/v1/event/%s/",
|
||||
url::encode(event_id, eidbuf),
|
||||
url::encode(eidbuf, event_id),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -623,8 +623,8 @@ ircd::m::v1::invite::invite(const room::id &room_id,
|
|||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||
{
|
||||
urlbuf, "/_matrix/federation/v1/invite/%s/%s",
|
||||
url::encode(room_id, ridbuf),
|
||||
url::encode(event_id, eidbuf)
|
||||
url::encode(ridbuf, room_id),
|
||||
url::encode(eidbuf, event_id)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -679,8 +679,8 @@ ircd::m::v1::send_join::send_join(const room::id &room_id,
|
|||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||
{
|
||||
urlbuf, "/_matrix/federation/v1/send_join/%s/%s",
|
||||
url::encode(room_id, ridbuf),
|
||||
url::encode(event_id, uidbuf)
|
||||
url::encode(ridbuf, room_id),
|
||||
url::encode(uidbuf, event_id)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -745,8 +745,8 @@ ircd::m::v1::make_join::make_join(const room::id &room_id,
|
|||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||
{
|
||||
urlbuf, "/_matrix/federation/v1/make_join/%s/%s",
|
||||
url::encode(room_id, ridbuf),
|
||||
url::encode(user_id, uidbuf)
|
||||
url::encode(ridbuf, room_id),
|
||||
url::encode(uidbuf, user_id)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -794,7 +794,7 @@ ircd::m::v1::user::devices::devices(const id::user &user_id,
|
|||
json::get<"uri"_>(opts.request) = fmt::sprintf
|
||||
{
|
||||
urlbuf, "/_matrix/federation/v1/user/devices/%s",
|
||||
url::encode(user_id, uidbuf)
|
||||
url::encode(uidbuf, user_id)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -894,7 +894,7 @@ ircd::m::v1::query::user_devices::user_devices(const id::user &user_id,
|
|||
"user_devices",
|
||||
fmt::sprintf
|
||||
{
|
||||
query_arg_buf, "user_id=%s", url::encode(user_id, query_url_buf)
|
||||
query_arg_buf, "user_id=%s", url::encode(query_url_buf, user_id)
|
||||
},
|
||||
buf,
|
||||
std::move(opts)
|
||||
|
@ -919,7 +919,7 @@ ircd::m::v1::query::directory::directory(const id::room_alias &room_alias,
|
|||
"directory",
|
||||
fmt::sprintf
|
||||
{
|
||||
query_arg_buf, "room_alias=%s", url::encode(room_alias, query_url_buf)
|
||||
query_arg_buf, "room_alias=%s", url::encode(query_url_buf, room_alias)
|
||||
},
|
||||
buf,
|
||||
std::move(opts)
|
||||
|
@ -944,7 +944,7 @@ ircd::m::v1::query::profile::profile(const id::user &user_id,
|
|||
"profile",
|
||||
fmt::sprintf
|
||||
{
|
||||
query_arg_buf, "user_id=%s", url::encode(user_id, query_url_buf)
|
||||
query_arg_buf, "user_id=%s", url::encode(query_url_buf, user_id)
|
||||
},
|
||||
buf,
|
||||
std::move(opts)
|
||||
|
@ -972,7 +972,7 @@ ircd::m::v1::query::profile::profile(const id::user &user_id,
|
|||
fmt::sprintf
|
||||
{
|
||||
query_arg_buf, "user_id=%s%s%s",
|
||||
url::encode(string_view{user_id}, query_url_buf),
|
||||
url::encode(query_url_buf, string_view{user_id}),
|
||||
!empty(field)? "&field=" : "",
|
||||
field
|
||||
},
|
||||
|
|
150
ircd/rfc3986.cc
150
ircd/rfc3986.cc
|
@ -128,62 +128,6 @@ struct ircd::rfc3986::grammar
|
|||
{}
|
||||
};
|
||||
|
||||
struct ircd::rfc3986::parser
|
||||
:grammar<const char *>
|
||||
{
|
||||
string_view operator()(const string_view &url) const;
|
||||
}
|
||||
const ircd::rfc3986::parser;
|
||||
|
||||
ircd::string_view
|
||||
ircd::rfc3986::parser::operator()(const string_view &url)
|
||||
const try
|
||||
{
|
||||
string_view out;
|
||||
const char *start{url.data()};
|
||||
const char *const stop{url.data() + url.size()};
|
||||
//qi::parse(start, stop, , out);
|
||||
return out;
|
||||
}
|
||||
catch(const qi::expectation_failure<const char *> &e)
|
||||
{
|
||||
auto rule
|
||||
{
|
||||
ircd::string(e.what_)
|
||||
};
|
||||
|
||||
throw error
|
||||
{
|
||||
"Not a valid url because of an invalid %s.", between(rule, '<', '>')
|
||||
};
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::rfc3986::form_encode(const mutable_buffer &out,
|
||||
const json::members &members)
|
||||
{
|
||||
window_buffer buf{out};
|
||||
const auto append{[&buf](const json::member &member)
|
||||
{
|
||||
consume(buf, size(encode(member.first, buf)));
|
||||
consume(buf, copy(buf, "="_sv));
|
||||
consume(buf, size(encode(member.second, buf)));
|
||||
}};
|
||||
|
||||
auto it(begin(members));
|
||||
if(it != end(members))
|
||||
{
|
||||
append(*it);
|
||||
for(++it; it != end(members); ++it)
|
||||
{
|
||||
consume(buf, copy(buf, "&"_sv));
|
||||
append(*it);
|
||||
}
|
||||
}
|
||||
|
||||
return buf.completed();
|
||||
}
|
||||
|
||||
struct ircd::rfc3986::encoder
|
||||
:karma::grammar<char *, const string_view &>
|
||||
{
|
||||
|
@ -202,15 +146,6 @@ struct ircd::rfc3986::encoder
|
|||
}
|
||||
const ircd::rfc3986::encoder;
|
||||
|
||||
ircd::string_view
|
||||
ircd::rfc3986::encode(const string_view &url,
|
||||
const mutable_buffer &buf)
|
||||
{
|
||||
char *out{data(buf)};
|
||||
karma::generate(out, maxwidth(size(buf))[encoder], url);
|
||||
return string_view{data(buf), size_t(std::distance(data(buf), out))};
|
||||
}
|
||||
|
||||
struct ircd::rfc3986::decoder
|
||||
:qi::grammar<const char *, mutable_buffer>
|
||||
{
|
||||
|
@ -244,19 +179,94 @@ struct ircd::rfc3986::decoder
|
|||
}
|
||||
const ircd::rfc3986::decoder;
|
||||
|
||||
struct ircd::rfc3986::parser
|
||||
:grammar<const char *>
|
||||
{
|
||||
string_view operator()(const string_view &url) const;
|
||||
}
|
||||
const ircd::rfc3986::parser;
|
||||
|
||||
ircd::string_view
|
||||
ircd::rfc3986::decode(const string_view &url,
|
||||
const mutable_buffer &buf)
|
||||
ircd::rfc3986::parser::operator()(const string_view &url)
|
||||
const try
|
||||
{
|
||||
string_view out;
|
||||
const char *start{url.data()};
|
||||
const char *const stop{url.data() + url.size()};
|
||||
//qi::parse(start, stop, , out);
|
||||
return out;
|
||||
}
|
||||
catch(const qi::expectation_failure<const char *> &e)
|
||||
{
|
||||
auto rule
|
||||
{
|
||||
ircd::string(e.what_)
|
||||
};
|
||||
|
||||
throw error
|
||||
{
|
||||
"Not a valid url because of an invalid %s.", between(rule, '<', '>')
|
||||
};
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::rfc3986::encode(const mutable_buffer &out,
|
||||
const json::members &members)
|
||||
{
|
||||
window_buffer buf{out};
|
||||
const auto append{[&buf](const json::member &member)
|
||||
{
|
||||
consume(buf, size(encode(buf, member.first)));
|
||||
consume(buf, copy(buf, "="_sv));
|
||||
consume(buf, size(encode(buf, member.second)));
|
||||
}};
|
||||
|
||||
auto it(begin(members));
|
||||
if(it != end(members))
|
||||
{
|
||||
append(*it);
|
||||
for(++it; it != end(members); ++it)
|
||||
{
|
||||
consume(buf, copy(buf, "&"_sv));
|
||||
append(*it);
|
||||
}
|
||||
}
|
||||
|
||||
return buf.completed();
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::rfc3986::encode(const mutable_buffer &buf,
|
||||
const string_view &url)
|
||||
{
|
||||
char *out(data(buf));
|
||||
karma::generate(out, maxwidth(size(buf))[encoder], url);
|
||||
return string_view
|
||||
{
|
||||
data(buf), size_t(std::distance(data(buf), out))
|
||||
};
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::rfc3986::decode(const mutable_buffer &buf,
|
||||
const string_view &url)
|
||||
try
|
||||
{
|
||||
const char *start{url.data()}, *const stop
|
||||
const char *start(url.data()), *const stop
|
||||
{
|
||||
start + std::min(size(url), size(buf))
|
||||
};
|
||||
|
||||
mutable_buffer mb{data(buf), size_t(0)};
|
||||
mutable_buffer mb
|
||||
{
|
||||
data(buf), size_t(0)
|
||||
};
|
||||
|
||||
qi::parse(start, stop, eps > decoder, mb);
|
||||
return string_view{data(mb), size(mb)};
|
||||
return string_view
|
||||
{
|
||||
data(mb), size(mb)
|
||||
};
|
||||
}
|
||||
catch(const qi::expectation_failure<const char *> &e)
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ get__devices(client &client,
|
|||
|
||||
m::id::device::buf device_id
|
||||
{
|
||||
url::decode(request.parv[1], device_id)
|
||||
url::decode(device_id, request.parv[1])
|
||||
};
|
||||
|
||||
user_room.get("ircd.device", device_id, [&]
|
||||
|
@ -117,7 +117,7 @@ put__devices(client &client,
|
|||
|
||||
m::id::device::buf device_id
|
||||
{
|
||||
url::decode(request.parv[1], device_id)
|
||||
url::decode(device_id, request.parv[1])
|
||||
};
|
||||
|
||||
user_room.get("ircd.device", device_id, [&]
|
||||
|
@ -166,7 +166,7 @@ delete__devices(client &client,
|
|||
|
||||
m::id::device::buf device_id
|
||||
{
|
||||
url::decode(request.parv[1], device_id)
|
||||
url::decode(device_id, request.parv[1])
|
||||
};
|
||||
|
||||
if(!user_room.has("ircd.device", device_id))
|
||||
|
|
|
@ -46,7 +46,7 @@ get__directory_room(client &client,
|
|||
{
|
||||
m::room::alias::buf room_alias
|
||||
{
|
||||
url::decode(request.parv[0], room_alias)
|
||||
url::decode(room_alias, request.parv[0])
|
||||
};
|
||||
|
||||
char buf[256];
|
||||
|
@ -76,7 +76,7 @@ put__directory_room(client &client,
|
|||
{
|
||||
m::room::alias::buf room_alias
|
||||
{
|
||||
url::decode(request.parv[0], room_alias)
|
||||
url::decode(room_alias, request.parv[0])
|
||||
};
|
||||
|
||||
const m::room::id &room_id
|
||||
|
|
|
@ -37,7 +37,7 @@ get__events(client &client,
|
|||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.query["room_id"], room_id)
|
||||
url::decode(room_id, request.query["room_id"])
|
||||
};
|
||||
|
||||
const auto &from
|
||||
|
|
|
@ -49,7 +49,7 @@ post__join(client &client,
|
|||
char idbuf[256];
|
||||
const auto &id
|
||||
{
|
||||
url::decode(request.parv[0], idbuf)
|
||||
url::decode(idbuf, request.parv[0])
|
||||
};
|
||||
|
||||
switch(m::sigil(id))
|
||||
|
|
|
@ -64,7 +64,7 @@ get__presence(client &client,
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[0], user_id)
|
||||
url::decode(user_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(request.parv.size() < 2)
|
||||
|
@ -121,7 +121,7 @@ get__presence_list(client &client,
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[1], user_id)
|
||||
url::decode(user_id, request.parv[1])
|
||||
};
|
||||
|
||||
const m::user::room user_room
|
||||
|
@ -192,7 +192,7 @@ post__presence_list(client &client,
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[1], user_id)
|
||||
url::decode(user_id, request.parv[1])
|
||||
};
|
||||
|
||||
const m::user::room user_room
|
||||
|
@ -240,7 +240,7 @@ put__presence(client &client,
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[0], user_id)
|
||||
url::decode(user_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(user_id != request.user_id)
|
||||
|
|
|
@ -59,7 +59,7 @@ get__profile(client &client,
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[0], user_id)
|
||||
url::decode(user_id, request.parv[0])
|
||||
};
|
||||
|
||||
const m::user user
|
||||
|
@ -76,7 +76,7 @@ get__profile(client &client,
|
|||
char parambuf[128];
|
||||
const string_view ¶m
|
||||
{
|
||||
url::decode(request.parv[1], parambuf)
|
||||
url::decode(parambuf, request.parv[1])
|
||||
};
|
||||
|
||||
profile_get(user, param, [¶m, &client]
|
||||
|
@ -149,7 +149,7 @@ get__profile_remote(client &client,
|
|||
char parambuf[128];
|
||||
const string_view ¶m
|
||||
{
|
||||
url::decode(request.parv[1], parambuf)
|
||||
url::decode(parambuf, request.parv[1])
|
||||
};
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
|
@ -205,7 +205,7 @@ put__profile(client &client,
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[0], user_id)
|
||||
url::decode(user_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(user_id != request.user_id)
|
||||
|
@ -224,7 +224,7 @@ put__profile(client &client,
|
|||
char parambuf[128];
|
||||
const string_view ¶m
|
||||
{
|
||||
url::decode(request.parv[1], parambuf)
|
||||
url::decode(parambuf, request.parv[1])
|
||||
};
|
||||
|
||||
const string_view &value
|
||||
|
|
|
@ -58,7 +58,7 @@ get__context(client &client,
|
|||
{
|
||||
m::event::id::buf event_id
|
||||
{
|
||||
url::decode(request.parv[2], event_id)
|
||||
url::decode(event_id, request.parv[2])
|
||||
};
|
||||
|
||||
const auto limit{[&request]
|
||||
|
|
|
@ -70,7 +70,7 @@ get__messages(client &client,
|
|||
|
||||
const json::object &filter_json
|
||||
{
|
||||
url::decode(filter_query, filter_buf)
|
||||
url::decode(filter_buf, filter_query)
|
||||
};
|
||||
|
||||
const m::room_event_filter filter
|
||||
|
@ -190,14 +190,14 @@ try
|
|||
// obtained from a prev_batch token returned for each room by the sync
|
||||
// API, or from a start or end token returned by a previous request to
|
||||
// this endpoint.
|
||||
url::decode(request.query.at("from"), from)
|
||||
url::decode(from, request.query.at("from"))
|
||||
}
|
||||
{
|
||||
// The token to stop returning events at. This token can be obtained from
|
||||
// a prev_batch token returned for each room by the sync endpoint, or from
|
||||
// a start or end token returned by a previous request to this endpoint.
|
||||
if(!empty(request.query["to"]))
|
||||
url::decode(request.query.at("to"), to);
|
||||
url::decode(to, request.query.at("to"));
|
||||
|
||||
if(dir != 'b' && dir != 'f')
|
||||
throw m::BAD_PAGINATION
|
||||
|
|
|
@ -52,7 +52,7 @@ post__receipt(client &client,
|
|||
|
||||
m::event::id::buf event_id
|
||||
{
|
||||
url::decode(request.parv[3], event_id)
|
||||
url::decode(event_id, request.parv[3])
|
||||
};
|
||||
|
||||
const auto eid
|
||||
|
|
|
@ -32,7 +32,7 @@ put__redact(client &client,
|
|||
|
||||
event::id::buf redacts
|
||||
{
|
||||
url::decode(request.parv[2], redacts)
|
||||
url::decode(redacts, request.parv[2])
|
||||
};
|
||||
|
||||
if(request.parv.size() < 4)
|
||||
|
@ -83,7 +83,7 @@ post__redact(client &client,
|
|||
|
||||
event::id::buf redacts
|
||||
{
|
||||
url::decode(request.parv[2], redacts)
|
||||
url::decode(redacts, request.parv[2])
|
||||
};
|
||||
|
||||
const room room
|
||||
|
|
|
@ -41,7 +41,7 @@ get_rooms(client &client,
|
|||
|
||||
room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
const string_view &cmd
|
||||
|
@ -91,7 +91,7 @@ put_rooms(client &client,
|
|||
|
||||
room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
const string_view &cmd
|
||||
|
@ -138,7 +138,7 @@ post_rooms(client &client,
|
|||
|
||||
room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
const string_view &cmd
|
||||
|
|
|
@ -49,13 +49,13 @@ get__state(client &client,
|
|||
char type_buf[uint(256 * 1.34 + 1)];
|
||||
const string_view &type
|
||||
{
|
||||
url::decode(request.parv[2], type_buf)
|
||||
url::decode(type_buf, request.parv[2])
|
||||
};
|
||||
|
||||
char skey_buf[uint(256 * 1.34 + 1)];
|
||||
const string_view &state_key
|
||||
{
|
||||
url::decode(request.parv[3], skey_buf)
|
||||
url::decode(skey_buf, request.parv[3])
|
||||
};
|
||||
|
||||
// (non-standard) Allow an event_id to be passed in the query string
|
||||
|
@ -63,7 +63,7 @@ get__state(client &client,
|
|||
char evid_buf[uint(256 * 1.34 + 1)];
|
||||
const string_view &event_id
|
||||
{
|
||||
url::decode(request.query["event_id"], evid_buf)
|
||||
url::decode(evid_buf, request.query["event_id"])
|
||||
};
|
||||
|
||||
if(type && state_key)
|
||||
|
@ -83,13 +83,13 @@ put__state(client &client,
|
|||
char type_buf[uint(256 * 1.34 + 1)];
|
||||
const string_view &type
|
||||
{
|
||||
url::decode(request.parv[2], type_buf)
|
||||
url::decode(type_buf, request.parv[2])
|
||||
};
|
||||
|
||||
char skey_buf[uint(256 * 1.34 + 1)];
|
||||
const string_view &state_key
|
||||
{
|
||||
url::decode(request.parv[3], skey_buf)
|
||||
url::decode(skey_buf, request.parv[3])
|
||||
};
|
||||
|
||||
const json::object &content
|
||||
|
|
|
@ -32,7 +32,7 @@ put__typing(client &client,
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[2], user_id)
|
||||
url::decode(user_id, request.parv[2])
|
||||
};
|
||||
|
||||
if(request.user_id != user_id)
|
||||
|
|
|
@ -37,7 +37,7 @@ put__account_data(client &client,
|
|||
char typebuf[256];
|
||||
const string_view type
|
||||
{
|
||||
url::decode(request.parv[2], typebuf)
|
||||
url::decode(typebuf, request.parv[2])
|
||||
};
|
||||
|
||||
const json::object value
|
||||
|
@ -70,7 +70,7 @@ get__account_data(client &client,
|
|||
char typebuf[256];
|
||||
const string_view type
|
||||
{
|
||||
url::decode(request.parv[2], typebuf)
|
||||
url::decode(typebuf, request.parv[2])
|
||||
};
|
||||
|
||||
account_data_get(user, type, [&client]
|
||||
|
|
|
@ -20,7 +20,7 @@ get__filter(client &client,
|
|||
char filter_id_buf[64];
|
||||
const auto filter_id
|
||||
{
|
||||
url::decode(request.parv[2], filter_id_buf)
|
||||
url::decode(filter_id_buf, request.parv[2])
|
||||
};
|
||||
|
||||
const m::user user
|
||||
|
|
|
@ -50,7 +50,7 @@ put__rooms(client &client,
|
|||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[2], room_id)
|
||||
url::decode(room_id, request.parv[2])
|
||||
};
|
||||
|
||||
if(request.parv.size() < 4)
|
||||
|
@ -86,7 +86,7 @@ get__rooms(client &client,
|
|||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[2], room_id)
|
||||
url::decode(room_id, request.parv[2])
|
||||
};
|
||||
|
||||
if(request.parv.size() < 4)
|
||||
|
@ -124,7 +124,7 @@ put__account_data(client &client,
|
|||
char typebuf[256];
|
||||
const auto &type
|
||||
{
|
||||
url::decode(request.parv[4], typebuf)
|
||||
url::decode(typebuf, request.parv[4])
|
||||
};
|
||||
|
||||
const json::object &value
|
||||
|
@ -159,7 +159,7 @@ get__account_data(client &client,
|
|||
char typebuf[256];
|
||||
const auto &type
|
||||
{
|
||||
url::decode(request.parv[4], typebuf)
|
||||
url::decode(typebuf, request.parv[4])
|
||||
};
|
||||
|
||||
room_account_data_get(user, room, type, [&client]
|
||||
|
|
|
@ -39,7 +39,7 @@ get_user(client &client, const resource::request &request)
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[0], user_id)
|
||||
url::decode(user_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(request.user_id != user_id)
|
||||
|
@ -88,7 +88,7 @@ post_user(client &client, resource::request &request)
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[0], user_id)
|
||||
url::decode(user_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(request.user_id != user_id)
|
||||
|
@ -134,7 +134,7 @@ put_user(client &client, const resource::request &request)
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[0], user_id)
|
||||
url::decode(user_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(request.user_id != user_id)
|
||||
|
|
|
@ -69,13 +69,13 @@ get__backfill(client &client,
|
|||
{
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
m::event::id::buf event_id
|
||||
{
|
||||
request.query["v"]?
|
||||
url::decode(request.query.at("v"), event_id):
|
||||
url::decode(event_id, request.query.at("v")):
|
||||
m::head(room_id)
|
||||
};
|
||||
|
||||
|
|
|
@ -65,13 +65,13 @@ get__backfill_ids(client &client,
|
|||
{
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
m::event::id::buf event_id
|
||||
{
|
||||
request.query["v"]?
|
||||
url::decode(request.query.at("v"), event_id):
|
||||
url::decode(event_id, request.query.at("v")):
|
||||
m::head(room_id)
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ handle_get(client &client,
|
|||
{
|
||||
m::event::id::buf event_id
|
||||
{
|
||||
url::decode(request.parv[0], event_id)
|
||||
url::decode(event_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(!visible(event_id, request.node_id))
|
||||
|
|
|
@ -45,7 +45,7 @@ get__event_auth(client &client,
|
|||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(request.parv.size() < 2)
|
||||
|
@ -56,7 +56,7 @@ get__event_auth(client &client,
|
|||
|
||||
m::event::id::buf event_id
|
||||
{
|
||||
url::decode(request.parv[1], event_id)
|
||||
url::decode(event_id, request.parv[1])
|
||||
};
|
||||
|
||||
const m::event::fetch event
|
||||
|
|
|
@ -72,7 +72,7 @@ get__missing_events(client &client,
|
|||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
ssize_t limit
|
||||
|
|
|
@ -50,7 +50,7 @@ put__invite(client &client,
|
|||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(request.parv.size() < 2)
|
||||
|
@ -61,7 +61,7 @@ put__invite(client &client,
|
|||
|
||||
m::event::id::buf event_id
|
||||
{
|
||||
url::decode(request.parv[1], event_id)
|
||||
url::decode(event_id, request.parv[1])
|
||||
};
|
||||
|
||||
const m::event event
|
||||
|
|
|
@ -47,7 +47,7 @@ get__make_join(client &client,
|
|||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(request.parv.size() < 2)
|
||||
|
@ -58,7 +58,7 @@ get__make_join(client &client,
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[1], user_id)
|
||||
url::decode(user_id, request.parv[1])
|
||||
};
|
||||
|
||||
int64_t depth;
|
||||
|
|
|
@ -47,7 +47,7 @@ get__make_leave(client &client,
|
|||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(request.parv.size() < 2)
|
||||
|
@ -58,7 +58,7 @@ get__make_leave(client &client,
|
|||
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.parv[1], user_id)
|
||||
url::decode(user_id, request.parv[1])
|
||||
};
|
||||
|
||||
int64_t depth;
|
||||
|
|
|
@ -80,7 +80,7 @@ get__query_profile(client &client,
|
|||
{
|
||||
m::user::id::buf user_id
|
||||
{
|
||||
url::decode(request.query.at("user_id"), user_id)
|
||||
url::decode(user_id, request.query.at("user_id"))
|
||||
};
|
||||
|
||||
const string_view field
|
||||
|
@ -115,7 +115,7 @@ get__query_directory(client &client,
|
|||
{
|
||||
m::room::alias::buf room_alias
|
||||
{
|
||||
url::decode(request.query.at("room_alias"), room_alias)
|
||||
url::decode(room_alias, request.query.at("room_alias"))
|
||||
};
|
||||
|
||||
const auto room_id
|
||||
|
|
|
@ -47,7 +47,7 @@ put__send_join(client &client,
|
|||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(!my_host(room_id.host()))
|
||||
|
@ -66,7 +66,7 @@ put__send_join(client &client,
|
|||
|
||||
m::event::id::buf event_id
|
||||
{
|
||||
url::decode(request.parv[1], event_id)
|
||||
url::decode(event_id, request.parv[1])
|
||||
};
|
||||
|
||||
const m::event event
|
||||
|
|
|
@ -47,7 +47,7 @@ put__send_leave(client &client,
|
|||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(!my_host(room_id.host()))
|
||||
|
@ -66,7 +66,7 @@ put__send_leave(client &client,
|
|||
|
||||
m::event::id::buf event_id
|
||||
{
|
||||
url::decode(request.parv[1], event_id)
|
||||
url::decode(event_id, request.parv[1])
|
||||
};
|
||||
|
||||
const m::event event
|
||||
|
|
|
@ -39,12 +39,12 @@ get__state(client &client,
|
|||
{
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
m::event::id::buf event_id;
|
||||
if(request.query["event_id"])
|
||||
event_id = url::decode(request.query.at("event_id"), event_id);
|
||||
event_id = url::decode(event_id, request.query.at("event_id"));
|
||||
|
||||
const m::room room
|
||||
{
|
||||
|
|
|
@ -32,12 +32,12 @@ get__state_ids(client &client,
|
|||
{
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[0], room_id)
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
m::event::id::buf event_id;
|
||||
if(request.query["event_id"])
|
||||
event_id = url::decode(request.query.at("event_id"), event_id);
|
||||
event_id = url::decode(event_id, request.query.at("event_id"));
|
||||
|
||||
const m::room room
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ handle_get(client &client,
|
|||
char key_id_buf[256];
|
||||
const auto key_id
|
||||
{
|
||||
url::decode(request.parv[0], key_id_buf)
|
||||
url::decode(key_id_buf, request.parv[0])
|
||||
};
|
||||
|
||||
m::keys::get(my_host(), key_id, [&client]
|
||||
|
|
|
@ -87,7 +87,7 @@ request_url(const string_view &urle)
|
|||
|
||||
const auto url
|
||||
{
|
||||
url::decode(urle, buf)
|
||||
url::decode(buf, urle)
|
||||
};
|
||||
|
||||
const auto &host
|
||||
|
|
Loading…
Reference in a new issue