@@ -21,7 +21,9 @@ impl QPayMember {
2121 & format ! ( "SELECT discord_username, origination FROM {table} WHERE email = $1" ) ,
2222 & [ & self . email ] ,
2323 ) {
24- Ok ( row) if row_missing ( & row, "discord_username" ) => InDb :: NeedsDiscord ,
24+ Ok ( row) if self . discord ( ) . is_some ( ) && row_missing ( & row, "discord_username" ) => {
25+ InDb :: NeedsDiscord
26+ }
2527 Ok ( row) if self . origination ( ) . is_some ( ) && row_missing ( & row, "origination" ) => {
2628 InDb :: NeedsOrigination
2729 }
@@ -36,24 +38,17 @@ impl QPayMember {
3638 db : & mut postgres:: Client ,
3739 table : & str ,
3840 ) -> Result < Option < CrobotWebook > > {
39- match self
40- . responses
41- . get ( "Do you have a discord username? If so, what is it?" )
42- . and_then ( |input| match input. is_empty ( ) {
43- true => None ,
44- false => Some ( input) ,
45- } ) {
46- None => Ok ( None ) ,
47- Some ( username) => {
48- let query = format ! ( "UPDATE {table} SET discord_username = $1 WHERE email = $2" , ) ;
49-
50- let _result = db
51- . query ( & query, & [ username, & self . email ] )
52- . with_context ( || "Updating" ) ?;
53-
54- Ok ( Some ( CrobotWebook :: new ( username. to_owned ( ) ) ) )
55- }
56- }
41+ let Some ( username) = self . discord ( ) else {
42+ return Ok ( None ) ;
43+ } ;
44+
45+ let query = format ! ( "UPDATE {table} SET discord_username = $1 WHERE email = $2" , ) ;
46+
47+ let _result = db
48+ . query ( & query, & [ & username, & self . email ] )
49+ . with_context ( || "Updating" ) ?;
50+
51+ Ok ( Some ( CrobotWebook :: new ( username. to_owned ( ) ) ) )
5752 }
5853
5954 pub fn create_membership ( & self , db : & mut postgres:: Client , table : & str ) -> Result < ( ) > {
0 commit comments