Compare commits

...

2 Commits

Author SHA1 Message Date
oysteikt 023aefff20 finger: debug logging serverside
Build and test / check (push) Successful in 1m24s
Build and test / build (push) Successful in 1m31s
Build and test / test (push) Successful in 1m56s
Build and test / docs (push) Successful in 3m35s
2026-04-23 20:53:24 +09:00
oysteikt 9cd1d0fe83 finger: dedup results 2026-04-23 20:53:24 +09:00
+13 -1
View File
@@ -1,6 +1,7 @@
use std::os::fd::OwnedFd;
use anyhow::Context;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use zlink::{ReplyError, service::MethodReply};
@@ -136,6 +137,7 @@ impl VarlinkRoowhoo2ClientServer {
impl VarlinkRoowhoo2ClientServer {
// TODO: handle 'all' parameter
async fn handle_rwho_request(&self, _all: bool) -> VarlinkRwhoResponse {
tracing::debug!(all = _all, "Handling Rwho request");
let store = self.whod_status_store.read().await;
let mut all_user_entries = Vec::with_capacity(store.len());
@@ -153,6 +155,7 @@ impl VarlinkRoowhoo2ClientServer {
}
async fn handle_ruptime_request(&self) -> VarlinkRuptimeResponse {
tracing::debug!("Handling Ruptime request");
let store = self.whod_status_store.read().await;
store.values().cloned().collect()
}
@@ -165,8 +168,13 @@ impl VarlinkRoowhoo2ClientServer {
_request_networking: FingerRequestNetworking,
_disable_user_account_db: bool,
) -> VarlinkFingerResponse {
tracing::debug!(
user_queries = ?user_queries,
match_fullnames = match_fullnames,
request_info = ?request_info,
"Handling Finger request",
);
match user_queries {
// TODO: deduplicate results
Some(usernames) => usernames
.into_iter()
.flat_map::<Vec<_>, _>(|username| {
@@ -175,6 +183,10 @@ impl VarlinkRoowhoo2ClientServer {
.map(|res| (username.clone(), res))
.collect()
})
.dedup_by(|a, b| match (&a.1, &b.1) {
(Ok(user_a), Ok(user_b)) => user_a.username == user_b.username,
_ => false,
})
.filter_map(|(username, user)| match user {
Ok(user_info) => Some(user_info),
Err(err) => {