Add info to verified discord log message

This commit is contained in:
Aadi Desai 2023-11-11 17:32:27 +00:00
parent b93194e57f
commit 1a94df8603
Signed by: supleed2
SSH key fingerprint: SHA256:CkbNRs0yVzXEiUp2zd0PSxsfRUMFF9bLlKXtE1xEbKM
5 changed files with 20 additions and 10 deletions

View file

@ -219,7 +219,7 @@ pub(crate) async fn insert_member_from_pending(
match db::insert_member_from_pending(&ctx.data().db, id.user.id.into(), &nickname, fresher) match db::insert_member_from_pending(&ctx.data().db, id.user.id.into(), &nickname, fresher)
.await .await
{ {
Ok(()) => { Ok(_) => {
ctx.say(format!("Member moved from pending to members table: {id}")) ctx.say(format!("Member moved from pending to members table: {id}"))
.await? .await?
} }
@ -237,7 +237,7 @@ pub(crate) async fn insert_member_from_manual(
) -> Result<(), Error> { ) -> Result<(), Error> {
tracing::info!("{} {}", ctx.author().name, id.user.name,); tracing::info!("{} {}", ctx.author().name, id.user.name,);
match db::insert_member_from_manual(&ctx.data().db, id.user.id.into()).await { match db::insert_member_from_manual(&ctx.data().db, id.user.id.into()).await {
Ok(()) => { Ok(_) => {
ctx.say(format!("Member moved from manual to members table: {id}")) ctx.say(format!("Member moved from manual to members table: {id}"))
.await? .await?
} }

View file

@ -131,7 +131,7 @@ pub(crate) async fn insert_member_from_pending(
id: i64, id: i64,
nickname: &str, nickname: &str,
fresher: bool, fresher: bool,
) -> Result<(), Error> { ) -> Result<PendingMember, Error> {
let p = sqlx::query_as!( let p = sqlx::query_as!(
PendingMember, PendingMember,
"delete from pending where discord_id=$1 returning *", "delete from pending where discord_id=$1 returning *",
@ -149,11 +149,14 @@ pub(crate) async fn insert_member_from_pending(
) )
.execute(pool) .execute(pool)
.await?; .await?;
Ok(()) Ok(p)
} }
/// Add member entry to members table from manual table /// Add member entry to members table from manual table
pub(crate) async fn insert_member_from_manual(pool: &sqlx::PgPool, id: i64) -> Result<(), Error> { pub(crate) async fn insert_member_from_manual(
pool: &sqlx::PgPool,
id: i64,
) -> Result<ManualMember, Error> {
let m = sqlx::query_as!( let m = sqlx::query_as!(
ManualMember, ManualMember,
"delete from manual where discord_id=$1 returning *", "delete from manual where discord_id=$1 returning *",
@ -171,7 +174,7 @@ pub(crate) async fn insert_member_from_manual(pool: &sqlx::PgPool, id: i64) -> R
) )
.execute(pool) .execute(pool)
.await?; .await?;
Ok(()) Ok(m)
} }
/// Edit member shortcode field /// Edit member shortcode field

View file

@ -222,7 +222,7 @@ pub(crate) async fn login_6(
) )
.await .await
{ {
Ok(()) => { Ok(p) => {
tracing::info!( tracing::info!(
"{} ({}) added via login{}", "{} ({}) added via login{}",
m.user.name, m.user.name,
@ -257,6 +257,8 @@ pub(crate) async fn login_6(
.title("Member verified via login") .title("Member verified via login")
.description(&m.user) .description(&m.user)
.field("Fresher", fresher, true) .field("Fresher", fresher, true)
.field("Nickname", nickname, true)
.field("Name", p.realname, true)
.timestamp(serenity::Timestamp::now()) .timestamp(serenity::Timestamp::now())
}) })
}) })

View file

@ -224,7 +224,7 @@ pub(crate) async fn manual_4(
if verify { if verify {
match crate::db::insert_member_from_manual(&data.db, user.id.into()).await { match crate::db::insert_member_from_manual(&data.db, user.id.into()).await {
Ok(()) => { Ok(mm) => {
let fresher = crate::db::get_member_by_id(&data.db, user.id.into()) let fresher = crate::db::get_member_by_id(&data.db, user.id.into())
.await? .await?
.unwrap() .unwrap()
@ -247,6 +247,8 @@ pub(crate) async fn manual_4(
.title("Member verified via manual") .title("Member verified via manual")
.description(&user) .description(&user)
.field("Fresher", fresher, true) .field("Fresher", fresher, true)
.field("Nickname", mm.nickname, true)
.field("Name", mm.realname, true)
.timestamp(serenity::Timestamp::now()) .timestamp(serenity::Timestamp::now())
}) })
}) })

View file

@ -132,13 +132,14 @@ pub(crate) async fn membership_3(
.await?; .await?;
return Ok(()); return Ok(());
}; };
let realname = format!("{} {}", member.first_name, member.surname);
if crate::db::insert_member( if crate::db::insert_member(
&data.db, &data.db,
crate::Member { crate::Member {
discord_id: m.user.id.into(), discord_id: m.user.id.into(),
shortcode, shortcode,
nickname, nickname: nickname.clone(),
realname: format!("{} {}", member.first_name, member.surname), realname: realname.clone(),
fresher, fresher,
}, },
) )
@ -177,6 +178,8 @@ pub(crate) async fn membership_3(
.title("Member verified via membership") .title("Member verified via membership")
.description(&m.user) .description(&m.user)
.field("Fresher", fresher, true) .field("Fresher", fresher, true)
.field("Nickname", nickname, true)
.field("Name", realname, true)
.timestamp(serenity::Timestamp::now()) .timestamp(serenity::Timestamp::now())
}) })
}) })