Compare commits

..

33 Commits

Author SHA1 Message Date
c81a8c1cd3 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 35s
Continuous integration / Test Suite (push) Successful in 40s
Continuous integration / Trunk (push) Successful in 37s
Continuous integration / Rustfmt (push) Successful in 39s
Continuous integration / build (push) Successful in 47s
Continuous integration / Disallow unused dependencies (push) Successful in 2m5s
2025-05-18 09:54:26 -07:00
7c3cfec3d1 web: improve keep unread logic in catchup, remove execess logging 2025-05-18 09:54:03 -07:00
a2920fde3b chore(deps): lock file maintenance
All checks were successful
Continuous integration / Check (push) Successful in 42s
Continuous integration / Test Suite (push) Successful in 2m51s
Continuous integration / Rustfmt (push) Successful in 37s
Continuous integration / Trunk (push) Successful in 4m0s
Continuous integration / Disallow unused dependencies (push) Successful in 58s
Continuous integration / build (push) Successful in 3m31s
2025-05-12 00:01:38 +00:00
8bc449ae6e fix(deps): update rust crate clap to v4.5.38
All checks were successful
Continuous integration / Check (push) Successful in 40s
Continuous integration / Trunk (push) Successful in 37s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / Test Suite (push) Successful in 2m0s
Continuous integration / build (push) Successful in 55s
Continuous integration / Disallow unused dependencies (push) Successful in 2m0s
2025-05-11 01:16:28 +00:00
0febd0535a fix(deps): update rust crate tower-http to v0.6.4
All checks were successful
Continuous integration / Check (push) Successful in 43s
Continuous integration / Test Suite (push) Successful in 49s
Continuous integration / Rustfmt (push) Successful in 32s
Continuous integration / build (push) Successful in 55s
Continuous integration / Disallow unused dependencies (push) Successful in 55s
Continuous integration / Trunk (push) Successful in 7m9s
2025-05-10 20:46:27 +00:00
a9e00a54e4 fix(deps): update rust crate tower-http to v0.6.3
All checks were successful
Continuous integration / Check (push) Successful in 1m3s
Continuous integration / Test Suite (push) Successful in 1m6s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / build (push) Successful in 56s
Continuous integration / Disallow unused dependencies (push) Successful in 55s
Continuous integration / Trunk (push) Successful in 7m14s
2025-05-07 19:46:07 +00:00
6811c689ff fix(deps): update rust crate tokio to v1.45.0
All checks were successful
Continuous integration / Check (push) Successful in 40s
Continuous integration / Trunk (push) Successful in 38s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / Test Suite (push) Successful in 2m18s
Continuous integration / build (push) Successful in 56s
Continuous integration / Disallow unused dependencies (push) Successful in 2m10s
2025-05-06 06:46:13 +00:00
8ba6b3d0b0 chore(deps): lock file maintenance
All checks were successful
Continuous integration / Check (push) Successful in 50s
Continuous integration / Test Suite (push) Successful in 49s
Continuous integration / Rustfmt (push) Successful in 32s
Continuous integration / build (push) Successful in 1m13s
Continuous integration / Disallow unused dependencies (push) Successful in 58s
Continuous integration / Trunk (push) Successful in 7m14s
2025-05-05 00:01:38 +00:00
a7c5585e80 fix(deps): update rust crate axum to v0.8.4
All checks were successful
Continuous integration / Check (push) Successful in 39s
Continuous integration / Trunk (push) Successful in 37s
Continuous integration / Rustfmt (push) Successful in 32s
Continuous integration / Test Suite (push) Successful in 2m10s
Continuous integration / build (push) Successful in 55s
Continuous integration / Disallow unused dependencies (push) Successful in 1m59s
2025-04-30 16:46:20 +00:00
4ef4d49113 fix(deps): update rust crate chrono to v0.4.41
All checks were successful
Continuous integration / Check (push) Successful in 41s
Continuous integration / Test Suite (push) Successful in 49s
Continuous integration / Rustfmt (push) Successful in 40s
Continuous integration / Trunk (push) Successful in 3m47s
Continuous integration / build (push) Successful in 3m24s
Continuous integration / Disallow unused dependencies (push) Successful in 55s
2025-04-29 09:31:11 +00:00
f8af303110 chore(deps): lock file maintenance
All checks were successful
Continuous integration / Check (push) Successful in 40s
Continuous integration / Test Suite (push) Successful in 1m16s
Continuous integration / Rustfmt (push) Successful in 34s
Continuous integration / build (push) Successful in 1m21s
Continuous integration / Disallow unused dependencies (push) Successful in 55s
Continuous integration / Trunk (push) Successful in 7m21s
2025-04-28 00:01:40 +00:00
fa5aac34ba chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 44s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / Trunk (push) Successful in 55s
Continuous integration / build (push) Successful in 51s
Continuous integration / Disallow unused dependencies (push) Successful in 2m7s
2025-04-24 12:03:13 -07:00
b58556254e notmuch: log any stderr output 2025-04-24 12:02:55 -07:00
e365ced7dd server: more concise slice of ids 2025-04-24 12:02:40 -07:00
93d569fb14 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 44s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / Trunk (push) Successful in 51s
Continuous integration / build (push) Successful in 52s
Continuous integration / Disallow unused dependencies (push) Successful in 2m4s
2025-04-24 09:04:42 -07:00
f86a5f464d server: properly limit index 2025-04-24 09:04:22 -07:00
956c20b156 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 38s
Continuous integration / Trunk (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 1m13s
Continuous integration / Rustfmt (push) Successful in 30s
Continuous integration / Disallow unused dependencies (push) Successful in 56s
Continuous integration / build (push) Successful in 1m34s
2025-04-24 08:56:56 -07:00
1eb498712b server: prevent out of bounds index at end of processing 2025-04-24 08:56:19 -07:00
f12979c0be chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 45s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / build (push) Successful in 52s
Continuous integration / Disallow unused dependencies (push) Successful in 55s
Continuous integration / Trunk (push) Successful in 7m10s
2025-04-23 18:59:16 -07:00
4665f34e54 server: label_unprocessed handle case where files cannot be found from message-id 2025-04-23 18:57:54 -07:00
bbdc35061c chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 45s
Continuous integration / Trunk (push) Successful in 37s
Continuous integration / Rustfmt (push) Successful in 39s
Continuous integration / build (push) Successful in 52s
Continuous integration / Disallow unused dependencies (push) Successful in 2m9s
2025-04-23 15:25:34 -07:00
f11f0b4d23 server: migrate all use of log to tracing 2025-04-23 15:25:11 -07:00
c7c47e4a73 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 44s
Continuous integration / Trunk (push) Successful in 38s
Continuous integration / Rustfmt (push) Successful in 39s
Continuous integration / build (push) Successful in 51s
Continuous integration / Disallow unused dependencies (push) Successful in 2m5s
2025-04-23 14:57:39 -07:00
c3835522b2 server: add Letterbox/Bad label to unparsable emails, and consider them processed 2025-04-23 14:57:13 -07:00
dfa80f9046 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 55s
Continuous integration / Trunk (push) Successful in 52s
Continuous integration / Rustfmt (push) Successful in 39s
Continuous integration / Disallow unused dependencies (push) Successful in 58s
Continuous integration / build (push) Successful in 1m32s
2025-04-23 14:41:25 -07:00
b8dfdabf8d server: more tracing and logging 2025-04-23 14:41:11 -07:00
bbcf52b006 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 43s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / Trunk (push) Successful in 51s
Continuous integration / build (push) Successful in 51s
Continuous integration / Disallow unused dependencies (push) Successful in 2m5s
2025-04-23 11:38:48 -07:00
f92c05cd28 server: return ids processed from send_refresh_websocket_handler 2025-04-23 11:38:30 -07:00
885bbe0a8c chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 40s
Continuous integration / Test Suite (push) Successful in 45s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / Trunk (push) Successful in 52s
Continuous integration / build (push) Successful in 55s
Continuous integration / Disallow unused dependencies (push) Successful in 2m5s
2025-04-23 11:09:19 -07:00
8b1d111837 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 38s
Continuous integration / Trunk (push) Successful in 37s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / Test Suite (push) Successful in 1m36s
Continuous integration / build (push) Successful in 51s
Continuous integration / Disallow unused dependencies (push) Successful in 1m59s
2025-04-23 11:02:46 -07:00
08abf31fa9 server: always remove unprocessed label when processing rules 2025-04-23 11:02:29 -07:00
fa99959508 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 46s
Continuous integration / Trunk (push) Successful in 38s
Continuous integration / Rustfmt (push) Successful in 38s
Continuous integration / build (push) Successful in 53s
Continuous integration / Disallow unused dependencies (push) Successful in 1m55s
2025-04-23 09:31:43 -07:00
0f6af0f475 server: more debug prints 2025-04-23 09:31:25 -07:00
12 changed files with 382 additions and 338 deletions

566
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
edition = "2021"
license = "UNLICENSED"
publish = ["xinu"]
version = "0.17.12"
version = "0.17.24"
repository = "https://git.z.xinu.tv/wathiede/letterbox"
[profile.dev]

View File

@@ -214,9 +214,8 @@ use std::{
process::Command,
};
use log::{error, info};
use serde::{Deserialize, Serialize};
use tracing::instrument;
use tracing::{error, info, instrument, warn};
/// # Number of seconds since the Epoch
pub type UnixTime = isize;
@@ -718,6 +717,13 @@ impl Notmuch {
cmd.args(args);
info!("{:?}", &cmd);
let out = cmd.output()?;
if !out.stderr.is_empty() {
warn!(
"{:?}: STDERR:\n{}",
&cmd,
String::from_utf8_lossy(&out.stderr)
);
}
Ok(out.stdout)
}
}

View File

@@ -27,10 +27,9 @@ css-inline = "0.14.4"
futures = "0.3.31"
headers = "0.4.0"
html-escape = "0.2.13"
letterbox-notmuch = { path = "../notmuch", version = "0.17.12", registry = "xinu" }
letterbox-shared = { path = "../shared", version = "0.17.12", registry = "xinu" }
letterbox-notmuch = { path = "../notmuch", version = "0.17.24", registry = "xinu" }
letterbox-shared = { path = "../shared", version = "0.17.24", registry = "xinu" }
linkify = "0.10.0"
log = "0.4.27"
lol_html = "2.3.0"
mailparse = "0.16.1"
maplit = "1.0.2"

View File

@@ -200,15 +200,21 @@ async fn send_refresh_websocket_handler(
None => Some(10),
};
if let Err(err) = label_unprocessed(&nm, &pool, false, limit, "tag:unprocessed").await {
error!("Failed to label_unprocessed: {err:?}");
let mut ids = None;
match label_unprocessed(&nm, &pool, false, limit, "tag:unprocessed").await {
Ok(i) => ids = Some(i),
Err(err) => error!("Failed to label_unprocessed: {err:?}"),
};
connection_tracker
.lock()
.await
.send_message_all(WebsocketMessage::RefreshMessages)
.await;
"refresh triggered"
if let Some(ids) = ids {
format!("{ids:?}")
} else {
"refresh triggered".to_string()
}
}
async fn watch_new(

View File

@@ -9,11 +9,10 @@ use async_graphql::{
use cacher::FilesystemCacher;
use futures::stream;
use letterbox_notmuch::Notmuch;
use log::info;
use serde::{Deserialize, Serialize};
use sqlx::postgres::PgPool;
use tokio::join;
use tracing::instrument;
use tracing::{info, instrument};
#[cfg(feature = "tantivy")]
use crate::tantivy::TantivyConnection;

View File

@@ -21,7 +21,6 @@ use cacher::{Cacher, FilesystemCacher};
use css_inline::{CSSInliner, InlineError, InlineOptions};
pub use error::ServerError;
use linkify::{LinkFinder, LinkKind};
use log::{debug, error, info, warn};
use lol_html::{
element, errors::RewritingError, html_content::ContentType, rewrite_str, text,
RewriteStrSettings,
@@ -32,6 +31,7 @@ use reqwest::StatusCode;
use scraper::{Html, Selector};
use sqlx::types::time::PrimitiveDateTime;
use thiserror::Error;
use tracing::{debug, error, info, warn};
use url::Url;
use crate::{

View File

@@ -3,11 +3,10 @@ use std::collections::HashMap;
use cacher::FilesystemCacher;
use futures::{stream::FuturesUnordered, StreamExt};
use letterbox_shared::compute_color;
use log::{error, info};
use maplit::hashmap;
use scraper::Selector;
use sqlx::postgres::PgPool;
use tracing::instrument;
use tracing::{error, info, instrument};
use url::Url;
use crate::{

View File

@@ -5,11 +5,10 @@ use std::{
use letterbox_notmuch::Notmuch;
use letterbox_shared::{compute_color, Rule};
use log::{error, info, warn};
use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail};
use memmap::MmapOptions;
use sqlx::{types::Json, PgPool};
use tracing::instrument;
use tracing::{error, info, info_span, instrument, warn};
use crate::{
compute_offset_limit,
@@ -946,7 +945,7 @@ pub async fn label_unprocessed(
dryrun: bool,
limit: Option<usize>,
query: &str,
) -> Result<(), ServerError> {
) -> Result<Box<[String]>, ServerError> {
use futures::StreamExt;
let ids = nm.message_ids(query)?;
info!(
@@ -977,21 +976,38 @@ pub async fn label_unprocessed(
*/
info!("Loaded {} rules", rules.len());
let ids = if let Some(limit) = limit {
&ids[..limit]
} else {
&ids[..]
};
let limit = limit.unwrap_or(ids.len());
let limit = limit.min(ids.len());
let ids = &ids[..limit];
let mut add_mutations = HashMap::new();
let mut rm_mutations = HashMap::new();
for id in ids {
let id = format!("id:{id}");
let files = nm.files(&id)?;
// Only process the first file path is multiple files have the same id
let path = files.iter().next().unwrap();
let Some(path) = files.iter().next() else {
error!("No files for message-ID {id}");
let t = "Letterbox/Bad";
nm.tag_add(t, &id)?;
let t = "unprocessed";
nm.tag_remove(t, &id)?;
continue;
};
let file = File::open(&path)?;
info!("parsing {path}");
let mmap = unsafe { MmapOptions::new().map(&file)? };
let m = parse_mail(&mmap)?;
let m = match info_span!("parse_mail", path = path).in_scope(|| parse_mail(&mmap)) {
Ok(m) => m,
Err(err) => {
error!("Failed to parse {path}: {err}");
let t = "Letterbox/Bad";
nm.tag_add(t, &id)?;
let t = "unprocessed";
nm.tag_remove(t, &id)?;
continue;
}
};
let (matched_rule, add_tags) = find_tags(&rules, &m.headers);
if matched_rule {
if dryrun {
@@ -1036,11 +1052,6 @@ pub async fn label_unprocessed(
.or_insert_with(|| Vec::new())
.push(id.clone());
}
let t = "unprocessed".to_string();
rm_mutations
.entry(t)
.or_insert_with(|| Vec::new())
.push(id.clone());
//nm.tag_remove("inbox", &id)?;
let t = "inbox".to_string();
rm_mutations
@@ -1048,25 +1059,32 @@ pub async fn label_unprocessed(
.or_insert_with(|| Vec::new())
.push(id.clone());
}
let t = "unprocessed".to_string();
rm_mutations
.entry(t)
.or_insert_with(|| Vec::new())
.push(id.clone());
}
println!("Adding {} distinct labels", add_mutations.len());
info!("Adding {} distinct labels", add_mutations.len());
for (tag, ids) in add_mutations.iter() {
println!(" {tag}: {}", ids.len());
info!(" {tag}: {}", ids.len());
if !dryrun {
let ids: Vec<_> = ids.iter().map(|s| s.as_str()).collect();
nm.tags_add(tag, &ids)?;
info_span!("tags_add", tag = tag, count = ids.len())
.in_scope(|| nm.tags_add(tag, &ids))?;
}
}
println!("Removing {} distinct labels", rm_mutations.len());
info!("Removing {} distinct labels", rm_mutations.len());
for (tag, ids) in rm_mutations.iter() {
println!(" {tag}: {}", ids.len());
info!(" {tag}: {}", ids.len());
if !dryrun {
let ids: Vec<_> = ids.iter().map(|s| s.as_str()).collect();
nm.tags_remove(tag, &ids)?;
info_span!("tags_remove", tag = tag, count = ids.len())
.in_scope(|| nm.tags_remove(tag, &ids))?;
}
}
Ok(())
Ok(ids.into())
}
fn find_tags<'a, 'b>(rules: &'a [Rule], headers: &'b [MailHeader]) -> (bool, HashSet<&'a str>) {
let mut matched_rule = false;

View File

@@ -12,7 +12,7 @@ version.workspace = true
[dependencies]
build-info = "0.0.40"
letterbox-notmuch = { path = "../notmuch", version = "0.17.12", registry = "xinu" }
letterbox-notmuch = { path = "../notmuch", version = "0.17.24", registry = "xinu" }
regex = "1.11.1"
serde = { version = "1.0.219", features = ["derive"] }
sqlx = "0.8.5"

View File

@@ -72,10 +72,6 @@ fn on_url_changed(old: &Url, mut new: Url) -> Msg {
if did_change {
messages.push(Msg::ScrollToTop)
}
info!(
"url changed\nold '{old}'\nnew '{new}', history {}",
history().length().unwrap_or(0)
);
let hpp = new.remaining_hash_path_parts();
let msg = match hpp.as_slice() {
["t", tid] => Msg::ShowThreadRequest {
@@ -553,7 +549,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
});
}
Msg::ScrollToTop => {
info!("scrolling to the top");
web_sys::window().unwrap().scroll_to_with_x_and_y(0., 0.);
}
Msg::WindowScrolled => {
@@ -619,6 +614,36 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
orders.send_msg(Msg::CatchupRequest { query });
}
Msg::CatchupKeepUnread => {
if let Some(thread_id) = current_thread_id(&model.context) {
if let Context::ThreadResult {
thread:
ShowThreadQueryThread::EmailThread(ShowThreadQueryThreadOnEmailThread {
messages,
..
}),
..
} = &model.context
{
//orders.send_msg(Msg::SetUnread(thread_id, false));
let unread_messages: Vec<_> = messages
.iter()
.filter(|msg| msg.tags.iter().any(|t| t == "unread"))
.map(|msg| &msg.id)
.collect();
if unread_messages.is_empty() {
// All messages are read, so mark them all unread
orders.send_msg(Msg::SetUnread(thread_id, true));
} else {
// Do nothing if there are some messages unread
}
} else {
// News post, not email, just mark unread
orders.send_msg(Msg::SetUnread(thread_id, true));
};
} else {
// This shouldn't happen
warn!("no current thread_id");
}
orders.send_msg(Msg::CatchupNext);
}
Msg::CatchupMarkAsRead => {

View File

@@ -1,7 +1,7 @@
use std::{collections::VecDeque, rc::Rc};
use letterbox_shared::WebsocketMessage;
use log::{error, info};
use log::{debug, error};
use seed::prelude::*;
use serde::{Deserialize, Serialize};
#[cfg(not(target_arch = "wasm32"))]
@@ -122,13 +122,13 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
match msg {
Msg::WebSocketOpened => {
model.web_socket_reconnector = None;
info!("WebSocket connection is open now");
debug!("WebSocket connection is open now");
}
Msg::TextMessageReceived(msg) => {
model.updates.push_back(msg);
}
Msg::WebSocketClosed(close_event) => {
info!(
debug!(
r#"==================
WebSocket connection was closed:
Clean: {0}
@@ -148,7 +148,7 @@ Reason: {2}
}
}
Msg::WebSocketFailed => {
info!("WebSocket failed");
debug!("WebSocket failed");
if model.web_socket_reconnector.is_none() {
model.web_socket_reconnector = Some(
orders.stream_with_handle(streams::backoff(None, Msg::ReconnectWebSocket)),
@@ -156,7 +156,7 @@ Reason: {2}
}
}
Msg::ReconnectWebSocket(retries) => {
info!("Reconnect attempt: {}", retries);
debug!("Reconnect attempt: {}", retries);
model.web_socket = create_websocket(&model.ws_url, orders).unwrap();
}
Msg::SendMessage(msg) => {
@@ -177,16 +177,16 @@ fn create_websocket(url: &str, orders: &impl Orders<Msg>) -> Result<EventClient,
let send = msg_sender.clone();
client.set_on_connection(Some(Box::new(move |client: &EventClient| {
info!("{:#?}", client.status);
debug!("{:#?}", client.status);
let msg = match *client.status.borrow() {
ConnectionStatus::Connecting => {
info!("Connecting...");
debug!("Connecting...");
None
}
ConnectionStatus::Connected => Some(Msg::WebSocketOpened),
ConnectionStatus::Error => Some(Msg::WebSocketFailed),
ConnectionStatus::Disconnected => {
info!("Disconnected");
debug!("Disconnected");
None
}
};
@@ -195,7 +195,7 @@ fn create_websocket(url: &str, orders: &impl Orders<Msg>) -> Result<EventClient,
let send = msg_sender.clone();
client.set_on_close(Some(Box::new(move |ev| {
info!("WS: Connection closed");
debug!("WS: Connection closed");
send(Some(Msg::WebSocketClosed(ev)));
})));