@@ -8,7 +8,7 @@ use axum::Form;
88use once_cell:: sync:: Lazy ;
99use serde:: Deserialize ;
1010use time:: { format_description, Date , Month } ;
11- use tracing:: { debug, info} ;
11+ use tracing:: { debug, info, span , Level } ;
1212use url;
1313use url:: Url ;
1414
@@ -115,6 +115,53 @@ pub async fn delete_some_account(
115115 Ok ( Redirect :: to ( "/me" ) )
116116}
117117
118+ #[ derive( Deserialize , Debug ) ]
119+ pub ( crate ) struct AddSomeAccountForm {
120+ bluesky : String ,
121+ button_bluesky : Option < String > ,
122+
123+ linkedin : String ,
124+ button_linkedin : Option < String > ,
125+
126+ x : String ,
127+ button_x : Option < String > ,
128+ }
129+
130+ pub async fn add_some_account (
131+ State ( app) : State < ServerImpl > ,
132+ user : SessionUser ,
133+ Form ( input) : Form < AddSomeAccountForm > ,
134+ ) -> Result < Redirect , AppError > {
135+ let _span = span ! ( Level :: INFO , "add_some_account" ) ;
136+
137+ info ! ( "input" = ?input, "Adding some account" ) ;
138+
139+ let mut network: Option < String > = None ;
140+ let mut nick: Option < String > = None ;
141+ let mut url: Option < String > = None ;
142+
143+ if input. button_bluesky . is_some ( ) {
144+ network = Some ( "bluesky" . to_string ( ) ) ;
145+ nick = Some ( input. bluesky . clone ( ) ) ;
146+ url = Some ( format ! ( "https://bsky.app/profile/{}" , input. bluesky. clone( ) ) . to_string ( ) ) ;
147+ } else if input. button_linkedin . is_some ( ) {
148+ network = Some ( "linkedin" . to_string ( ) ) ;
149+ url = Some ( input. linkedin ) ;
150+ } else if input. button_x . is_some ( ) && input. x . trim ( ) . len ( ) > 0 {
151+ network = Some ( "x" . to_string ( ) ) ;
152+ nick = Some ( input. x . clone ( ) ) ;
153+ url = Some ( format ! ( "https://x.com/{}" , input. x. clone( ) ) . to_string ( ) ) ;
154+ }
155+
156+ if let Some ( network) = network {
157+ app. employee_dao
158+ . add_some_account ( user. employee , network. to_string ( ) , nick, url)
159+ . await ?;
160+ }
161+
162+ Ok ( Redirect :: to ( "/me" ) )
163+ }
164+
118165#[ derive( Template ) ]
119166#[ template( path = "employee.html" ) ]
120167struct EmployeeTemplate {
0 commit comments