183
183
if (cfg.play_notify_form) {
184
184
app.post("/play-notify-form", function(req, resp) {
185
resp.type('text/plain')
186
if (!req.body.data||!req.body.nick) {
187
resp.send(400, "invalid/empty fields\n")
192
data = JSON.parse(req.body.data)
194
resp.send(400, "data is not JSON\n")
185
if (!req.body.message||!req.body.nick) {
186
resp.redirect("/?error=invalid or empty fields in form")
192
"message": req.body.message,
193
"to": req.body.nick.toLowerCase()
199
if (req.body.enable) {
201
"summary": "The website says:",
202
"body": req.body.message,
203
"actions": ["appid://com.ubuntu.developer.ralsina.hello/hello/current-user-version"]
205
if (req.body.popup) {card["popup"] = true}
206
if (req.body.persist) {card["persist"] = true}
207
data["notification"]["card"] = card
208
if (req.body.sound) {data["notification"]["sound"] = true}
209
if (req.body.vibrate) {data["notification"]["vibrate"] = {"duration": 200}}
210
if (req.body.counter) {data["notification"]["emblem-counter"] = {
211
"count": Math.floor(req.body.counter),
197
215
doNotify(true, req.body.nick, data, function() {
198
resp.send(200, 'OK\n')
199
217
}, function() { // not found
200
resp.send(400, "unknown nick\n")
218
resp.redirect("/?error=unknown nick")