use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class MessageManager method preparepublishNewMessagesResponse.
public static ChatResponse<ResultNewMessage> preparepublishNewMessagesResponse(MessageVO messageVO, long threadId) {
ChatResponse<ResultNewMessage> chatResponse = new ChatResponse<>();
chatResponse.setUniqueId(messageVO.getUniqueId());
chatResponse.setHasError(false);
chatResponse.setErrorCode(0);
chatResponse.setErrorMessage("");
ResultNewMessage resultNewMessage = new ResultNewMessage();
resultNewMessage.setMessageVO(messageVO);
resultNewMessage.setThreadId(threadId);
chatResponse.setResult(resultNewMessage);
chatResponse.setSubjectId(threadId);
return chatResponse;
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class MessageManager method prepareSeenMessageListResponse.
public static ChatResponse<ResultParticipant> prepareSeenMessageListResponse(ChatMessage chatMessage, long offset) {
ChatResponse<ResultParticipant> chatResponse = new ChatResponse<>();
chatResponse.setUniqueId(chatMessage.getUniqueId());
ResultParticipant resultParticipant = new ResultParticipant();
List<Participant> participants = App.getGson().fromJson(chatMessage.getContent(), new TypeToken<ArrayList<Participant>>() {
}.getType());
resultParticipant.setParticipants(participants);
resultParticipant.setContentCount(chatMessage.getContentCount());
resultParticipant.setNextOffset(offset + participants.size());
resultParticipant.setContentCount(chatMessage.getContentCount());
if (participants.size() + offset < chatMessage.getContentCount()) {
resultParticipant.setHasNext(true);
} else {
resultParticipant.setHasNext(false);
}
chatResponse.setResult(resultParticipant);
return chatResponse;
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class PingManager method handleOnPingStatusSent.
public static ChatResponse<StatusPingResult> handleOnPingStatusSent(ChatMessage chatMessage) {
StatusPingResult result = new StatusPingResult();
ChatResponse<StatusPingResult> response = new ChatResponse<>();
response.setResult(result);
response.setCache(false);
response.setHasError(false);
response.setUniqueId(chatMessage.getUniqueId());
return response;
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class UserRoles method handleOnGetUserRolesFromCache.
public static ChatResponse<ResultCurrentUserRoles> handleOnGetUserRolesFromCache(String uniqueId, RequestGetUserRoles request, CacheUserRoles cacheUserRole) {
ArrayList<String> roles = new ArrayList<>(cacheUserRole.getRole());
ResultCurrentUserRoles result = new ResultCurrentUserRoles();
result.setRoles(roles);
ChatResponse<ResultCurrentUserRoles> response = new ChatResponse<>();
response.setResult(result);
response.setUniqueId(uniqueId);
response.setSubjectId(request.getThreadId());
response.setCache(true);
return response;
}
use of com.fanap.podchat.model.ChatResponse in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method getThreadHistory.
public Observable<ChatResponse<ResultHistory>> getThreadHistory(@NonNull SearchSystemMetadataRequest request) {
return rx.Observable.create(subscriber -> {
List<MessageVO> messageVOS = new ArrayList<>();
List<CacheMessageVO> cacheMessageVOS;
long offset = request.getOffset();
long count = request.getCount();
String order = request.getOrder();
offset = offset >= 0 ? offset : 0;
count = count > 0 ? count : 50;
if (Util.isNullOrEmpty(order)) {
order = "desc";
}
String rawQuery = "SELECT * FROM CacheMessageVO WHERE threadVoId =" + request.getMessageThreadId();
// rawQuery = rawQuery + " AND system_metadata_" + request.getMetadataCriteria().getField() + " >= " + request.getMetadataCriteria().getGte();
long contentCount = messageDao.getHistoryContentCount(new SimpleSQLiteQuery(rawQuery.replaceFirst("SELECT \\* ", "SELECT COUNT(ID) ")));
rawQuery = addOrderAndLimitAndOffset(offset, count, order, rawQuery);
SupportSQLiteQuery sqLiteQuery = new SimpleSQLiteQuery(rawQuery);
cacheMessageVOS = messageDao.getRawHistory(sqLiteQuery);
prepareMessageVOs(messageVOS, cacheMessageVOS);
List<Sending> sendingList = getAllSendingQueueByThreadId(request.getMessageThreadId());
List<Uploading> uploadingList = getAllUploadingQueueByThreadId(request.getMessageThreadId());
List<Failed> failedList = getAllWaitQueueCacheByThreadId(request.getMessageThreadId());
ChatResponse<ResultHistory> chatResponse = new ChatResponse<>();
chatResponse.setCache(true);
ResultHistory resultHistory = new ResultHistory();
resultHistory.setHistory(messageVOS);
resultHistory.setNextOffset(request.getOffset() + messageVOS.size());
resultHistory.setContentCount(contentCount);
if (messageVOS.size() + request.getOffset() < contentCount) {
resultHistory.setHasNext(true);
} else {
resultHistory.setHasNext(false);
}
resultHistory.setHistory(messageVOS);
resultHistory.setSending(sendingList);
resultHistory.setUploadingQueue(uploadingList);
resultHistory.setFailed(failedList);
chatResponse.setErrorCode(0);
chatResponse.setHasError(false);
chatResponse.setErrorMessage("");
chatResponse.setResult(resultHistory);
chatResponse.setCache(true);
chatResponse.setSubjectId(request.getMessageThreadId());
subscriber.onNext(chatResponse);
});
}
Aggregations