Make title optional. Trim title, sel if the message is too long.

This commit is contained in:
costin
2010-09-09 23:28:04 +00:00
parent 3867d258b1
commit 1e833c971f

View File

@@ -71,11 +71,21 @@ public class SendServlet extends HttpServlet {
String url = req.getParameter("url");
String title = req.getParameter("title");
if (url == null || title == null) {
if (url == null) {
resp.setStatus(400);
resp.getWriter().println(ERROR_STATUS + " (Must specify url and title parameters)");
return;
}
if (title == null || url.length() + title.length() + sel.length() >
1000) {
// Shorten the title - C2DM has a 1024 limit, some padding for keys
title = ""; // any better default ?
if (url.length() + sel.length() > 1000) {
sel = "";
}
// TODO: when we have history, save the url/title/sel in the history
// and send a pointer, have device fetch it.
}
String deviceId = req.getParameter("deviceId");
String deviceName = req.getParameter("deviceName");