use of im.actor.runtime.actors.messages.Void in project actor-platform by actorapp.
the class JsFacade method favoriteChat.
@UsedByApp
public JsPromise favoriteChat(final JsPeer peer) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.favouriteChat(peer.convert()).start(new CommandCallback<Void>() {
@Override
public void onResult(Void res) {
Log.d(TAG, "favouriteChat:result");
resolve();
}
@Override
public void onError(Exception e) {
Log.d(TAG, "favouriteChat:error");
reject(e.getMessage());
}
});
}
});
}
use of im.actor.runtime.actors.messages.Void in project actor-platform by actorapp.
the class JsFacade method clearChat.
@UsedByApp
public JsPromise clearChat(final JsPeer peer) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.clearChat(peer.convert()).start(new CommandCallback<Void>() {
@Override
public void onResult(Void res) {
Log.d(TAG, "clearChat:result");
resolve();
}
@Override
public void onError(Exception e) {
Log.d(TAG, "clearChat:error");
reject(e.getMessage());
}
});
}
});
}
use of im.actor.runtime.actors.messages.Void 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.runtime.actors.messages.Void in project actor-platform by actorapp.
the class RouterActor method onMessageReadByMe.
private Promise<Void> onMessageReadByMe(Peer peer, long date, int counter) {
ConversationState state = conversationStates.getValue(peer.getUnuqueId());
if (state.getInReadDate() >= date) {
return Promise.success(null);
}
state = state.changeCounter(counter).changeInReadDate(date);
conversationStates.addOrUpdateItem(state);
Promise<Void> res = getDialogsRouter().onCounterChanged(peer, counter);
notifyActiveDialogsVM();
context().getNotificationsModule().onOwnRead(peer, date);
return res;
}
use of im.actor.runtime.actors.messages.Void in project actor-platform by actorapp.
the class SequenceHandlerActor method onDifferenceUpdate.
private Promise<Void> onDifferenceUpdate(@NotNull List<ApiUser> users, @NotNull List<ApiGroup> groups, @NotNull List<ApiUserOutPeer> userOutPeers, @NotNull List<ApiGroupOutPeer> groupOutPeers, @NotNull List<Update> updates) {
if (updates.size() > 0) {
String command = "Difference updates:";
for (Update u : updates) {
command += "\n| " + u;
}
Log.d(TAG, command);
}
beginUpdates();
// Related Users
Promise<Void> currentPromise = updates().applyRelatedData(users, groups);
// Loading missing peers
currentPromise = currentPromise.chain(v -> updates().loadRequiredPeers(userOutPeers, groupOutPeers));
// Apply Diff
long applyStart = im.actor.runtime.Runtime.getCurrentTime();
currentPromise = currentPromise.chain(v -> processor.applyDifferenceUpdate(updates)).then(v -> {
Log.d(TAG, "Difference applied in " + (im.actor.runtime.Runtime.getCurrentTime() - applyStart) + " ms");
endUpdates();
});
return currentPromise;
}
Aggregations