Skip to content

Commit

Permalink
Merge pull request #40 from SRGSSR/develop
Browse files Browse the repository at this point in the history
Optional update check can be disabled
  • Loading branch information
pyby authored Apr 9, 2020
2 parents 6676c7d + 12b7aee commit d72a7e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ A wide list of parameters are available.
* `DEEP_LINK_REFRESH_DELAY_MS` (optional, integer): Scheduled fixed delay before refreshing the deep link script cache. If not set, defaults is `300000`.
* `MAX_DEEP_LINK_REPORTS` (optional, integer): Maximum number of deep link reports in the database. If not set, defaults is `2500`.
* `DEEP_LINK_ENVIRONMENTS` (optional, string, multiple): List of `Environment`s to pull deep link dynamic informations. If not set, defaults is `PROD`.
* `UPDATE_CHECK_DISABLED` (optional, boolean): Disable checking if a recommended or required update is available, if set to `true`. If not set, defaults is `false`.

## API
* `urn` (string): an unique identifier.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>ch.srgssr</groupId>
<artifactId>playfff</artifactId>
<version>19</version>
<version>20</version>
<packaging>jar</packaging>

<name>pfff</name>
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/ch/srgssr/playfff/controller/UpdateController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ch.srgssr.playfff.model.UpdateResult;
import ch.srgssr.playfff.service.UpdateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
Expand All @@ -17,6 +18,14 @@
*/
@Controller
public class UpdateController {

private Boolean updateCheckDisabled;

public UpdateController(
@Value("${UPDATE_CHECK_DISABLED:false}") String updateCheckDisabledString) {
this.updateCheckDisabled = Boolean.valueOf(updateCheckDisabledString);
}

@Autowired
UpdateService updateService;

Expand Down Expand Up @@ -50,7 +59,7 @@ public ResponseEntity<Update> create(@RequestBody Update update) {
// Public API
@RequestMapping("/api/v1/update/check")
public ResponseEntity<UpdateResult> updateText(@RequestParam(value = "package") String packageName, @RequestParam(value = "version") String version) {
Update update = updateService.getUpdate(packageName, version);
Update update = (! updateCheckDisabled) ? updateService.getUpdate(packageName, version) : null;
return new ResponseEntity<>(new UpdateResult(update), HttpStatus.OK);
}
}

0 comments on commit d72a7e1

Please sign in to comment.