Mercurial > prosody-modules
comparison mod_adhoc_cmd_admin/mod_adhoc_cmd_admin.lua @ 248:db1b4c6089b6
mod_adhoc_cmd_admin: Check if announcement fields are filled (Thanks Zash)
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Thu, 26 Aug 2010 22:59:45 +0200 |
parents | 161067865850 |
children | 67f03b7786af |
comparison
equal
deleted
inserted
replaced
247:fbddb9db1c82 | 248:db1b4c6089b6 |
---|---|
444 return { status = "canceled" }; | 444 return { status = "canceled" }; |
445 end | 445 end |
446 | 446 |
447 local fields = announce_layout:data(data.form); | 447 local fields = announce_layout:data(data.form); |
448 | 448 |
449 if #fields.announcement == 0 then | 449 if (not fields.announcement) or (#fields.announcement == 0) then |
450 return { status = "completed", error = { message = "Please specify some announcement text." } }; | 450 return { status = "completed", error = { message = "Please specify some announcement text." } }; |
451 end | 451 end |
452 | 452 |
453 module:log("info", "Sending server announcement to all online users"); | 453 module:log("info", "Sending server announcement to all online users"); |
454 local message = st.message({type = "headline"}, fields.announcement):up() | 454 local message = st.message({type = "headline"}, fields.announcement):up() |
471 return { status = "canceled" }; | 471 return { status = "canceled" }; |
472 end | 472 end |
473 | 473 |
474 local fields = shut_down_service_layout:data(data.form); | 474 local fields = shut_down_service_layout:data(data.form); |
475 | 475 |
476 if #fields.announcement > 0 then | 476 if fields.announcement and #fields.announcement > 0 then |
477 local message = st.message({type = "headline"}, fields.announcement):up() | 477 local message = st.message({type = "headline"}, fields.announcement):up() |
478 :tag("subject"):text("Server is shutting down"); | 478 :tag("subject"):text("Server is shutting down"); |
479 send_to_online(message); | 479 send_to_online(message); |
480 end | 480 end |
481 | 481 |