File tree Expand file tree Collapse file tree 2 files changed +24
-24
lines changed
Expand file tree Collapse file tree 2 files changed +24
-24
lines changed Original file line number Diff line number Diff line change @@ -226,23 +226,23 @@ async def __call__(
226226 )
227227 if bot is not None :
228228 bot_token = bot .bot_token
229+ if bot .bot_refresh_token is not None :
230+ # Token rotation
231+ if self .token_rotator is None :
232+ raise BoltError (self ._config_error_message )
233+ refreshed = await self .token_rotator .perform_bot_token_rotation (
234+ bot = bot ,
235+ token_rotation_expiration_minutes = self .token_rotation_expiration_minutes ,
236+ )
237+ if refreshed is not None :
238+ await self .installation_store .async_save_bot (refreshed )
239+ bot_token = refreshed .bot_token
240+
229241 except NotImplementedError as _ :
230242 self .find_bot_available = False
231243 except Exception as e :
232244 self .logger .info (f"Failed to call find_bot method: { e } " )
233245
234- if bot .bot_refresh_token is not None :
235- # Token rotation
236- if self .token_rotator is None :
237- raise BoltError (self ._config_error_message )
238- refreshed = await self .token_rotator .perform_bot_token_rotation (
239- bot = bot ,
240- token_rotation_expiration_minutes = self .token_rotation_expiration_minutes ,
241- )
242- if refreshed is not None :
243- await self .installation_store .async_save_bot (refreshed )
244- bot_token = refreshed .bot_token
245-
246246 token : Optional [str ] = bot_token or user_token
247247 if token is None :
248248 # No valid token was found
Original file line number Diff line number Diff line change @@ -223,23 +223,23 @@ def __call__(
223223 )
224224 if bot is not None :
225225 bot_token = bot .bot_token
226+ if bot .bot_refresh_token is not None :
227+ # Token rotation
228+ if self .token_rotator is None :
229+ raise BoltError (self ._config_error_message )
230+ refreshed = self .token_rotator .perform_bot_token_rotation (
231+ bot = bot ,
232+ minutes_before_expiration = self .token_rotation_expiration_minutes ,
233+ )
234+ if refreshed is not None :
235+ self .installation_store .save_bot (refreshed )
236+ bot_token = refreshed .bot_token
237+
226238 except NotImplementedError as _ :
227239 self .find_bot_available = False
228240 except Exception as e :
229241 self .logger .info (f"Failed to call find_bot method: { e } " )
230242
231- if bot .bot_refresh_token is not None :
232- # Token rotation
233- if self .token_rotator is None :
234- raise BoltError (self ._config_error_message )
235- refreshed = self .token_rotator .perform_bot_token_rotation (
236- bot = bot ,
237- minutes_before_expiration = self .token_rotation_expiration_minutes ,
238- )
239- if refreshed is not None :
240- self .installation_store .save_bot (refreshed )
241- bot_token = refreshed .bot_token
242-
243243 token : Optional [str ] = bot_token or user_token
244244 if token is None :
245245 # No valid token was found
You can’t perform that action at this time.
0 commit comments