Compare commits

..

No commits in common. "92b880f03b528868e942f2188384969f5293f91d" and "221b4f10dfe8dc88aba36ebc5fdc8efcb3251e84" have entirely different histories.

6 changed files with 28 additions and 43 deletions

10
Cargo.lock generated
View File

@ -2995,7 +2995,7 @@ dependencies = [
[[package]]
name = "letterbox-notmuch"
version = "0.15.2"
version = "0.15.1"
dependencies = [
"itertools",
"log",
@ -3010,14 +3010,14 @@ dependencies = [
[[package]]
name = "letterbox-procmail2notmuch"
version = "0.15.2"
version = "0.15.1"
dependencies = [
"anyhow",
]
[[package]]
name = "letterbox-server"
version = "0.15.2"
version = "0.15.1"
dependencies = [
"ammonia",
"anyhow",
@ -3061,7 +3061,7 @@ dependencies = [
[[package]]
name = "letterbox-shared"
version = "0.15.2"
version = "0.15.1"
dependencies = [
"build-info",
"letterbox-notmuch",
@ -3071,7 +3071,7 @@ dependencies = [
[[package]]
name = "letterbox-web"
version = "0.15.2"
version = "0.15.1"
dependencies = [
"build-info",
"build-info-build",

View File

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

View File

@ -27,8 +27,8 @@ css-inline = "0.14.0"
futures = "0.3.31"
headers = "0.4.0"
html-escape = "0.2.13"
letterbox-notmuch = { version = "0.15.2", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.15.2", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.15.1", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.15.1", path = "../shared", registry = "xinu" }
linkify = "0.10.0"
log = "0.4.17"
lol_html = "2.0.0"

View File

@ -8,10 +8,10 @@ use async_graphql_axum::{GraphQL, GraphQLSubscription};
//allows to extract the IP of connecting user
use axum::extract::connect_info::ConnectInfo;
use axum::{
extract::{self, ws::WebSocketUpgrade, Query, State},
extract::{self, ws::WebSocketUpgrade, State},
http::{header, StatusCode},
response::{self, IntoResponse, Response},
routing::{any, get, post},
routing::{any, get},
Router,
};
use cacher::FilesystemCacher;
@ -25,7 +25,6 @@ use letterbox_server::{
ws::ConnectionTracker,
};
use letterbox_shared::WebsocketMessage;
use serde::Deserialize;
use sqlx::postgres::PgPool;
use tokio::{net::TcpListener, sync::Mutex};
use tower_http::trace::{DefaultMakeSpan, TraceLayer};
@ -160,29 +159,18 @@ async fn start_ws(
) -> impl IntoResponse {
ws.on_upgrade(async move |socket| connection_tracker.lock().await.add_peer(socket, addr).await)
}
#[derive(Debug, Deserialize)]
struct NotificationParams {
delay_ms: Option<u64>,
}
async fn send_refresh_websocket_handler(
#[axum_macros::debug_handler]
async fn test_handler(
State(AppState {
connection_tracker, ..
}): State<AppState>,
params: Query<NotificationParams>,
) -> impl IntoResponse {
info!("send_refresh_websocket_handler params {params:?}");
if let Some(delay_ms) = params.delay_ms {
let delay = Duration::from_millis(delay_ms);
info!("sleeping {delay:?}");
tokio::time::sleep(delay).await;
}
connection_tracker
.lock()
.await
.send_message_all(WebsocketMessage::RefreshMessages)
.await;
"refresh triggered"
"test triggered"
}
async fn watch_new(
@ -252,26 +240,23 @@ async fn main() -> Result<(), Box<dyn Error>> {
let poll_time = Duration::from_secs(10);
let _h = tokio::spawn(watch_new(nm.clone(), pool, ct, poll_time));
let api_routes = Router::new()
let app = Router::new()
.route("/test", get(test_handler))
.route(
"/download/attachment/{id}/{idx}/{*rest}",
"/api/download/attachment/{id}/{idx}/{*rest}",
get(download_attachment),
)
.route("/view/attachment/{id}/{idx}/{*rest}", get(view_attachment))
.route("/cid/{id}/{cid}", get(view_cid))
.route("/ws", any(start_ws))
.route_service("/graphql/ws", GraphQLSubscription::new(schema.clone()))
.route(
"/graphql/",
"/api/view/attachment/{id}/{idx}/{*rest}",
get(view_attachment),
)
.route("/api/cid/{id}/{cid}", get(view_cid))
.route("/api/ws", any(start_ws))
.route_service("/api/graphql/ws", GraphQLSubscription::new(schema.clone()))
.route(
"/api/graphql/",
get(graphiql).post_service(GraphQL::new(schema.clone())),
);
let notification_routes = Router::new()
.route("/mail", post(send_refresh_websocket_handler))
.route("/news", post(send_refresh_websocket_handler));
let app = Router::new()
.nest("/api", api_routes)
.nest("/notification", notification_routes)
)
.with_state(AppState {
nm,
connection_tracker,

View File

@ -12,6 +12,6 @@ version.workspace = true
[dependencies]
build-info = "0.0.40"
letterbox-notmuch = { version = "0.15.2", path = "../notmuch", registry = "xinu" }
letterbox-notmuch = { version = "0.15.1", path = "../notmuch", registry = "xinu" }
serde = { version = "1.0.147", features = ["derive"] }
strum_macros = "0.27.1"

View File

@ -33,8 +33,8 @@ wasm-bindgen = "=0.2.100"
uuid = { version = "1.13.1", features = [
"js",
] } # direct dep to set js feature, prevents Rng issues
letterbox-shared = { version = "0.15.2", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.15.2", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.15.1", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.15.1", path = "../notmuch", registry = "xinu" }
seed_hooks = { version = "0.4.0", registry = "xinu" }
strum_macros = "0.27.1"
gloo-console = "0.3.0"