File tree Expand file tree Collapse file tree 4 files changed +16
-4
lines changed
Expand file tree Collapse file tree 4 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ user=$1
1313topic=$( echo $2 | sed " s/'/%quote%/g" )
1414notice=$( echo $3 | sed " s/'/%quote%/g" )
1515type=$4
16+ priority=$5
1617
1718# Includes
1819# shellcheck source=/etc/hestiacp/hestia.conf
@@ -26,9 +27,10 @@ source_conf "$HESTIA/conf/hestia.conf"
2627# Verifications #
2728# ----------------------------------------------------------#
2829
29- check_args ' 2' " $# " ' USER TOPIC NOTICE [ TYPE]'
30- is_format_valid ' user' ' topic' ' notice'
30+ check_args ' 2' " $# " ' USER TOPIC NOTICE TYPE [PRIORITY ]'
31+ is_format_valid ' user' ' topic' ' notice' ' priority '
3132is_object_valid ' user' ' USER' " $user "
33+ is_common_format_valid " $type "
3234
3335# Perform verification if read-only mode is enabled
3436check_hestia_demo_mode
@@ -56,7 +58,7 @@ time=$(echo "$time_n_date" | cut -f 1 -d \ )
5658date=$( echo " $time_n_date " | cut -f 2 -d \ )
5759
5860# Concatenating string
59- str=" NID='$nid ' TOPIC='$topic ' NOTICE='$notice ' TYPE='$type '"
61+ str=" NID='$nid ' TOPIC='$topic ' NOTICE='$notice ' TYPE='$type ' PRIORITY=' $priority ' "
6062str=" $str ACK='no' TIME='$time ' DATE='$date '"
6163
6264# Adding to config
Original file line number Diff line number Diff line change @@ -30,14 +30,17 @@ json_list() {
3030 echo " {"
3131 while read str; do
3232 parse_object_kv_list " $str "
33+ if [ " $PRIORITY " = ' ' ]; then
34+ PRIORITY=' 0'
35+ fi
3336 TOPIC=$( echo " $TOPIC " | sed -e " s/%quote%/'/g" )
3437 NOTICE=$( echo " $NOTICE " | sed -e " s/%quote%/'/g" )
3538 echo -n ' "' $NID ' ": {
3639 "TOPIC": "' $TOPIC ' ",
3740 "NOTICE": "' ${NOTICE// \" / \' } ' ",
3841 "TYPE": "' $TYPE ' ",
3942 "ACK": "' $ACK ' ",
40- "TPL ": "' $TPL ' ",
43+ "PRIORITY ": "' $PRIORITY ' ",
4144 "TIME": "' $TIME ' ",
4245 "DATE": "' $DATE ' "
4346 }'
Original file line number Diff line number Diff line change @@ -1210,6 +1210,7 @@ is_format_valid() {
12101210 object) is_object_name_format_valid " $arg " ' object' ;;
12111211 package) is_object_format_valid " $arg " " $arg_name " ;;
12121212 password) is_password_format_valid " $arg " ;;
1213+ priority) is_int_format_valid $arg ;;
12131214 port) is_int_format_valid " $arg " ' port' ;;
12141215 port_ext) is_fw_port_format_valid " $arg " ;;
12151216 protocol) is_fw_protocol_format_valid " $arg " ;;
Original file line number Diff line number Diff line change 66 // Data
77 exec (HESTIA_CMD . "v-list-user-notifications $ user json " , $ output , $ return_var );
88 $ data = json_decode (implode ("" , $ output ), true );
9+
10+ function sort_priorty_id ($ element1 , $ element2 ) {
11+ return $ element2 ["PRIORITY " ] <=> $ element1 ["PRIORITY " ];
12+ }
913 $ data = array_reverse ($ data , true );
14+ usort ($ data , sort_priorty_id (...));
15+
1016 foreach ($ data as $ key => $ note ) {
1117 $ note ["ID " ] = $ key ;
1218 $ data [$ key ] = $ note ;
You can’t perform that action at this time.
0 commit comments