@@ -139,12 +139,25 @@ async fn post_gi_wishes_import(
139139 . finish ( ) ;
140140
141141 let mut uid = 0 ;
142+ let mut import_error = None ;
142143
143144 for gacha_type in [ 100 , 200 , 301 , 302 , 500 ] {
144- let gacha_log: GachaLog = reqwest:: get ( format ! ( "{url}&gacha_type={gacha_type}&end_id=0" ) )
145- . await ?
146- . json ( )
147- . await ?;
145+ // User-provided wish URLs can point at expired or malformed upstream responses.
146+ // Keep those as import status errors instead of bubbling reqwest decode errors.
147+ let gacha_log = match reqwest:: get ( format ! ( "{url}&gacha_type={gacha_type}&end_id=0" ) ) . await
148+ {
149+ Ok ( response) => match response. json :: < GachaLog > ( ) . await {
150+ Ok ( gacha_log) => gacha_log,
151+ Err ( _) => {
152+ import_error = Some ( "Unable to fetch wish history" . to_string ( ) ) ;
153+ continue ;
154+ }
155+ } ,
156+ Err ( _) => {
157+ import_error = Some ( "Unable to fetch wish history" . to_string ( ) ) ;
158+ continue ;
159+ }
160+ } ;
148161
149162 if let Some ( entry) = gacha_log. data . list . first ( ) {
150163 uid = entry. uid . parse ( ) ?;
@@ -160,24 +173,30 @@ async fn post_gi_wishes_import(
160173 character : 0 ,
161174 weapon : 0 ,
162175 chronicled : 0 ,
163- status : Status :: Error ( "No data" . to_string ( ) ) ,
176+ status : Status :: Error ( import_error . unwrap_or_else ( || "No data" . to_string ( ) ) ) ,
164177 } ) ) ;
165178
166179 wishes_import_infos. lock ( ) . await . insert ( uid, info. clone ( ) ) ;
167180
168181 return Ok ( HttpResponse :: Ok ( ) . json ( WishesImport { uid } ) ) ;
169182 }
170183
171- let name = reqwest:: Client :: new ( )
184+ // Enka is only used to populate a display name. The import can continue without it.
185+ let name = match reqwest:: Client :: new ( )
172186 . get ( format ! ( "https://enka.network/api/uid/{uid}?info" ) )
173187 . header ( header:: USER_AGENT , "stardb" )
174188 . send ( )
175- . await ?
176- . json :: < serde_json:: Value > ( )
177- . await ?[ "playerInfo" ] [ "nickname" ]
178- . as_str ( )
179- . unwrap_or_default ( )
180- . to_string ( ) ;
189+ . await
190+ {
191+ Ok ( response) => match response. json :: < serde_json:: Value > ( ) . await {
192+ Ok ( json) => json[ "playerInfo" ] [ "nickname" ]
193+ . as_str ( )
194+ . unwrap_or_default ( )
195+ . to_string ( ) ,
196+ Err ( _) => String :: new ( ) ,
197+ } ,
198+ Err ( _) => String :: new ( ) ,
199+ } ;
181200
182201 database:: gi:: profiles:: set ( & database:: gi:: profiles:: DbProfile { uid, name } , & pool) . await ?;
183202 if let Ok ( Some ( username) ) = session. get :: < String > ( "username" ) {
0 commit comments