2024-04-21 13:15:18 +02:00
|
|
|
package stirling.software.SPDF.config;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
2025-02-23 21:02:46 +01:00
|
|
|
import org.springframework.context.annotation.Configuration;
|
2024-04-21 13:15:18 +02:00
|
|
|
import org.springframework.context.annotation.Scope;
|
|
|
|
|
2024-10-14 22:34:41 +01:00
|
|
|
import stirling.software.SPDF.config.interfaces.ShowAdminInterface;
|
2025-04-29 12:54:11 +01:00
|
|
|
import stirling.software.common.model.ApplicationProperties;
|
2024-04-21 13:15:18 +02:00
|
|
|
|
2025-02-23 21:02:46 +01:00
|
|
|
@Configuration
|
2024-04-21 13:15:18 +02:00
|
|
|
class AppUpdateService {
|
|
|
|
|
2024-12-24 09:52:53 +00:00
|
|
|
private final ApplicationProperties applicationProperties;
|
2024-04-21 13:15:18 +02:00
|
|
|
|
2024-12-24 09:52:53 +00:00
|
|
|
private final ShowAdminInterface showAdmin;
|
|
|
|
|
|
|
|
public AppUpdateService(
|
|
|
|
ApplicationProperties applicationProperties,
|
|
|
|
@Autowired(required = false) ShowAdminInterface showAdmin) {
|
|
|
|
this.applicationProperties = applicationProperties;
|
|
|
|
this.showAdmin = showAdmin;
|
|
|
|
}
|
2024-04-21 13:15:18 +02:00
|
|
|
|
|
|
|
@Bean(name = "shouldShow")
|
|
|
|
@Scope("request")
|
|
|
|
public boolean shouldShow() {
|
2024-09-13 16:42:38 +01:00
|
|
|
boolean showUpdate = applicationProperties.getSystem().isShowUpdate();
|
2024-04-21 13:15:18 +02:00
|
|
|
boolean showAdminResult = (showAdmin != null) ? showAdmin.getShowUpdateOnlyAdmins() : true;
|
|
|
|
return showUpdate && showAdminResult;
|
|
|
|
}
|
|
|
|
}
|