Search in sources :

Example 1 with Verified

use of im.actor.runtime.annotations.Verified 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);
}
Also used : RequestTyping(im.actor.core.api.rpc.RequestTyping) ApiOutPeer(im.actor.core.api.ApiOutPeer) Verified(im.actor.runtime.annotations.Verified)

Example 2 with Verified

use of im.actor.runtime.annotations.Verified in project actor-platform by actorapp.

the class UserRouter method checkIsInPhoneBook.

@Verified
protected Promise<Void> checkIsInPhoneBook(User user) {
    if (!config().isEnableOnClientPrivacy()) {
        return Promise.success(null);
    }
    Log.d("ON_CLIENT_PRIVACY", "checking " + user.getName() + " is in phone book");
    return getPhoneBook().flatMap(new Function<List<PhoneBookContact>, Promise<Void>>() {

        @Override
        public Promise<Void> apply(List<PhoneBookContact> phoneBookContacts) {
            return new Promise<Void>(resolver -> {
                List<ContactRecord> userRecords = user.getRecords();
                Log.d("ON_CLIENT_PRIVACY", "phonebook have " + phoneBookContacts.size() + " records");
                Log.d("ON_CLIENT_PRIVACY", "user have " + userRecords.size() + " records");
                outer: for (ContactRecord record : userRecords) {
                    for (PhoneBookContact phoneBookContact : phoneBookContacts) {
                        for (PhoneBookPhone phone1 : phoneBookContact.getPhones()) {
                            if (record.getRecordType() == ContactRecordType.PHONE) {
                                if (record.getRecordData().equals(phone1.getNumber() + "")) {
                                    context().getContactsModule().markInPhoneBook(user.getUid());
                                    getUserVM(user.getUid()).isInPhoneBook().change(true);
                                    Log.d("ON_CLIENT_PRIVACY", "in record book!");
                                    break outer;
                                }
                            }
                        }
                        for (PhoneBookEmail email : phoneBookContact.getEmails()) {
                            if (record.getRecordType() == ContactRecordType.EMAIL) {
                                if (record.getRecordData().equals(email.getEmail())) {
                                    context().getContactsModule().markInPhoneBook(user.getUid());
                                    getUserVM(user.getUid()).isInPhoneBook().change(true);
                                    Log.d("ON_CLIENT_PRIVACY", "in record book!");
                                    break outer;
                                }
                            }
                        }
                    }
                }
                Log.d("ON_CLIENT_PRIVACY", "finish check");
                resolver.result(null);
            });
        }
    });
}
Also used : ModuleContext(im.actor.core.modules.ModuleContext) ContactRecord(im.actor.core.entity.ContactRecord) PhoneBookContact(im.actor.core.entity.PhoneBookContact) ApiUser(im.actor.core.api.ApiUser) UpdateUserContactsChanged(im.actor.core.api.updates.UpdateUserContactsChanged) ApiMapValue(im.actor.core.api.ApiMapValue) ApiBotCommand(im.actor.core.api.ApiBotCommand) PhoneBookEmail(im.actor.core.entity.PhoneBookEmail) PromisesArray(im.actor.runtime.promise.PromisesArray) RouterLoadFullUser(im.actor.core.modules.users.router.entity.RouterLoadFullUser) UpdateContactRegistered(im.actor.core.api.updates.UpdateContactRegistered) UpdateUserNameChanged(im.actor.core.api.updates.UpdateUserNameChanged) ContactRecordType(im.actor.core.entity.ContactRecordType) Tuple2(im.actor.runtime.function.Tuple2) UpdateUserBlocked(im.actor.core.api.updates.UpdateUserBlocked) Void(im.actor.runtime.actors.messages.Void) Verified(im.actor.runtime.annotations.Verified) UserPhone(im.actor.core.viewmodel.UserPhone) ResponseLoadFullUsers(im.actor.core.api.rpc.ResponseLoadFullUsers) UpdateUserAvatarChanged(im.actor.core.api.updates.UpdateUserAvatarChanged) List(java.util.List) UpdateUserAboutChanged(im.actor.core.api.updates.UpdateUserAboutChanged) ModuleActor(im.actor.core.modules.ModuleActor) ArrayListUserPhone(im.actor.core.viewmodel.generics.ArrayListUserPhone) UpdateUserFullExtChanged(im.actor.core.api.updates.UpdateUserFullExtChanged) UserEmail(im.actor.core.viewmodel.UserEmail) Peer(im.actor.core.entity.Peer) UpdateUserExtChanged(im.actor.core.api.updates.UpdateUserExtChanged) MessageState(im.actor.core.entity.MessageState) Message(im.actor.core.entity.Message) ApiUserOutPeer(im.actor.core.api.ApiUserOutPeer) ApiAvatar(im.actor.core.api.ApiAvatar) ApiContactRecord(im.actor.core.api.ApiContactRecord) UpdateUserTimeZoneChanged(im.actor.core.api.updates.UpdateUserTimeZoneChanged) Function(im.actor.runtime.function.Function) ServiceUserRegistered(im.actor.core.entity.content.ServiceUserRegistered) PhoneBookProvider(im.actor.core.providers.PhoneBookProvider) Promise(im.actor.runtime.promise.Promise) UpdateUserBotCommandsChanged(im.actor.core.api.updates.UpdateUserBotCommandsChanged) UpdateUserNickChanged(im.actor.core.api.updates.UpdateUserNickChanged) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) User(im.actor.core.entity.User) UpdateUserLocalNameChanged(im.actor.core.api.updates.UpdateUserLocalNameChanged) ArrayListUserEmail(im.actor.core.viewmodel.generics.ArrayListUserEmail) JavaUtil.equalsE(im.actor.core.util.JavaUtil.equalsE) UpdateUserUnblocked(im.actor.core.api.updates.UpdateUserUnblocked) RequestLoadFullUsers(im.actor.core.api.rpc.RequestLoadFullUsers) ContactsSyncActor(im.actor.core.modules.contacts.ContactsSyncActor) UserVM(im.actor.core.viewmodel.UserVM) RouterFetchMissingUsers(im.actor.core.modules.users.router.entity.RouterFetchMissingUsers) BookImportStorage(im.actor.core.modules.contacts.entity.BookImportStorage) RouterApplyUsers(im.actor.core.modules.users.router.entity.RouterApplyUsers) UpdateUserPreferredLanguagesChanged(im.actor.core.api.updates.UpdateUserPreferredLanguagesChanged) Log(im.actor.runtime.Log) PhoneBookPhone(im.actor.core.entity.PhoneBookPhone) Update(im.actor.core.network.parser.Update) RouterUserUpdate(im.actor.core.modules.users.router.entity.RouterUserUpdate) Promise(im.actor.runtime.promise.Promise) PhoneBookContact(im.actor.core.entity.PhoneBookContact) List(java.util.List) ArrayList(java.util.ArrayList) PhoneBookEmail(im.actor.core.entity.PhoneBookEmail) Void(im.actor.runtime.actors.messages.Void) ContactRecord(im.actor.core.entity.ContactRecord) ApiContactRecord(im.actor.core.api.ApiContactRecord) PhoneBookPhone(im.actor.core.entity.PhoneBookPhone) Verified(im.actor.runtime.annotations.Verified)

Example 3 with Verified

use of im.actor.runtime.annotations.Verified in project actor-platform by actorapp.

the class DialogsActor method onMessageContentChanged.

@Verified
private Promise<Void> onMessageContentChanged(Peer peer, long rid, AbsContent content) {
    Dialog dialog = dialogs.getValue(peer.getUnuqueId());
    // If message is on top
    if (dialog != null && dialog.getRid() == rid) {
        ContentDescription description = ContentDescription.fromContent(content);
        addOrUpdateItem(new DialogBuilder(dialog).setText(description.getText()).setRelatedUid(description.getRelatedUser()).setMessageType(description.getContentType()).createDialog());
    }
    return Promise.success(null);
}
Also used : Dialog(im.actor.core.entity.Dialog) ContentDescription(im.actor.core.entity.ContentDescription) DialogBuilder(im.actor.core.entity.DialogBuilder) Verified(im.actor.runtime.annotations.Verified)

Example 4 with Verified

use of im.actor.runtime.annotations.Verified in project actor-platform by actorapp.

the class DialogsActor method onGroupChanged.

@Verified
private Promise<Void> onGroupChanged(Group group) {
    Dialog dialog = dialogs.getValue(group.peer().getUnuqueId());
    if (dialog != null) {
        // Ignore if nothing changed
        if (dialog.getDialogTitle().equals(group.getTitle()) && equalsE(dialog.getDialogAvatar(), group.getAvatar())) {
            return Promise.success(null);
        }
        // Update dialog peer info
        Dialog updated = dialog.editPeerInfo(group.getTitle(), group.getAvatar());
        addOrUpdateItem(updated);
        updateSearch(updated);
    }
    return Promise.success(null);
}
Also used : Dialog(im.actor.core.entity.Dialog) Verified(im.actor.runtime.annotations.Verified)

Example 5 with Verified

use of im.actor.runtime.annotations.Verified in project actor-platform by actorapp.

the class PresenceActor method onGroupOnline.

@Verified
private void onGroupOnline(int gid, int count, long updateDate) {
    // Log.d(TAG, "onGroupOnline  #" + gid + " " + count + " at " + updateDate);
    if (lastGidState.containsKey(gid) && lastGidState.get(gid) >= updateDate) {
        // Log.d(TAG, "onGroupOnline:ignored - too old");
        return;
    }
    lastGidState.put(gid, updateDate);
    // Log.d(TAG, "onGroupOnline:updated");
    GroupVM vm = getGroupVM(gid);
    if (vm != null) {
        vm.getPresence().change(count);
    }
}
Also used : GroupVM(im.actor.core.viewmodel.GroupVM) Verified(im.actor.runtime.annotations.Verified)

Aggregations

Verified (im.actor.runtime.annotations.Verified)14 Dialog (im.actor.core.entity.Dialog)5 UserVM (im.actor.core.viewmodel.UserVM)4 ContentDescription (im.actor.core.entity.ContentDescription)3 DialogBuilder (im.actor.core.entity.DialogBuilder)3 Message (im.actor.core.entity.Message)3 Peer (im.actor.core.entity.Peer)3 UserPresence (im.actor.core.viewmodel.UserPresence)3 ArrayList (java.util.ArrayList)3 ApiAvatar (im.actor.core.api.ApiAvatar)2 ApiBotCommand (im.actor.core.api.ApiBotCommand)2 ApiContactRecord (im.actor.core.api.ApiContactRecord)2 ApiMapValue (im.actor.core.api.ApiMapValue)2 ApiUser (im.actor.core.api.ApiUser)2 ApiUserOutPeer (im.actor.core.api.ApiUserOutPeer)2 RequestLoadFullUsers (im.actor.core.api.rpc.RequestLoadFullUsers)2 ResponseLoadFullUsers (im.actor.core.api.rpc.ResponseLoadFullUsers)2 UpdateContactRegistered (im.actor.core.api.updates.UpdateContactRegistered)2 UpdateUserAboutChanged (im.actor.core.api.updates.UpdateUserAboutChanged)2 UpdateUserAvatarChanged (im.actor.core.api.updates.UpdateUserAvatarChanged)2