use of im.actor.core.api.ApiOutPeer in project actor-platform by actorapp.
the class OwnTypingActor method onTyping.
@Verified
private void onTyping(Peer peer) {
if (ActorTime.currentTime() - lastTypingTime < TYPING_DELAY) {
return;
}
lastTypingTime = ActorTime.currentTime();
ApiOutPeer outPeer = buidOutPeer(peer);
if (outPeer == null) {
return;
}
cancelPrevRequest();
prevRid = request(new RequestTyping(outPeer, ApiTypingType.TEXT));
if (typingCancellable != null) {
typingCancellable.cancel();
typingCancellable = null;
}
typingCancellable = schedule(new AbortTyping(peer), TYPING_CANCEL_DELAY);
}
use of im.actor.core.api.ApiOutPeer in project actor-platform by actorapp.
the class OwnTypingActor method onAbortTyping.
private void onAbortTyping(Peer peer) {
ApiOutPeer outPeer = buidOutPeer(peer);
if (outPeer == null) {
return;
}
cancelPrevRequest();
prevRid = request(new RequestStopTyping(outPeer, ApiTypingType.TEXT));
}
use of im.actor.core.api.ApiOutPeer in project actor-platform by actorapp.
the class CursorReceiverActor method perform.
@Override
protected void perform(final Peer peer, final long date) {
ApiOutPeer outPeer = buidOutPeer(peer);
if (outPeer == null) {
return;
}
request(new RequestMessageReceived(outPeer, date), new RpcCallback<ResponseVoid>() {
@Override
public void onResult(ResponseVoid response) {
onCompleted(peer, date);
}
@Override
public void onError(RpcException e) {
CursorReceiverActor.this.onError(peer, date);
}
});
}
use of im.actor.core.api.ApiOutPeer 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.api.ApiOutPeer in project actor-platform by actorapp.
the class CursorReaderActor method perform.
@Override
protected void perform(final Peer peer, final long date) {
ApiOutPeer outPeer = buidOutPeer(peer);
if (outPeer == null) {
return;
}
request(new RequestMessageRead(outPeer, date), new RpcCallback<ResponseVoid>() {
@Override
public void onResult(ResponseVoid response) {
onCompleted(peer, date);
}
@Override
public void onError(RpcException e) {
CursorReaderActor.this.onError(peer, date);
}
});
}
Aggregations