add: check ip ban endpoint
This commit is contained in:
parent
8786cb4781
commit
e78c43ab62
8 changed files with 68 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "tetratto-core"
|
||||
description = "The core behind Tetratto"
|
||||
version = "12.0.0"
|
||||
version = "12.0.1"
|
||||
edition = "2024"
|
||||
authors.workspace = true
|
||||
repository.workspace = true
|
||||
|
|
|
@ -408,6 +408,10 @@ impl DataManager {
|
|||
|
||||
// check muted phrases
|
||||
for phrase in receiver.settings.muted {
|
||||
if phrase.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if data.content.contains(&phrase) {
|
||||
// act like the question was created so theyre less likely to try and send it again or bypass
|
||||
return Ok(0);
|
||||
|
|
|
@ -75,6 +75,22 @@ impl DataClient {
|
|||
}
|
||||
}
|
||||
|
||||
/// Check if the given IP is IP banned from the Tetratto host. You will only know
|
||||
/// if the IP is banned or not, meaning you will not be shown the reason if it
|
||||
/// is banned.
|
||||
pub async fn check_ip(&self, ip: &str) -> Result<bool> {
|
||||
match self
|
||||
.http
|
||||
.get(format!("{}/api/v1/bans/{}", self.host, ip))
|
||||
.header("Atto-Secret-Key", &self.api_key)
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
Ok(x) => api_return_ok!(bool, x),
|
||||
Err(e) => Err(Error::MiscError(e.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
/// Query the app's data.
|
||||
pub async fn query(&self, query: &SimplifiedQuery) -> Result<AppDataQueryResult> {
|
||||
match self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue