mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
Deploying to gh-pages from @ 6b8ee754dd836dae3da3e3b5ead926f4854da629 🚀
This commit is contained in:
@@ -1342,6 +1342,66 @@
|
||||
<a href="#1342" id="1342">1342</a>
|
||||
<a href="#1343" id="1343">1343</a>
|
||||
<a href="#1344" id="1344">1344</a>
|
||||
<a href="#1345" id="1345">1345</a>
|
||||
<a href="#1346" id="1346">1346</a>
|
||||
<a href="#1347" id="1347">1347</a>
|
||||
<a href="#1348" id="1348">1348</a>
|
||||
<a href="#1349" id="1349">1349</a>
|
||||
<a href="#1350" id="1350">1350</a>
|
||||
<a href="#1351" id="1351">1351</a>
|
||||
<a href="#1352" id="1352">1352</a>
|
||||
<a href="#1353" id="1353">1353</a>
|
||||
<a href="#1354" id="1354">1354</a>
|
||||
<a href="#1355" id="1355">1355</a>
|
||||
<a href="#1356" id="1356">1356</a>
|
||||
<a href="#1357" id="1357">1357</a>
|
||||
<a href="#1358" id="1358">1358</a>
|
||||
<a href="#1359" id="1359">1359</a>
|
||||
<a href="#1360" id="1360">1360</a>
|
||||
<a href="#1361" id="1361">1361</a>
|
||||
<a href="#1362" id="1362">1362</a>
|
||||
<a href="#1363" id="1363">1363</a>
|
||||
<a href="#1364" id="1364">1364</a>
|
||||
<a href="#1365" id="1365">1365</a>
|
||||
<a href="#1366" id="1366">1366</a>
|
||||
<a href="#1367" id="1367">1367</a>
|
||||
<a href="#1368" id="1368">1368</a>
|
||||
<a href="#1369" id="1369">1369</a>
|
||||
<a href="#1370" id="1370">1370</a>
|
||||
<a href="#1371" id="1371">1371</a>
|
||||
<a href="#1372" id="1372">1372</a>
|
||||
<a href="#1373" id="1373">1373</a>
|
||||
<a href="#1374" id="1374">1374</a>
|
||||
<a href="#1375" id="1375">1375</a>
|
||||
<a href="#1376" id="1376">1376</a>
|
||||
<a href="#1377" id="1377">1377</a>
|
||||
<a href="#1378" id="1378">1378</a>
|
||||
<a href="#1379" id="1379">1379</a>
|
||||
<a href="#1380" id="1380">1380</a>
|
||||
<a href="#1381" id="1381">1381</a>
|
||||
<a href="#1382" id="1382">1382</a>
|
||||
<a href="#1383" id="1383">1383</a>
|
||||
<a href="#1384" id="1384">1384</a>
|
||||
<a href="#1385" id="1385">1385</a>
|
||||
<a href="#1386" id="1386">1386</a>
|
||||
<a href="#1387" id="1387">1387</a>
|
||||
<a href="#1388" id="1388">1388</a>
|
||||
<a href="#1389" id="1389">1389</a>
|
||||
<a href="#1390" id="1390">1390</a>
|
||||
<a href="#1391" id="1391">1391</a>
|
||||
<a href="#1392" id="1392">1392</a>
|
||||
<a href="#1393" id="1393">1393</a>
|
||||
<a href="#1394" id="1394">1394</a>
|
||||
<a href="#1395" id="1395">1395</a>
|
||||
<a href="#1396" id="1396">1396</a>
|
||||
<a href="#1397" id="1397">1397</a>
|
||||
<a href="#1398" id="1398">1398</a>
|
||||
<a href="#1399" id="1399">1399</a>
|
||||
<a href="#1400" id="1400">1400</a>
|
||||
<a href="#1401" id="1401">1401</a>
|
||||
<a href="#1402" id="1402">1402</a>
|
||||
<a href="#1403" id="1403">1403</a>
|
||||
<a href="#1404" id="1404">1404</a>
|
||||
</pre></div><pre class="rust"><code><span class="comment">// Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
@@ -2617,6 +2677,66 @@
|
||||
<span class="prelude-val">Err</span>(e) => <span class="prelude-val">Err</span>(map_row_not_found_err(e, DBError::CaptchaNotFound)),
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Get all easy captcha configurations on instance
|
||||
</span><span class="kw">async fn </span>get_all_easy_captchas(
|
||||
<span class="kw-2">&</span><span class="self">self</span>,
|
||||
limit: usize,
|
||||
offset: usize,
|
||||
) -> DBResult<Vec<EasyCaptcha>> {
|
||||
<span class="kw">struct </span>InnerEasyCaptcha {
|
||||
captcha_key: String,
|
||||
name: String,
|
||||
username: String,
|
||||
peak_sustainable_traffic: i32,
|
||||
avg_traffic: i32,
|
||||
broke_my_site_traffic: <span class="prelude-ty">Option</span><i32>,
|
||||
}
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>inner_res = <span class="macro">sqlx::query_as!</span>(
|
||||
InnerEasyCaptcha,
|
||||
<span class="string">"SELECT
|
||||
mcaptcha_sitekey_user_provided_avg_traffic.avg_traffic,
|
||||
mcaptcha_sitekey_user_provided_avg_traffic.peak_sustainable_traffic,
|
||||
mcaptcha_sitekey_user_provided_avg_traffic.broke_my_site_traffic,
|
||||
mcaptcha_config.name,
|
||||
mcaptcha_users.name as username,
|
||||
mcaptcha_config.captcha_key
|
||||
FROM
|
||||
mcaptcha_sitekey_user_provided_avg_traffic
|
||||
INNER JOIN
|
||||
mcaptcha_config
|
||||
ON
|
||||
mcaptcha_config.config_id = mcaptcha_sitekey_user_provided_avg_traffic.config_id
|
||||
INNER JOIN
|
||||
mcaptcha_users
|
||||
ON
|
||||
mcaptcha_config.user_id = mcaptcha_users.ID
|
||||
ORDER BY mcaptcha_config.config_id
|
||||
LIMIT ? OFFSET ?"</span>,
|
||||
limit <span class="kw">as </span>i64,
|
||||
offset <span class="kw">as </span>i64
|
||||
)
|
||||
.fetch_all(<span class="kw-2">&</span><span class="self">self</span>.pool)
|
||||
.<span class="kw">await
|
||||
</span>.map_err(|e| map_row_not_found_err(e, DBError::TrafficPatternNotFound))<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>res = Vec::with_capacity(inner_res.len());
|
||||
inner_res.drain(<span class="number">0</span>..).for_each(|v| {
|
||||
res.push(EasyCaptcha {
|
||||
key: v.captcha_key,
|
||||
description: v.name,
|
||||
username: v.username,
|
||||
traffic_pattern: TrafficPattern {
|
||||
broke_my_site_traffic: v
|
||||
.broke_my_site_traffic
|
||||
.as_ref()
|
||||
.map(|v| <span class="kw-2">*</span>v <span class="kw">as </span>u32),
|
||||
avg_traffic: v.avg_traffic <span class="kw">as </span>u32,
|
||||
peak_sustainable_traffic: v.peak_sustainable_traffic <span class="kw">as </span>u32,
|
||||
},
|
||||
})
|
||||
});
|
||||
<span class="prelude-val">Ok</span>(res)
|
||||
}
|
||||
}
|
||||
|
||||
<span class="attr">#[derive(Clone)]
|
||||
|
||||
Reference in New Issue
Block a user