});
}
let stmt = match dbclient
.prepare("select protocol::text, address, is_active, create_ts, delete_ts from auth.contacts where player_name = $1;")
.await
{
Ok(stmt) => stmt,
Err(e) => {
log::error!("{}", e);
return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
}
};
let rows = match dbclient.query(&stmt, &[&user]).await {
Ok(rows) => rows,
Err(e) => {
log::error!("{}", e);
return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
}
};
let mut contacts = Vec::with_capacity(rows.len());
for row in rows {
contacts.push(ContactData {
protocol: row.get::<_, String>(0),
address: row.get::<_, String>(1),
is_active: row.get::<_, bool>(2),
create_ts: naive_to_text(row.get::<_, chrono::NaiveDateTime>(3)),
delete_ts: row
.get::<_, Option<chrono::NaiveDateTime>>(4)
.map(naive_to_text),