Skip to content

Commit 40d516e

Browse files
committed
Performance: Do not load notification list on every pageload
1 parent d07ca55 commit 40d516e

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ All notable changes to this project will be documented in this file.
3131
- Added a confirmation dialog when deleting user logs (/list/log/)
3232
- Fixed issue with sftp-jail not working for users restored from backups
3333
- SecImprove: Improved input validation in multiple cli scripts
34+
- Performance: Do not load complete notifications list on every page load, reduced load time from over 1sec to under 100ms
3435

3536
## [1.0.5] - 2019-08-06 - Hotfix
3637
### Bugfixes

bin/v-list-user

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ json_list() {
7474
"U_CRON_JOBS": "'$U_CRON_JOBS'",
7575
"U_BACKUPS": "'$U_BACKUPS'",
7676
"LANGUAGE": "'$LANGUAGE'",
77+
"NOTIFICATIONS": "'$NOTIFICATIONS'",
7778
"TIME": "'$TIME'",
7879
"DATE": "'$DATE'"
7980
}
@@ -120,7 +121,7 @@ plain_list() {
120121
echo -ne "$U_WEB_DOMAINS\t$U_WEB_SSL\t$U_WEB_ALIASES\t"
121122
echo -ne "$U_DNS_DOMAINS\t$U_DNS_RECORDS\t$U_MAIL_DOMAINS\t"
122123
echo -ne "$U_MAIL_DKIM\t$U_MAIL_ACCOUNTS\t$U_DATABASES\t"
123-
echo -e "'$U_CRON_JOBS\t$U_BACKUPS\t$LANGUAGE\t$TIME\t$DATE"
124+
echo -e "$U_CRON_JOBS\t$U_BACKUPS\t$LANGUAGE\t$TIME\t$DATE"
124125
}
125126

126127
# CSV list function
@@ -135,7 +136,7 @@ csv_list() {
135136
echo -n "U_DISK_WEB,U_DISK_MAIL,U_DISK_DB,U_BANDWIDTH,U_WEB_DOMAINS,"
136137
echo -n "U_WEB_SSL,U_WEB_ALIASES,U_DNS_DOMAINS,U_DNS_RECORDS,"
137138
echo -n "U_MAIL_DOMAINS,U_MAIL_DKIM,U_MAIL_ACCOUNTS,U_DATABASES"
138-
echo "U_CRON_JOBS,U_BACKUPS,LANGUAGE,TIME,DATE"
139+
echo "U_CRON_JOBS,U_BACKUPS,LANGUAGE,NOTIFICATIONS,TIME,DATE"
139140
echo -n "$USER,\"$FNAME\",\"$LNAME\",$PACKAGE,$WEB_TEMPLATE,"
140141
echo -n "$BACKEND_TEMPLATE,$PROXY_TEMPLATE,$DNS_TEMPLATE,$WEB_DOMAINS,"
141142
echo -n "$WEB_ALIASES,$DNS_DOMAINS,$DNS_RECORDS,$MAIL_DOMAINS,"
@@ -147,7 +148,7 @@ csv_list() {
147148
echo -n "$U_DISK_MAIL,$U_DISK_DB,$U_BANDWIDTH,$U_WEB_DOMAINS,$U_WEB_SSL,"
148149
echo -n "$U_WEB_ALIASES,$U_DNS_DOMAINS,$U_DNS_RECORDS,$U_MAIL_DOMAINS,"
149150
echo -n "$U_MAIL_DKIM,$U_MAIL_ACCOUNTS,$U_DATABASES,$U_CRON_JOBS,"
150-
echo "$U_BACKUPS,$LANGUAGE,$TIME,$DATE"
151+
echo "$U_BACKUPS,$LANGUAGE,$NOTIFICATIONS,$TIME,$DATE"
151152
}
152153

153154

web/inc/main.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function render_page($user, $TAB, $page) {
167167

168168
function top_panel($user, $TAB) {
169169
global $panel;
170-
$command = HESTIA_CMD."v-list-user '".$user."' 'json'";
170+
$command = HESTIA_CMD."v-list-user ".escapeshellarg($user)." 'json'";
171171
exec ($command, $output, $return_var);
172172
if ( $return_var > 0 ) {
173173
header("Location: /error/");
@@ -176,20 +176,6 @@ function top_panel($user, $TAB) {
176176
$panel = json_decode(implode('', $output), true);
177177
unset($output);
178178

179-
180-
// getting notifications
181-
$command = HESTIA_CMD."v-list-user-notifications '".$user."' 'json'";
182-
exec ($command, $output, $return_var);
183-
$notifications = json_decode(implode('', $output), true);
184-
foreach($notifications as $message){
185-
if($message['ACK'] == 'no'){
186-
$panel[$user]['NOTIFICATIONS'] = 'yes';
187-
break;
188-
}
189-
}
190-
unset($output);
191-
192-
193179
if ( $user == 'admin' ) {
194180
include(dirname(__FILE__).'/../templates/admin/panel.html');
195181
} else {

0 commit comments

Comments
 (0)