use of im.actor.core.entity.Message in project actor-platform by actorapp.
the class MessagesFragment method onCreateDisplayList.
protected BindedDisplayList<Message> onCreateDisplayList() {
BindedDisplayList<Message> displayList = messenger().getMessageDisplayList(peer);
if (displayList.getListProcessor() == null) {
displayList.setListProcessor(new ChatListProcessor(peer, this.getContext()));
}
notifyNewMessage(displayList);
return displayList;
}
use of im.actor.core.entity.Message in project actor-platform by actorapp.
the class MessagesModule method updateMessage.
public Promise<Void> updateMessage(final Peer peer, final String message, final long rid) {
context().getTypingModule().onMessageSent(peer);
ArrayList<Integer> mentions = new ArrayList<>();
TextContent content = TextContent.create(message, null, mentions);
if (peer.getPeerType() == PeerType.GROUP) {
Group group = groups().getValue(peer.getPeerId());
String lowText = message.toLowerCase();
for (GroupMember member : group.getMembers()) {
User user = users().getValue(member.getUid());
if (user.getNick() != null) {
String nick = "@" + user.getNick().toLowerCase();
// TODO: Better filtering
if (lowText.contains(nick + ":") || lowText.contains(nick + " ") || lowText.contains(" " + nick) || lowText.endsWith(nick) || lowText.equals(nick)) {
mentions.add(user.getUid());
}
}
}
}
ApiMessage editMessage = new ApiTextMessage(message, content.getMentions(), content.getTextMessageEx());
return buildOutPeer(peer).flatMap(apiOutPeer -> api(new RequestUpdateMessage(apiOutPeer, rid, editMessage))).flatMap(responseSeqDate -> updates().applyUpdate(responseSeqDate.getSeq(), responseSeqDate.getState(), new UpdateMessageContentChanged(new ApiPeer(peer.getPeerType().toApi(), peer.getPeerId()), rid, editMessage)));
}
use of im.actor.core.entity.Message in project actor-platform by actorapp.
the class MessagesProcessor method onDifferenceMessages.
@Verified
public Promise<Void> onDifferenceMessages(ApiPeer _peer, List<UpdateMessage> messages) {
Peer peer = convert(_peer);
ArrayList<Message> nMessages = new ArrayList<>();
for (UpdateMessage u : messages) {
AbsContent msgContent = AbsContent.fromMessage(u.getMessage());
nMessages.add(new Message(u.getRid(), u.getDate(), u.getDate(), u.getSenderUid(), myUid() == u.getSenderUid() ? MessageState.SENT : MessageState.UNKNOWN, msgContent));
}
return context().getMessagesModule().getRouter().onNewMessages(peer, nMessages);
}
use of im.actor.core.entity.Message in project actor-platform by actorapp.
the class RouterActor method onOutgoingSent.
private Promise<Void> onOutgoingSent(Peer peer, long rid, long date) {
Message msg = conversation(peer).getValue(rid);
// If we have pending message
if (msg != null && (msg.getMessageState() == MessageState.PENDING)) {
// Updating message
Message updatedMsg = msg.changeAllDate(date).changeState(MessageState.SENT);
conversation(peer).addOrUpdateItem(updatedMsg);
ConversationState state = conversationStates.getValue(peer.getUnuqueId());
conversationStates.addOrUpdateItem(state.changeOutSendDate(date));
updateChatState(peer);
// Notify dialogs
return getDialogsRouter().onMessage(peer, updatedMsg, -1);
} else {
return Promise.success(null);
}
}
use of im.actor.core.entity.Message in project actor-platform by actorapp.
the class RouterActor method onOutgoingError.
private Promise<Void> onOutgoingError(Peer peer, long rid) {
Message msg = conversation(peer).getValue(rid);
// If we have pending message
if (msg != null && (msg.getMessageState() == MessageState.PENDING)) {
// Updating message
Message updatedMsg = msg.changeState(MessageState.ERROR);
conversation(peer).addOrUpdateItem(updatedMsg);
updateChatState(peer);
}
return Promise.success(null);
}
Aggregations