// Try to register on Mastodon
let stmt = match dbclient_rw
.prepare(
"INSERT INTO auth.mastodon_apps (domain, refresh_ts) VALUES ($1, $2)
ON CONFLICT (domain) DO UPDATE SET refresh_ts = $2
RETURNING client_id, client_secret;",
)
.await
{
Ok(stmt) => stmt,
Err(e) => {
log::error!("Pool RW statement error {}", e);
return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
}
};
let ts = chrono::Utc::now().naive_utc();
let rows = match dbclient_rw.query_opt(&stmt, &[&domain, &ts]).await {
Ok(rows) => rows,
Err(e) => {
log::error!("Pool RW query error {}", e);
return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
}
};
let row = match rows {
Some(row) => row,
None => {
log::error!("Pool RW query error");
return HttpResponse::ServiceUnavailable().body(actix_web::body::None::new());
}
};