@@ -82,7 +82,7 @@ public Server(String[] args) {
8282 instance = this ;
8383
8484 String tempVersion = getInstance ().getClass ().getPackage ().getImplementationVersion ();
85- backendVersion = tempVersion == null ? "4 .0.11 " : tempVersion ;
85+ backendVersion = tempVersion == null ? "5 .0.0 " : tempVersion ;
8686 load (args );
8787 }
8888
@@ -178,32 +178,33 @@ public void load(String[] args) {
178178 Runtime .getRuntime ().addShutdownHook (new Thread (this ::onShutdown ));
179179
180180 ThreadUtil .createNewThread (x -> {
181- List < Recording > recordings = SQLSession .getSqlConnector ().getSqlWorker ().getEntityList (new Recording (), "FROM Recording" , null );
182-
183- if ( recordings != null && ! recordings . isEmpty () ) {
184- for ( Recording recording : recordings ) {
185- if ( recording . getCreation () < System . currentTimeMillis () - Duration . ofDays ( 1 ). toMillis ()) {
186- SQLSession . getSqlConnector (). getSqlWorker (). deleteEntity ( recording );
181+ SQLSession .getSqlConnector ().getSqlWorker ().getEntityList (new Recording (), "FROM Recording" , null ). subscribe ( recordings -> {
182+ if ( recordings != null && ! recordings . isEmpty ()) {
183+ for ( Recording recording : recordings ) {
184+ if ( recording . getCreation () < System . currentTimeMillis () - Duration . ofDays ( 1 ). toMillis () ) {
185+ SQLSession . getSqlConnector (). getSqlWorker (). deleteEntity ( recording ). block ();
186+ }
187187 }
188188 }
189- }
189+ });
190190
191- List < TwitchIntegration > twitchIntegrations = SQLSession .getSqlConnector ().getSqlWorker ().getEntityList (new TwitchIntegration (), "FROM TwitchIntegration" , null );
192- twitchIntegrations .forEach (twitchIntegration -> {
193- if (twitchIntegration .getLastUpdated ().getTime () + (twitchIntegration .getExpiresIn () * 1000L ) - Duration .ofMinutes (10 ).toMillis () <= System .currentTimeMillis ()) {
194- Optional <OAuth2Credential > cred = twitchIdentityProvider .refreshCredential (CustomOAuth2Util .convertToOriginal (twitchIntegration ));
191+ SQLSession .getSqlConnector ().getSqlWorker ().getEntityList (new TwitchIntegration (), "FROM TwitchIntegration" , null ). subscribe ( twitchIntegrations -> {
192+ twitchIntegrations .forEach (twitchIntegration -> {
193+ if (twitchIntegration .getLastUpdated ().getTime () + (twitchIntegration .getExpiresIn () * 1000L ) - Duration .ofMinutes (10 ).toMillis () <= System .currentTimeMillis ()) {
194+ Optional <OAuth2Credential > cred = twitchIdentityProvider .refreshCredential (CustomOAuth2Util .convertToOriginal (twitchIntegration ));
195195
196- credentialManager .getCredentials ().removeIf (credential -> {
197- if (credential instanceof CustomOAuth2Credential customOAuth2CredentialLocal ) {
198- return customOAuth2CredentialLocal .getDiscordId () == twitchIntegration .getUserId ();
199- }
200- return false ;
201- });
196+ credentialManager .getCredentials ().removeIf (credential -> {
197+ if (credential instanceof CustomOAuth2Credential customOAuth2CredentialLocal ) {
198+ return customOAuth2CredentialLocal .getDiscordId () == twitchIntegration .getUserId ();
199+ }
200+ return false ;
201+ });
202202
203- cred .ifPresent (oAuth2Credential -> credentialManager .addCredential ("twitch" , CustomOAuth2Util .convert (twitchIntegration .getUserId (), oAuth2Credential )));
204- }
203+ cred .ifPresent (oAuth2Credential -> credentialManager .addCredential ("twitch" , CustomOAuth2Util .convert (twitchIntegration .getUserId (), oAuth2Credential )));
204+ }
205+ });
206+ credentialManager .save ();
205207 });
206- credentialManager .save ();
207208 }, throwable -> log .error ("Failed running Data clear Thread" , throwable ), Duration .ofMinutes (5 ), true , false );
208209 }
209210
0 commit comments