@@ -288,8 +288,6 @@ def plaintext_refresh_token(self) -> str:
288288 return token
289289
290290 def save (self , * args : Any , ** kwargs : Any ) -> None :
291- from sentry import options
292-
293291 self .hashed_token = hashlib .sha256 (self .token .encode ()).hexdigest ()
294292
295293 if self .refresh_token :
@@ -303,17 +301,9 @@ def save(self, *args: Any, **kwargs: Any) -> None:
303301 token_last_characters = self .token [- 4 :]
304302 self .token_last_characters = token_last_characters
305303
306- has_async_flush = options .get ("api-token-async-flush" )
307- if has_async_flush :
308- self .default_flush = False
309-
310- result = super ().save (* args , ** kwargs )
311-
312- return result
304+ return super ().save (* args , ** kwargs )
313305
314306 def update (self , * args : Any , ** kwargs : Any ) -> int :
315- from sentry import options
316-
317307 # if the token or refresh_token was updated, we need to
318308 # re-calculate the hashed values
319309 if "token" in kwargs :
@@ -327,12 +317,7 @@ def update(self, *args: Any, **kwargs: Any) -> int:
327317 if "token" in kwargs :
328318 kwargs ["token_last_characters" ] = kwargs ["token" ][- 4 :]
329319
330- has_async_flush = options .get ("api-token-async-flush" )
331- if has_async_flush :
332- self .default_flush = False
333- result = super ().update (* args , ** kwargs )
334-
335- return result
320+ return super ().update (* args , ** kwargs )
336321
337322 def outbox_region_names (self ) -> Collection [str ]:
338323 return list (find_all_region_names ())
@@ -576,6 +561,17 @@ def organization_id(self) -> int | None:
576561
577562 return installation .organization_id
578563
564+ @property
565+ def default_flush (self ) -> bool :
566+ from sentry import options
567+
568+ has_async_flush = options .get ("api-token-async-flush" )
569+ return not has_async_flush
570+
571+ @default_flush .setter
572+ def default_flush (self , value : bool ) -> None :
573+ self .default_flush = value
574+
579575
580576def is_api_token_auth (auth : object ) -> bool :
581577 """:returns True when an API token is hitting the API."""
0 commit comments