@@ -61,35 +61,35 @@ pub async fn update_user(
6161 return Err ( bad_request ( "current user does not match requested user" ) ) ;
6262 }
6363
64- if let Some ( publish_notifications) = & user_update. user . publish_notifications {
65- if user. publish_notifications != * publish_notifications {
66- diesel :: update ( user )
67- . set ( users :: publish_notifications . eq ( * publish_notifications ) )
68- . execute ( & mut conn )
69- . await ? ;
70-
71- if !publish_notifications {
72- let email_address = user . verified_email ( & mut conn ) . await ? ;
73-
74- if let Some ( email_address ) = email_address {
75- let email = EmailMessage :: from_template (
76- "unsubscribe_notifications" ,
77- context ! {
78- user_name => user . gh_login ,
79- domain => state . emails . domain
80- } ,
81- ) ;
82-
83- match email {
84- Ok ( email) => {
85- if let Err ( error ) = state . emails . send ( & email_address , email ) . await {
86- warn ! (
87- "Failed to send publish notifications unsubscribe email to {email_address}: {error}"
88- ) ;
89- }
64+ if let Some ( publish_notifications) = & user_update. user . publish_notifications
65+ && user. publish_notifications != * publish_notifications
66+ {
67+ diesel :: update ( user )
68+ . set ( users :: publish_notifications . eq ( * publish_notifications ) )
69+ . execute ( & mut conn )
70+ . await ? ;
71+
72+ if !publish_notifications {
73+ let email_address = user . verified_email ( & mut conn ) . await ? ;
74+
75+ if let Some ( email_address ) = email_address {
76+ let email = EmailMessage :: from_template (
77+ "unsubscribe_notifications" ,
78+ context ! {
79+ user_name => user . gh_login ,
80+ domain => state . emails . domain
81+ } ,
82+ ) ;
83+
84+ match email {
85+ Ok ( email ) => {
86+ if let Err ( error ) = state . emails . send ( & email_address , email ) . await {
87+ warn ! (
88+ "Failed to send publish notifications unsubscribe email to {email_address}: {error}"
89+ ) ;
9090 }
91- Err ( error) => warn ! ( "Failed to render unsubscribe email template: {error}" ) ,
9291 }
92+ Err ( error) => warn ! ( "Failed to render unsubscribe email template: {error}" ) ,
9393 }
9494 }
9595 }
0 commit comments