formatting, clap fixes, remove cs json trans

# Conflicts:
#	src/group_handler/mod.rs
#	src/store/mod.rs
master^2
Ondřej Hruška 1 day ago
parent b4619f25e7
commit e52e692889
  1. 1025
      Cargo.lock
  2. 6
      Cargo.toml
  3. 2
      build.rs
  4. 3
      locales/cs.json
  5. 8
      src/error.rs
  6. 2
      src/group_handler/handle_mention.rs
  7. 18
      src/group_handler/mod.rs
  8. 4
      src/main.rs
  9. 31
      src/store/group_config.rs
  10. 30
      src/store/mod.rs
  11. 2
      src/utils.rs

1025
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -9,8 +9,8 @@ build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
#elefren = { path = "../elefren22-fork" }
elefren = { git = "https://git.ondrovo.com/MightyPork/elefren-fork.git", rev = "b10e5935ae32f4756b19e9ca58b78a5382f865d1" }
#elefren = { path = "../elefren-fork" }
elefren = { git = "https://git.ondrovo.com/MightyPork/elefren-fork.git", rev = "8aa32c060eddb825e46f777661a93ff6f745659d" }
env_logger = "0.11.8"
@ -18,7 +18,7 @@ log = "0.4.27"
serde = "1"
serde_json = "1"
anyhow = "1"
clap = "3"
clap = "3.2"
tokio = { version = "1", features = ["full"] }
thiserror = "2.0.12"
futures = "0.3"

@ -2,7 +2,7 @@ use std::process::Command;
use std::str;
fn main() {
let desc_c = Command::new("git").args(&["describe", "--all", "--long"]).output().unwrap();
let desc_c = Command::new("git").args(["describe", "--all", "--long"]).output().unwrap();
let desc = unsafe { str::from_utf8_unchecked(&desc_c.stdout) };

@ -1,3 +0,0 @@
{
"ping_response": "pong, toto je fedigroups verze {version}"
}

@ -23,7 +23,13 @@ pub enum GroupError {
#[error(transparent)]
Serializer5(#[from] json5::Error),
#[error(transparent)]
Elefren(#[from] elefren::Error),
Elefren(Box<elefren::Error>),
}
impl From<elefren::Error> for GroupError {
fn from(e: elefren::Error) -> Self {
Self::Elefren(Box::new(e))
}
}
// this is for tests

@ -843,7 +843,7 @@ fn smart_split(msg: &str, prefix: Option<String>, limit: usize) -> Vec<String> {
while this_piece.len() > limit {
// line too long, try splitting at the last space, if any
let to_send = if let Some(last_space) = (&this_piece[..=limit]).rfind(' ') {
let to_send = if let Some(last_space) = this_piece[..=limit].rfind(' ') {
// println!("line split at word boundary");
let mut p = this_piece.split_off(last_space + 1);
std::mem::swap(&mut p, &mut this_piece);

@ -34,19 +34,11 @@ pub struct GroupHandle {
pub internal: GroupInternal,
}
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct GroupInternal {
recently_seen_notif_statuses: VecDeque<String>,
}
impl Default for GroupInternal {
fn default() -> Self {
Self {
recently_seen_notif_statuses: VecDeque::new(),
}
}
}
#[macro_export]
macro_rules! grp_debug {
($self:ident, $f:expr) => {
@ -138,11 +130,11 @@ impl GroupHandle {
match self.run_internal().await {
Ok(()) => unreachable!(),
Err(e @ GroupError::BadConfig(_)) => {
grp_error!(self, "ERROR in group handler, aborting! {}", e);
grp_error!(self, "ERROR in group handler, aborting! {:?}", e);
return Err(e);
}
Err(other) => {
grp_error!(self, "ERROR in group handler, will restart! {}", other);
grp_error!(self, "ERROR in group handler, will restart! {:?}", other);
tokio::time::sleep(Duration::from_secs_f64(self.cc.delay_reopen_error_s)).await;
}
}
@ -175,7 +167,7 @@ impl GroupHandle {
grp_debug!(self, "No notifs missed");
}
Err(e) => {
grp_error!(self, "Failed to handle missed notifs: {}", e);
grp_error!(self, "Failed to handle missed notifs: {:?}", e);
}
}
}
@ -189,7 +181,7 @@ impl GroupHandle {
grp_debug!(self, "No statuses missed");
}
Err(e) => {
grp_error!(self, "Failed to handle missed statuses: {}", e);
grp_error!(self, "Failed to handle missed statuses: {:?}", e);
}
}
}

@ -32,13 +32,13 @@ async fn main() -> anyhow::Result<()> {
.arg(
Arg::with_name("verbose")
.short('v')
.multiple(true)
.multiple_occurrences(true)
.help("increase logging, can be repeated"),
)
.arg(
Arg::with_name("quiet")
.short('q')
.multiple(true)
.multiple_occurrences(true)
.help("decrease logging, can be repeated"),
)
.arg(

@ -25,7 +25,7 @@ struct FixedConfig {
_path: PathBuf,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, deny_unknown_fields)]
struct MutableConfig {
/// Hashtags the group will auto-boost from it's members
@ -48,7 +48,7 @@ struct MutableConfig {
_path: PathBuf,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default, deny_unknown_fields)]
struct StateConfig {
/// Last seen notification timestamp (millis)
@ -94,33 +94,6 @@ impl Default for FixedConfig {
}
}
impl Default for MutableConfig {
fn default() -> Self {
Self {
group_tags: Default::default(),
admin_users: Default::default(),
member_users: Default::default(),
banned_users: Default::default(),
optout_users: Default::default(),
member_only: false,
banned_servers: Default::default(),
_dirty: false,
_path: PathBuf::default(),
}
}
}
impl Default for StateConfig {
fn default() -> Self {
Self {
last_notif_ts: 0,
last_status_ts: 0,
_dirty: false,
_path: PathBuf::default(),
}
}
}
macro_rules! impl_change_tracking {
($struc:ident) => {
impl $struc {

@ -149,7 +149,7 @@ impl ConfigStore {
/// Re-auth an existing group
pub async fn reauth_group(&self, acct: &str) -> Result<(), GroupError> {
let group_dir = self.groups_path.join(&acct);
let group_dir = self.groups_path.join(acct);
let mut config = GroupConfig::from_dir(group_dir, &self.config).await?;
@ -203,21 +203,19 @@ impl ConfigStore {
}
};
for e in entries {
if let Ok(e) = e {
let path = e.path();
if path.is_file() && path.extension().unwrap_or_default().to_string_lossy() == "json" {
let filename = path.file_name().unwrap_or_default().to_string_lossy();
debug!("Loading locale {}", filename);
match tokio::fs::read(&path).await {
Ok(f) => {
let locale_name = path.file_stem().unwrap_or_default().to_string_lossy();
self.load_locale(&locale_name, &String::from_utf8_lossy(&f), false);
}
Err(e) => {
error!("Failed to read locale file {}: {}", path.display(), e);
}
for e in entries.flatten() {
let path = e.path();
if path.is_file() && path.extension().unwrap_or_default().to_string_lossy() == "json" {
let filename = path.file_name().unwrap_or_default().to_string_lossy();
debug!("Loading locale {}", filename);
match tokio::fs::read(&path).await {
Ok(f) => {
let locale_name = path.file_stem().unwrap_or_default().to_string_lossy();
self.load_locale(&locale_name, &String::from_utf8_lossy(&f), false);
}
Err(e) => {
error!("Failed to read locale file {}: {}", path.display(), e);
}
}
}

@ -95,6 +95,8 @@ mod test {
pub trait VisExt: Copy {
/// Check if is private or direct
fn is_private(self) -> bool;
#[allow(unused)]
fn make_unlisted(self) -> Self;
}

Loading…
Cancel
Save