crystal-gauntlet/src/endpoints/comments/addProfileComment.cr

25 lines
695 B
Crystal
Raw Normal View History

2022-12-31 19:29:51 +01:00
require "uri"
include CrystalGauntlet
CrystalGauntlet.endpoints["/uploadGJAccComment20.php"] = ->(context : HTTP::Server::Context): String {
params = URI::Params.parse(context.request.body.not_nil!.gets_to_end)
2023-01-02 11:59:37 +01:00
LOG.debug { params.inspect }
2022-12-31 19:29:51 +01:00
user_id, account_id = Accounts.auth(params)
if !(user_id && account_id)
return "-1"
end
comment = params["comment"]?
2023-01-04 13:05:27 +01:00
if comment && !comment.blank?
2023-01-05 20:39:24 +01:00
comment_value = Base64.decode_string(comment)[0..140-1]
next_id = IDs.get_next_id("account_comments")
2022-12-31 19:29:51 +01:00
DATABASE.exec("insert into account_comments (id, account_id, comment) values (?, ?, ?)", next_id, account_id, comment_value)
return "1"
else
return "-1"
end
}