feat: sort by time

This commit is contained in:
Jet Pham 2026-03-05 13:22:19 -08:00
parent 658381307d
commit d43ddb5e06
No known key found for this signature in database
2 changed files with 3 additions and 41 deletions

View file

@ -62,15 +62,6 @@ fn map_webhook_error(e: mymx_sdk::Error) -> (StatusCode, Json<ErrorResponse>) {
}),
)
}
mymx_sdk::Error::TimestampTooOld => {
tracing::warn!("Webhook rejected: timestamp too old (replay protection)");
(
StatusCode::UNAUTHORIZED,
Json(ErrorResponse {
error: "timestamp too old".into(),
}),
)
}
mymx_sdk::Error::HmacError(msg) => {
tracing::warn!("Webhook rejected: HMAC error: {}", msg);
(
@ -218,7 +209,7 @@ async fn health_handler(State(state): State<AppState>) -> impl IntoResponse {
async fn index_handler(State(state): State<AppState>) -> Result<Html<String>, StatusCode> {
let emails: Vec<EmailRow> = sqlx::query_as::<_, EmailRow>(
"SELECT body, subject, from_address, received_at FROM emails",
"SELECT body, subject, from_address, received_at FROM emails ORDER BY received_at DESC",
)
.fetch_all(&state.db)
.await
@ -227,7 +218,7 @@ async fn index_handler(State(state): State<AppState>) -> Result<Html<String>, St
StatusCode::INTERNAL_SERVER_ERROR
})?;
let mut rows: Vec<(String, String, String, DateTime<Utc>)> = emails
let rows: Vec<(String, String, String, DateTime<Utc>)> = emails
.into_iter()
.map(|email| {
let mut hasher = Sha256::new();
@ -239,9 +230,6 @@ async fn index_handler(State(state): State<AppState>) -> Result<Html<String>, St
})
.collect();
// Sort alphabetically by hash
rows.sort_by(|a, b| a.0.cmp(&b.0));
let table_rows: String = rows
.iter()
.map(|(hash, subject, from, received_at)| {