use of org.roof.im.chain.handler.SessionVo in project roof-im by madfroglx.
the class CreateSessionVoNode method doNode.
public NodeResult<List<SessionVo>> doNode(Request request, List<Session> sessions) {
// TODO session缓存
if (sessions == null || sessions.size() == 0) {
return new NodeResult<>(NO_INCOMPLETE_SESSION);
}
List<SessionVo> sessionVos = new ArrayList<>();
String username = request.getUsername();
for (Session session : sessions) {
String receiver;
if (StringUtils.equals(session.getReceiver(), username)) {
receiver = session.getSender();
} else {
receiver = session.getReceiver();
}
String userState = ImConstant.OFFLINE;
List<UserState> userStates = userStateService.getStates(receiver);
if (userStates != null) {
for (UserState state : userStates) {
if (StringUtils.equals(state.getState(), ImConstant.ONLINE)) {
userState = ImConstant.ONLINE;
}
}
}
SessionVo sessionVo = new SessionVo();
sessionVo.setSessionId(session.getId());
sessionVo.setReceiver(receiver);
sessionVo.setStartTime(session.getStartTime());
sessionVo.setEndTime(session.getEndTime());
sessionVo.setRealEndTime(session.getRealEndTime());
sessionVo.setState(session.getState());
sessionVo.setUserState(userState);
sessionVos.add(sessionVo);
}
NodeResult<List<SessionVo>> result = new NodeResult<>(QUERY_INCOMPLETE_SESSION_SUCCESS);
result.setData(sessionVos);
return result;
}