From ea33ee5ea7eb5513e731e9ffaa966082f3927d07 Mon Sep 17 00:00:00 2001
From: Johanna Dorothea Reichmann <transcaffeine@finallycoffee.eu>
Date: Sun, 21 Nov 2021 08:29:12 +0100
Subject: [PATCH] feat(apps): allow checking app integrity

---
 roles/apps/defaults/main.yml | 2 ++
 roles/apps/tasks/main.yml    | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/roles/apps/defaults/main.yml b/roles/apps/defaults/main.yml
index 9f2c35c..2a08210 100644
--- a/roles/apps/defaults/main.yml
+++ b/roles/apps/defaults/main.yml
@@ -3,3 +3,5 @@
 nextcloud_container_name: nextcloud
 nextcloud_apps: []
 nextcloud_run_user: nextcloud
+
+nextcloud_apps_check_integrity: false
diff --git a/roles/apps/tasks/main.yml b/roles/apps/tasks/main.yml
index 3934a1b..a12ed89 100644
--- a/roles/apps/tasks/main.yml
+++ b/roles/apps/tasks/main.yml
@@ -48,3 +48,12 @@
   loop: "{{ nextcloud_apps }}"
   notify:
     - restart-nextcloud
+
+- name: Ensure app integrity
+  community.docker.docker_container_exec:
+    container: "{{ nextcloud_container_name }}"
+    command: "php occ integrity:check-app {{ item.name }}"
+    user: "{{ nextcloud_run_user }}"
+    tty: yes
+  when: nextcloud_apps_check_integrity and item.state|default('present') in ['latest', 'present']
+  loop: "{{ nextcloud_apps }}"