cleanup: removed old and unused functions and variables
This commit is contained in:
parent
68e7e1432f
commit
c15188ec9d
|
@ -124,7 +124,7 @@ impl HedgeDoc {
|
||||||
|
|
||||||
pub fn create_pad(&self) -> Result<String, Box<dyn Error>> {
|
pub fn create_pad(&self) -> Result<String, Box<dyn Error>> {
|
||||||
if self.is_dry_run {
|
if self.is_dry_run {
|
||||||
todo!("NYI: sane dry-run behavior")
|
todo!("nyi: sane dry-run behavior")
|
||||||
}
|
}
|
||||||
let res = self.do_request(&format!("{}/new", self.server_url)).unwrap();
|
let res = self.do_request(&format!("{}/new", self.server_url)).unwrap();
|
||||||
if res.status().is_success() {
|
if res.status().is_success() {
|
||||||
|
@ -136,7 +136,7 @@ impl HedgeDoc {
|
||||||
|
|
||||||
pub fn import_note(&self, id: Option<&str>, content: String) -> Result<String, Box<dyn Error>> {
|
pub fn import_note(&self, id: Option<&str>, content: String) -> Result<String, Box<dyn Error>> {
|
||||||
if self.is_dry_run {
|
if self.is_dry_run {
|
||||||
todo!("NYI: sane dry-run behavior")
|
todo!("nyi: sane dry-run behavior")
|
||||||
}
|
}
|
||||||
let url = match id {
|
let url = match id {
|
||||||
Some(id) => self.format_url(&format!("new/{id}")),
|
Some(id) => self.format_url(&format!("new/{id}")),
|
||||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -125,24 +125,24 @@ macro_rules! trace_var_ {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Similar to [`todo!`], but non-fatal; `NYI` prints a message to stderr _only once_
|
/// Similar to [`todo!`], but non-fatal; `nyi` prints a message to stderr _only once_
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! NYI {
|
macro_rules! nyi {
|
||||||
($msg:expr) => {{
|
($msg:expr) => {{
|
||||||
// rely on the non-snake-case warning to get a warning at use sites
|
// rely on the non-snake-case warning to get a warning at use sites
|
||||||
fn NYI() {}
|
fn nyi() {}
|
||||||
NYI();
|
nyi();
|
||||||
static ONCE: std::sync::Once = std::sync::Once::new();
|
static ONCE: std::sync::Once = std::sync::Once::new();
|
||||||
let location = stdext::debug_name!();
|
let location = stdext::debug_name!();
|
||||||
ONCE.call_once(|| {
|
ONCE.call_once(|| {
|
||||||
eprintln!("{}: NYI -- {}", location, $msg);
|
eprintln!("{}: nyi -- {}", location, $msg);
|
||||||
});
|
});
|
||||||
}};
|
}};
|
||||||
() => {{
|
() => {{
|
||||||
static ONCE: std::sync::Once = std::sync::Once::new();
|
static ONCE: std::sync::Once = std::sync::Once::new();
|
||||||
let location = stdext::debug_name!();
|
let location = stdext::debug_name!();
|
||||||
ONCE.call_once(|| {
|
ONCE.call_once(|| {
|
||||||
eprintln!("{}: NYI!", location);
|
eprintln!("{}: nyi!", location);
|
||||||
});
|
});
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
113
src/main.rs
113
src/main.rs
|
@ -13,12 +13,11 @@ use cccron_lib::is_dry_run;
|
||||||
use cccron_lib::key_value::{KeyValueStore as KV, KeyValueStore};
|
use cccron_lib::key_value::{KeyValueStore as KV, KeyValueStore};
|
||||||
use cccron_lib::matrix::{self, MatrixClient};
|
use cccron_lib::matrix::{self, MatrixClient};
|
||||||
use cccron_lib::mediawiki::{self, Mediawiki};
|
use cccron_lib::mediawiki::{self, Mediawiki};
|
||||||
use cccron_lib::NYI;
|
use cccron_lib::nyi;
|
||||||
use cccron_lib::{trace_var, trace_var_, verboseln};
|
use cccron_lib::{trace_var, trace_var_, verboseln};
|
||||||
use chrono::{DateTime, Local, NaiveDate, Utc};
|
use chrono::{Local, NaiveDate};
|
||||||
use clap::{Arg, Command};
|
use clap::{Arg, Command};
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use regex::Regex;
|
|
||||||
|
|
||||||
/* ***** Config Spec ***** */
|
/* ***** Config Spec ***** */
|
||||||
const CONFIG_SPEC: CfgSpec<'static> = CfgSpec {
|
const CONFIG_SPEC: CfgSpec<'static> = CfgSpec {
|
||||||
|
@ -264,52 +263,6 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_new_pad_for_following_date(
|
|
||||||
config: KV, hedgedoc: HedgeDoc, übernächster_plenumtermin: &str,
|
|
||||||
überübernächster_plenumtermin: &str, kv: &KV,
|
|
||||||
) -> Result<(), Box<dyn Error>> {
|
|
||||||
match hedgedoc.create_pad() {
|
|
||||||
Err(e) => println!("Failed to create pad: {}", e),
|
|
||||||
Ok(pad_id) => {
|
|
||||||
println!("Pad created successfully with ID: {}", pad_id);
|
|
||||||
|
|
||||||
// Get the most recent plenum template and replace the placeholders:
|
|
||||||
let template_content: String = match config.get("hedgedoc-template-name") {
|
|
||||||
Ok(content) => hedgedoc
|
|
||||||
.download(&content.clone())
|
|
||||||
.unwrap_or_else(|_| config.get("text-fallback-template").unwrap_or_default()),
|
|
||||||
Err(_) => config.get("text-fallback-template").unwrap_or_default(),
|
|
||||||
};
|
|
||||||
// XXX you don't just use the template as-is…
|
|
||||||
let template_modified: String = replace_placeholders(
|
|
||||||
&template_content,
|
|
||||||
übernächster_plenumtermin,
|
|
||||||
überübernächster_plenumtermin,
|
|
||||||
)
|
|
||||||
.unwrap_or(template_content); // Try regex, if not successful use without regex
|
|
||||||
|
|
||||||
match hedgedoc.import_note(Some(&pad_id), template_modified) {
|
|
||||||
Ok(_) => {
|
|
||||||
println!("Pad updated successfully with template content.");
|
|
||||||
rotate(&pad_id, kv);
|
|
||||||
},
|
|
||||||
Err(e) => println!("Failed to update pad: {}", e),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn replace_placeholders(
|
|
||||||
template: &str, übernächster_plenumtermin: &str, überübernächster_plenumtermin: &str,
|
|
||||||
) -> Result<String, Box<dyn Error>> {
|
|
||||||
let re_datum = Regex::new(r"\{\{Datum\}\}")?;
|
|
||||||
let result = re_datum.replace_all(template, übernächster_plenumtermin);
|
|
||||||
let re_naechstes_plenum = Regex::new(r"\{\{naechstes-plenum\}\}")?;
|
|
||||||
let result = re_naechstes_plenum.replace_all(&result, überübernächster_plenumtermin);
|
|
||||||
Ok(result.to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rotate(future_pad_id: &str, kv: &KV) {
|
fn rotate(future_pad_id: &str, kv: &KV) {
|
||||||
let next_plenum_pad = kv.get("zukünftiges-plenumspad").ok();
|
let next_plenum_pad = kv.get("zukünftiges-plenumspad").ok();
|
||||||
if let Some(next_plenum_pad) = next_plenum_pad {
|
if let Some(next_plenum_pad) = next_plenum_pad {
|
||||||
|
@ -381,7 +334,7 @@ fn do_announcement(
|
||||||
ttp: i64, plenum_day: &NaiveDate, config: &KV, hedgedoc: &HedgeDoc, email: &SimpleEmail,
|
ttp: i64, plenum_day: &NaiveDate, config: &KV, hedgedoc: &HedgeDoc, email: &SimpleEmail,
|
||||||
_wiki: &Mediawiki,
|
_wiki: &Mediawiki,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
NYI!("trace/verbose annotations");
|
nyi!("trace/verbose annotations");
|
||||||
// fetch current pad contents & summarize
|
// fetch current pad contents & summarize
|
||||||
let (current_pad_id, _pad_content, toc, n_topics) = get_pad_info(config, hedgedoc);
|
let (current_pad_id, _pad_content, toc, n_topics) = get_pad_info(config, hedgedoc);
|
||||||
// construct email
|
// construct email
|
||||||
|
@ -400,7 +353,7 @@ fn do_announcement(
|
||||||
"Falls ihr noch Themen ergänzen wollt ist hier der Link zum Pad:\n {}",
|
"Falls ihr noch Themen ergänzen wollt ist hier der Link zum Pad:\n {}",
|
||||||
hedgedoc.format_url(¤t_pad_id)
|
hedgedoc.format_url(¤t_pad_id)
|
||||||
);
|
);
|
||||||
let mut body = format!("{line1}\n\n{line2}");
|
let body = format!("{line1}\n\n{line2}");
|
||||||
// send it
|
// send it
|
||||||
let message_id = send_email(&subject, &body, email, config)?;
|
let message_id = send_email(&subject, &body, email, config)?;
|
||||||
// on success, update state (ignore write errors, they'll be checked later)
|
// on success, update state (ignore write errors, they'll be checked later)
|
||||||
|
@ -424,7 +377,7 @@ fn do_reminder(
|
||||||
ttp: i64, plenum_day: &NaiveDate, config: &KV, hedgedoc: &HedgeDoc, email: &SimpleEmail,
|
ttp: i64, plenum_day: &NaiveDate, config: &KV, hedgedoc: &HedgeDoc, email: &SimpleEmail,
|
||||||
_wiki: &Mediawiki,
|
_wiki: &Mediawiki,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
NYI!("trace/verbose annotations");
|
nyi!("trace/verbose annotations");
|
||||||
// fetch current pad contents & summarize
|
// fetch current pad contents & summarize
|
||||||
let (current_pad_id, _pad_content, toc, n_topics) = get_pad_info(config, hedgedoc);
|
let (current_pad_id, _pad_content, toc, n_topics) = get_pad_info(config, hedgedoc);
|
||||||
let old_toc = config.get("email-state-toc")?;
|
let old_toc = config.get("email-state-toc")?;
|
||||||
|
@ -446,14 +399,14 @@ fn do_reminder(
|
||||||
} else {
|
} else {
|
||||||
format!("Es gab nochmal Änderungen, die aktualisierten Themen für das Plenum sind:\n\n{toc}\n\n")
|
format!("Es gab nochmal Änderungen, die aktualisierten Themen für das Plenum sind:\n\n{toc}\n\n")
|
||||||
};
|
};
|
||||||
let mut body = if n_topics > 0 {
|
let body = if n_topics > 0 {
|
||||||
format!(
|
format!(
|
||||||
"{body_prefix}Die vollen Details findet ihr im Pad:\n {}\n\nBis {} um 20:00!",
|
"{body_prefix}Die vollen Details findet ihr im Pad:\n {}\n\nBis {} um 20:00!",
|
||||||
hedgedoc.format_url(¤t_pad_id),
|
hedgedoc.format_url(¤t_pad_id),
|
||||||
relative_date(ttp)
|
relative_date(ttp)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
NYI!("generate link / pad for next plenum & include in this email");
|
nyi!("generate link / pad for next plenum & include in this email");
|
||||||
"Da es immer noch keine Themen gibt fällt das Plenum aus.\n\n\
|
"Da es immer noch keine Themen gibt fällt das Plenum aus.\n\n\
|
||||||
(Natürlich könnt ihr im Bedarfsfall immer noch kurzfristig ein Treffen einberufen, aber \
|
(Natürlich könnt ihr im Bedarfsfall immer noch kurzfristig ein Treffen einberufen, aber \
|
||||||
bitte kündigt das so früh wie möglich an, damit insbesondere auch Leute mit längeren \
|
bitte kündigt das so früh wie möglich an, damit insbesondere auch Leute mit längeren \
|
||||||
|
@ -464,7 +417,7 @@ fn do_reminder(
|
||||||
let _message_id = send_email(&subject, &body, email, config)?;
|
let _message_id = send_email(&subject, &body, email, config)?;
|
||||||
// on success, update state (ignore write errors, they'll be checked later)
|
// on success, update state (ignore write errors, they'll be checked later)
|
||||||
if n_topics == 0 {
|
if n_topics == 0 {
|
||||||
NYI!(
|
nyi!(
|
||||||
"do we skip ahead to ProgramState::Logged here or do we later add a note to the wiki?"
|
"do we skip ahead to ProgramState::Logged here or do we later add a note to the wiki?"
|
||||||
);
|
);
|
||||||
// TODO: ADD SOMETHING TO WIKI
|
// TODO: ADD SOMETHING TO WIKI
|
||||||
|
@ -485,13 +438,12 @@ fn do_reminder(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
|
||||||
fn do_protocol(
|
fn do_protocol(
|
||||||
ttp: i64, plenum_day: &NaiveDate, config: &KV, hedgedoc: &HedgeDoc, email: &SimpleEmail,
|
ttp: i64, plenum_day: &NaiveDate, config: &KV, hedgedoc: &HedgeDoc, email: &SimpleEmail,
|
||||||
wiki: &Mediawiki,
|
wiki: &Mediawiki,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
NYI!("trace/verbose annotations");
|
nyi!("trace/verbose annotations");
|
||||||
let (current_pad_id, pad_content_without_cleanup, toc, n_topics) =
|
let (_current_pad_id, pad_content_without_cleanup, toc, n_topics) =
|
||||||
get_pad_info(config, hedgedoc);
|
get_pad_info(config, hedgedoc);
|
||||||
let pad_content = hedgedoc::strip_metadata(pad_content_without_cleanup.clone());
|
let pad_content = hedgedoc::strip_metadata(pad_content_without_cleanup.clone());
|
||||||
let ollama_enabled: bool = match &config["hedgedoc-ollama-summaries-enabled"] {
|
let ollama_enabled: bool = match &config["hedgedoc-ollama-summaries-enabled"] {
|
||||||
|
@ -521,8 +473,9 @@ fn do_protocol(
|
||||||
let subject = format!("Protokoll vom Plenum am {human_date}");
|
let subject = format!("Protokoll vom Plenum am {human_date}");
|
||||||
let pad_content = pad_content.replace("[toc]", &toc);
|
let pad_content = pad_content.replace("[toc]", &toc);
|
||||||
let body = format!(
|
let body = format!(
|
||||||
"Anbei das Protokoll vom {human_date}, ab sofort auch im Wiki zu finden.\n\n\
|
"Anbei das Protokoll von {} ({human_date}), ab sofort auch im Wiki zu finden. Heute gab es {n_topics} TOPs.\n\n\
|
||||||
Das Pad für das nächste Plenum ist zu finden unter <{}/{}>.\n\nDie Protokolle der letzten Plena findet ihr im wiki unter <{}/index.php?title={}>.\n\n---Protokoll:---\n{}\n-----",
|
Das Pad für das nächste Plenum ist zu finden unter <{}/{}>.\n\nDie Protokolle der letzten Plena findet ihr im wiki unter <{}/index.php?title={}>.\n\n---Protokoll:---\n{}\n-----",
|
||||||
|
relative_date(ttp),
|
||||||
&config["hedgedoc-server-url"],
|
&config["hedgedoc-server-url"],
|
||||||
&config["hedgedoc-next-id"],
|
&config["hedgedoc-next-id"],
|
||||||
&config["wiki-server-url"],
|
&config["wiki-server-url"],
|
||||||
|
@ -538,8 +491,9 @@ fn do_protocol(
|
||||||
let subject = format!("Protokoll vom ausgefallenem Plenum am {human_date}");
|
let subject = format!("Protokoll vom ausgefallenem Plenum am {human_date}");
|
||||||
let pad_content = pad_content.replace("[toc]", &toc);
|
let pad_content = pad_content.replace("[toc]", &toc);
|
||||||
let body = format!(
|
let body = format!(
|
||||||
"Anbei das Protokoll vom {human_date}, ab sofort auch im Wiki zu finden.\n\n\
|
"Anbei das Protokoll von {} ({human_date}), ab sofort auch im Wiki zu finden. Heute gab es {n_topics} TOPs.\n\n\
|
||||||
Das Pad für das nächste Plenum ist zu finden unter {}/{}.\n\nDie Protokolle der letzten Plena findet ihr im wiki unter {}/index.php?title={}.\n\n---Protokoll:---{}",
|
Das Pad für das nächste Plenum ist zu finden unter {}/{}.\n\nDie Protokolle der letzten Plena findet ihr im wiki unter {}/index.php?title={}.\n\n---Protokoll:---{}",
|
||||||
|
relative_date(ttp),
|
||||||
&config["hedgedoc-server-url"],
|
&config["hedgedoc-server-url"],
|
||||||
&config["hedgedoc-next-id"],
|
&config["hedgedoc-next-id"],
|
||||||
&config["wiki-server-url"],
|
&config["wiki-server-url"],
|
||||||
|
@ -560,10 +514,10 @@ fn do_protocol(
|
||||||
);
|
);
|
||||||
// Send the matrix room message
|
// Send the matrix room message
|
||||||
let human_date = plenum_day.format("%d.%m.%Y");
|
let human_date = plenum_day.format("%d.%m.%Y");
|
||||||
let pad_content = pad_content.replace("[toc]", &toc);
|
|
||||||
let message = format!(
|
let message = format!(
|
||||||
"Anbei das Protokoll vom {human_date}, ab sofort auch im Wiki zu finden.\n\n\
|
"Anbei das Protokoll von {} ({human_date}), ab sofort auch im Wiki zu finden. Heute gab es {n_topics} TOPs.\n\n\
|
||||||
Das Pad für das nächste Plenum ist zu finden unter {}/{}.\n\nDie Protokolle der letzten Plena findet ihr im wiki unter {}/index.php?title={}.\n\n**Hier die Zusammenfassung:**\n\n{}",
|
Das Pad für das nächste Plenum ist zu finden unter {}/{}.\n\nDie Protokolle der letzten Plena findet ihr im wiki unter {}/index.php?title={}.\n\n**Hier die Zusammenfassung:**\n\n{}",
|
||||||
|
relative_date(ttp),
|
||||||
&config["hedgedoc-server-url"],
|
&config["hedgedoc-server-url"],
|
||||||
&config["hedgedoc-next-id"],
|
&config["hedgedoc-next-id"],
|
||||||
&config["wiki-server-url"],
|
&config["wiki-server-url"],
|
||||||
|
@ -577,17 +531,16 @@ fn do_protocol(
|
||||||
|
|
||||||
/// General cleanup function. Call as `(999, today, …)` for a complete reset
|
/// General cleanup function. Call as `(999, today, …)` for a complete reset
|
||||||
/// based on today as the base date.
|
/// based on today as the base date.
|
||||||
#[allow(unused_must_use)]
|
|
||||||
fn do_cleanup(
|
fn do_cleanup(
|
||||||
_ttp: i64, _plenum_day: &NaiveDate, config: &KV, _hedgedoc: &HedgeDoc, _email: &SimpleEmail,
|
_ttp: i64, _plenum_day: &NaiveDate, config: &KV, _hedgedoc: &HedgeDoc, _email: &SimpleEmail,
|
||||||
_wiki: &Mediawiki,
|
_wiki: &Mediawiki,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
NYI!("trace/verbose annotations");
|
nyi!("trace/verbose annotations");
|
||||||
config.delete("email-state-toc");
|
_ = config.delete("email-state-toc");
|
||||||
config.delete("email-last-message-id");
|
_ = config.delete("email-last-message-id");
|
||||||
NYI!("rotate pad links");
|
nyi!("rotate pad links");
|
||||||
NYI!("double-check state for leftovers");
|
nyi!("double-check state for leftovers");
|
||||||
config.set("state-name", &ProgramState::Normal.to_string());
|
_ = config.set("state-name", &ProgramState::Normal.to_string());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,25 +698,3 @@ fn send_email(
|
||||||
);
|
);
|
||||||
email.send_email(full_subject, full_body)
|
email.send_email(full_subject, full_body)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_logo(eta: &str) {
|
|
||||||
let ansi_art_pt1 = r#"
|
|
||||||
[0m
|
|
||||||
[0;1;41m [0m
|
|
||||||
[0;1;41m ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ [0;1;30m Plenum! Ple-e-e-num!
|
|
||||||
[0;1;41m █ ▂▂▂▂▂▂▂▂▂ █ [0;1;30m Plenum ist wichtig für die Revolution!
|
|
||||||
[0;1;41m █ ▞ ▚ ▌ ▚ █ [0m
|
|
||||||
[0;1;41m █ ▌ ▚🬯🮗🮗🮗🮗🮗🮗▚▚▚ █ [0m Dies ist der [1mCCCB Plenumsbot
|
|
||||||
[0;1;41m █ ▌ ▞🬥🮗🮗🮗🮗🮗🮗▜▞▞▖ █ [0m
|
|
||||||
[0;1;41m █ ▚ ▞ ▌ ▞ 🬂🬤▞▚🬭 █ [0m Version {VERSION}
|
|
||||||
[0;1;41m █ 🬂🬂🬂🬂🬂🬂🬂🬂🬂 ▞▐▐ █ [0m
|
|
||||||
[0;1;41m █ 🬔🬈 🬔🬈 🬔🬈 🬴🬗 🬭🬫🬀 █ [0m ETA.:"#;
|
|
||||||
let ansi_art_pt2 = r#"
|
|
||||||
[0;1;41m █ 🬣🬖 🬣🬖 🬣🬖 🬲🬘 ▚ █ [0m
|
|
||||||
[0;1;41m █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ [0m
|
|
||||||
[0;1;41m [0m
|
|
||||||
[1;0;31m▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀[0m
|
|
||||||
"#;
|
|
||||||
let ansi_art = format!("{ansi_art_pt1}{eta}{ansi_art_pt2}");
|
|
||||||
println!("{}", ansi_art);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::io::Read;
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
|
@ -9,9 +8,10 @@ use std::collections::HashMap;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use reqwest::blocking::Client;
|
use reqwest::blocking::Client;
|
||||||
use serde_json::{json, Value};
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::config_spec::{CfgField, CfgGroup};
|
use crate::config_spec::{CfgField, CfgGroup};
|
||||||
|
#[allow(unused_imports)]
|
||||||
use crate::{trace_var, verboseln};
|
use crate::{trace_var, verboseln};
|
||||||
|
|
||||||
pub const CONFIG: CfgGroup<'static> = CfgGroup {
|
pub const CONFIG: CfgGroup<'static> = CfgGroup {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use chrono::{Datelike, NaiveDate, Utc};
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use reqwest::blocking::Client;
|
use reqwest::blocking::Client;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::{json, Value};
|
use serde_json;
|
||||||
|
|
||||||
use crate::config_spec::{CfgField, CfgGroup};
|
use crate::config_spec::{CfgField, CfgGroup};
|
||||||
use crate::{trace_var, verboseln};
|
use crate::{trace_var, verboseln};
|
||||||
|
@ -81,7 +81,7 @@ pub enum ValidRequestTypes {
|
||||||
pub enum ValidPageEdits {
|
pub enum ValidPageEdits {
|
||||||
WithPotentiallyOverriding,
|
WithPotentiallyOverriding,
|
||||||
WithoutOverriding,
|
WithoutOverriding,
|
||||||
ModifyPlenumPageAfterwards_WithoutOverriding,
|
ModifyPlenumPageAfterwardsWithoutOverriding,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mediawiki {
|
impl Mediawiki {
|
||||||
|
@ -255,7 +255,7 @@ impl Mediawiki {
|
||||||
("bot", "true"),
|
("bot", "true"),
|
||||||
])
|
])
|
||||||
},
|
},
|
||||||
ValidPageEdits::ModifyPlenumPageAfterwards_WithoutOverriding => {
|
ValidPageEdits::ModifyPlenumPageAfterwardsWithoutOverriding => {
|
||||||
// This means we *CREATE* a *new Page* and always prevent overwriting
|
// This means we *CREATE* a *new Page* and always prevent overwriting
|
||||||
Box::from([
|
Box::from([
|
||||||
("action", "edit"),
|
("action", "edit"),
|
||||||
|
@ -326,7 +326,7 @@ impl Mediawiki {
|
||||||
verboseln!("pos7");
|
verboseln!("pos7");
|
||||||
// Update the main plenum page if requested
|
// Update the main plenum page if requested
|
||||||
match update_main_page {
|
match update_main_page {
|
||||||
ValidPageEdits::ModifyPlenumPageAfterwards_WithoutOverriding => {
|
ValidPageEdits::ModifyPlenumPageAfterwardsWithoutOverriding => {
|
||||||
verboseln!("updating main page...");
|
verboseln!("updating main page...");
|
||||||
self.update_plenum_page(page_title)?
|
self.update_plenum_page(page_title)?
|
||||||
},
|
},
|
||||||
|
@ -530,7 +530,7 @@ pub fn pad_ins_wiki(
|
||||||
wiki.new_wiki_page(
|
wiki.new_wiki_page(
|
||||||
&full_page_title,
|
&full_page_title,
|
||||||
&pad_converted,
|
&pad_converted,
|
||||||
ValidPageEdits::ModifyPlenumPageAfterwards_WithoutOverriding,
|
ValidPageEdits::ModifyPlenumPageAfterwardsWithoutOverriding,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
verboseln!("Finished successfully with wiki");
|
verboseln!("Finished successfully with wiki");
|
||||||
|
@ -560,7 +560,7 @@ fn create_page_title(date: &NaiveDate) -> String {
|
||||||
/// Deserialization must be done this way because the response contains
|
/// Deserialization must be done this way because the response contains
|
||||||
/// two `\\` characters in both the login and csrf tokens, which breaks the
|
/// two `\\` characters in both the login and csrf tokens, which breaks the
|
||||||
/// usual deserialization
|
/// usual deserialization
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct QueryResponseLogin {
|
struct QueryResponseLogin {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -568,11 +568,13 @@ struct QueryResponseLogin {
|
||||||
query: QueryTokensLogin,
|
query: QueryTokensLogin,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct QueryTokensLogin {
|
struct QueryTokensLogin {
|
||||||
tokens: TokensLogin,
|
tokens: TokensLogin,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct TokensLogin {
|
struct TokensLogin {
|
||||||
logintoken: String,
|
logintoken: String,
|
||||||
|
|
Loading…
Reference in a new issue