update notify_admin_gui to cache the admin user (#1502)
Co-authored-by: Daniel Hansson <github@hanssonit.se>
This commit is contained in:
Родитель
3cecc203f1
Коммит
f732671d5b
25
lib.sh
25
lib.sh
|
@ -1395,6 +1395,9 @@ esac
|
|||
#
|
||||
# occ_command_no_check notification:generate -l "$2" "$admin" "$1"
|
||||
notify_admin_gui() {
|
||||
local NC_USERS
|
||||
local user
|
||||
local admin
|
||||
if ! is_app_enabled notifications
|
||||
then
|
||||
print_text_in_color "$IRed" "The notifications app isn't enabled - unable to send notifications"
|
||||
|
@ -1402,13 +1405,23 @@ then
|
|||
fi
|
||||
|
||||
print_text_in_color "$ICyan" "Posting notification to users that are admins, this might take a while..."
|
||||
occ_command_no_check user:list | sed 's|^ - ||g' | sed 's|:.*||' | while read -r admin
|
||||
if [ -z "${NC_ADMIN_USER[*]}" ]
|
||||
then
|
||||
NC_USERS=$(occ_command_no_check user:list | sed 's|^ - ||g' | sed 's|:.*||')
|
||||
mapfile -t NC_USERS <<< "$NC_USERS"
|
||||
for user in "${NC_USERS[@]}"
|
||||
do
|
||||
if occ_command_no_check user:info "$user" | cut -d "-" -f2 | grep -x -q " admin"
|
||||
then
|
||||
NC_ADMIN_USER+=("$user")
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
for admin in "${NC_ADMIN_USER[@]}"
|
||||
do
|
||||
if occ_command_no_check user:info "$admin" | cut -d "-" -f2 | grep -x -q " admin"
|
||||
then
|
||||
print_text_in_color "$IGreen" "Posting '$1' to: $admin"
|
||||
occ_command_no_check notification:generate -l "$2" "$admin" "$1"
|
||||
fi
|
||||
print_text_in_color "$IGreen" "Posting '$1' to: $admin"
|
||||
occ_command_no_check notification:generate -l "$2" "$admin" "$1"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
@ -398,6 +398,9 @@ then
|
|||
fi
|
||||
clear
|
||||
|
||||
# We need to unset the cached admin-user since we have changed its name
|
||||
unset NC_ADMIN_USER
|
||||
|
||||
msg_box "Well done, you have now finished most of the setup.
|
||||
|
||||
There are still some stuff left to do, but they are automated so sit back and relax! :)"
|
||||
|
|
Загрузка…
Ссылка в новой задаче