package com.juick.api; import com.juick.User; import com.juick.json.UserSerializer; import com.juick.server.PMQueries; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.sql.Connection; import java.util.List; /** * * @author ugnich */ public class Others { Connection sql; UserSerializer userSerializer = new UserSerializer(); public Others(Connection sql) { this.sql = sql; } public void doGetGroupsPMs(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException { int cnt = 5; try { String cntStr = request.getParameter("cnt"); cnt = Integer.parseInt(cntStr); if (cnt < 3) { cnt = 3; } if (cnt > 10) { cnt = 10; } } catch (Exception e) { } List lastconv = PMQueries.getPMLastConversationsUsers(sql, vuid, cnt); if (lastconv != null && !lastconv.isEmpty()) { String json = "{\"pms\":" + userSerializer.serializeList(lastconv) + "}"; Main.replyJSON(request, response, json); } else { response.sendError(404); } } }