Compare commits
No commits in common. "278deff6da0a81a41c49301696a5c542ad76eb4f" and "d146ec3498faa735166587ed4b7f2662b3d3b51c" have entirely different histories.
278deff6da
...
d146ec3498
|
@ -235,7 +235,7 @@ CURL* MastodonClient::_get_easy() {
|
|||
}
|
||||
|
||||
try {
|
||||
setopt(curl, CURLOPT_TIMEOUT_MS, 30000L);
|
||||
setopt(curl, CURLOPT_TIMEOUT_MS, 10000L);
|
||||
#if CURL_AT_LEAST_VERSION(7, 85, 0)
|
||||
setopt(curl, CURLOPT_PROTOCOLS_STR, "https");
|
||||
#else
|
||||
|
|
|
@ -241,29 +241,20 @@ static inline void preprocess_link(const httplib::Request& req, const std::strin
|
|||
const lxb_char_t* cls_c = lxb_dom_element_class(element, &cls_c_len);
|
||||
std::string cls = cls_c ? std::string(reinterpret_cast<const char*>(cls_c), cls_c_len) : "";
|
||||
|
||||
try {
|
||||
CurlUrl href_url;
|
||||
href_url.set(CURLUPART_URL, get_origin(req));
|
||||
href_url.set(CURLUPART_PATH, std::string(href_url.get(CURLUPART_PATH).get()) + req.path);
|
||||
href_url.set(CURLUPART_URL, href);
|
||||
CurlUrl href_url;
|
||||
href_url.set(CURLUPART_URL, get_origin(req));
|
||||
href_url.set(CURLUPART_PATH, std::string(href_url.get(CURLUPART_PATH).get()) + req.path);
|
||||
href_url.set(CURLUPART_URL, href);
|
||||
CurlUrl instance_url_base;
|
||||
instance_url_base.set(CURLUPART_SCHEME, "https");
|
||||
instance_url_base.set(CURLUPART_HOST, domain_name);
|
||||
// .mention is used in note and posts
|
||||
// Instance base is used for link fields
|
||||
if (std::regex_search(cls, mention_class_re) || starts_with(href_url, instance_url_base)) {
|
||||
// Proxy this instance's URLs to Coyote
|
||||
href = proxy_mastodon_url(req, std::move(href));
|
||||
|
||||
CurlUrl instance_url_base;
|
||||
instance_url_base.set(CURLUPART_SCHEME, "https");
|
||||
instance_url_base.set(CURLUPART_HOST, domain_name);
|
||||
|
||||
// .mention is used in note and posts
|
||||
// Instance base is used for link fields
|
||||
if (std::regex_search(cls, mention_class_re) || starts_with(href_url, instance_url_base)) {
|
||||
// Proxy this instance's URLs to Coyote
|
||||
href = proxy_mastodon_url(req, std::move(href));
|
||||
|
||||
lxb_dom_element_set_attribute(element, reinterpret_cast<const lxb_char_t*>("href"), 4, reinterpret_cast<const lxb_char_t*>(href.data()), href.size());
|
||||
}
|
||||
} catch (const CurlUrlException& e) {
|
||||
// example: <a href=""></a> on eldritch.cafe/about
|
||||
if (e.code != CURLUE_MALFORMED_INPUT) {
|
||||
throw;
|
||||
}
|
||||
lxb_dom_element_set_attribute(element, reinterpret_cast<const lxb_char_t*>("href"), 4, reinterpret_cast<const lxb_char_t*>(href.data()), href.size());
|
||||
}
|
||||
|
||||
if (should_fix_link(element, cls)) {
|
||||
|
@ -283,7 +274,7 @@ static inline bool should_fix_link(lxb_dom_element_t* element, const std::string
|
|||
}
|
||||
|
||||
auto expected_element = [](lxb_dom_node_t* node, const char* expected_cls) {
|
||||
if (!node || node->type != LXB_DOM_NODE_TYPE_ELEMENT) {
|
||||
if (node->type != LXB_DOM_NODE_TYPE_ELEMENT) {
|
||||
return false;
|
||||
}
|
||||
lxb_dom_element_t* span = lxb_dom_interface_element(node);
|
||||
|
@ -481,8 +472,6 @@ static inline Element serialize_media(const Media& media) {
|
|||
}
|
||||
|
||||
static inline Element serialize_poll(const httplib::Request& req, const Poll& poll) {
|
||||
using namespace std::string_literals;
|
||||
|
||||
uint64_t voters_count = poll.voters_count >= 0 ? static_cast<uint64_t>(poll.voters_count) : poll.votes_count;
|
||||
Element div("div");
|
||||
|
||||
|
@ -507,13 +496,10 @@ static inline Element serialize_poll(const httplib::Request& req, const Poll& po
|
|||
: std::vector<Node>({std::to_string(poll.votes_count), " ", pick_form(poll.votes_count, "vote", "votes")})
|
||||
);
|
||||
if (poll.expired) {
|
||||
p.nodes.push_back(" / ");
|
||||
p.nodes.push_back(Element("time", {{"datetime", to_rfc3339(poll.expires_at)}, {"title", "Expired on "s + full_time(poll.expires_at)}}, {"Expired"}));
|
||||
p.nodes.push_back(" / Expired");
|
||||
} else if (poll.expires_at >= 0) {
|
||||
p.nodes.push_back(" / ");
|
||||
p.nodes.push_back(Element("time", {{"datetime", to_rfc3339(poll.expires_at)}, {"title", full_time(poll.expires_at)}}, {
|
||||
"Expires in ", relative_time(current_time(), poll.expires_at),
|
||||
}));
|
||||
p.nodes.push_back(" / Expires in ");
|
||||
p.nodes.push_back(relative_time(current_time(), poll.expires_at));
|
||||
}
|
||||
div.nodes.push_back(std::move(p));
|
||||
|
||||
|
|
Loading…
Reference in New Issue