Skip to content

Commit

Permalink
Merge pull request #1239 from get10101/chore/user-registration-dlc-ch…
Browse files Browse the repository at this point in the history
…annels-endpoint

Add user registration timestamp to `dlc_channels` endpoint
  • Loading branch information
luckysori authored Sep 7, 2023
2 parents 08f6832 + 3647b06 commit 269d899
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions coordinator/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use serde::Serialize;
use std::fmt;
use std::str::FromStr;
use std::sync::Arc;
use time::OffsetDateTime;
use tokio::task::spawn_blocking;
use tracing::instrument;

Expand Down Expand Up @@ -95,13 +96,21 @@ pub struct DlcChannelDetails {
#[serde(flatten)]
pub channel_details: ln_dlc_node::DlcChannelDetails,
pub user_email: String,
pub user_registration_timestamp: Option<OffsetDateTime>,
}

impl From<(SubChannel, String)> for DlcChannelDetails {
fn from((channel_details, user_email): (SubChannel, String)) -> Self {
impl From<(SubChannel, String, Option<OffsetDateTime>)> for DlcChannelDetails {
fn from(
(channel_details, user_email, user_registration_timestamp): (
SubChannel,
String,
Option<OffsetDateTime>,
),
) -> Self {
DlcChannelDetails {
channel_details: ln_dlc_node::DlcChannelDetails::from(channel_details),
user_email,
user_registration_timestamp,
}
}
}
Expand All @@ -122,12 +131,12 @@ pub async fn list_dlc_channels(
let dlc_channels = dlc_channels
.into_iter()
.map(|subchannel| {
let user_email = match db::user::by_id(&mut conn, subchannel.counter_party.to_string())
{
Ok(Some(user)) => user.email,
_ => "unknown".to_string(),
};
DlcChannelDetails::from((subchannel, user_email))
let (email, registration_timestamp) =
match db::user::by_id(&mut conn, subchannel.counter_party.to_string()) {
Ok(Some(user)) => (user.email, Some(user.timestamp)),
_ => ("unknown".to_string(), None),
};
DlcChannelDetails::from((subchannel, email, registration_timestamp))
})
.collect::<Vec<_>>();

Expand Down

0 comments on commit 269d899

Please sign in to comment.