1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00

fix request bug

This commit is contained in:
lxsang 2018-10-10 14:35:00 +02:00
parent 0ad5eaa138
commit 6098e1b0ee
3 changed files with 8 additions and 8 deletions

View File

@ -17,10 +17,10 @@ function result(obj)
end
function ServiceController:sendmail()
if not REQUEST.query.json then
if not REQUEST.json then
fail("unknown request")
end
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
local to = "xsang.le@gmail.com"
local from = "From: " .. rq.email .. "\n"
local suject = "Subject: " .. rq.subject .. "\n"
@ -40,10 +40,10 @@ function ServiceController:sendmail()
end
function ServiceController:subscribe()
if not REQUEST.query.json then
if not REQUEST.json then
fail("unknown request")
end
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
-- check if email is exist
local data = self.subscribers:find({exp = {["="] = {email = rq.email}}})
if data and #data > 0 then

View File

@ -1,8 +1,8 @@
if not REQUEST.query.json then
if not REQUEST.json then
fail("unknown request")
end
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
local to = "xsang.le@gmail.com"
local from = "From: "..rq.email.."\n"
local suject = "Subject: "..rq.subject.."\n"

View File

@ -1,8 +1,8 @@
if not REQUEST.query.json then
if not REQUEST.json then
fail("unknown request")
end
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
local sample = {name = "toto", email = "toto@mail.fr"}
local db = require("db.model").get("mrsang","subscribers",sample)