File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -231,11 +231,19 @@ async fn fetch_devforum_data(
231231 roblox_username : & str ,
232232) -> anyhow:: Result < DevForumAPIResponse > {
233233 // Construct the DevForum API endpoint using the Roblox username and make the request.
234- let mut req = request. get ( construct_devforum_endpoint ( roblox_username) ) ;
235- if let Some ( cookie) = & * DEVFORUM_COOKIE {
236- req = req. header ( COOKIE , format ! ( "_t={cookie}" ) ) ;
234+ let mut res = request
235+ . get ( construct_devforum_endpoint ( roblox_username) )
236+ . send ( )
237+ . await ?;
238+
239+ if res. status ( ) . is_client_error ( ) && DEVFORUM_COOKIE . is_some ( ) {
240+ // Retry the request with the DevForum cookie if the first attempt fails
241+ res = request
242+ . get ( construct_devforum_endpoint ( roblox_username) )
243+ . header ( COOKIE , format ! ( "_t={}" , * DEVFORUM_COOKIE . as_ref( ) . unwrap( ) ) )
244+ . send ( )
245+ . await ?;
237246 }
238- let res = req. send ( ) . await . context ( "fetch devforum data" ) ?;
239247
240248 // Check if the response was successful and parse the JSON data.
241249 if res. status ( ) . is_success ( ) {
You can’t perform that action at this time.
0 commit comments