Search in sources :

Example 1 with RequestLoadFullGroups

use of im.actor.core.api.rpc.RequestLoadFullGroups in project actor-platform by actorapp.

the class GroupRouter method onRequestLoadFullGroup.

private void onRequestLoadFullGroup(int gid) {
    if (requestedFullGroups.contains(gid)) {
        return;
    }
    requestedFullGroups.add(gid);
    freeze();
    groups().getValueAsync(gid).flatMap(new Function<Group, Promise<Group>>() {

        @Override
        public Promise<Group> apply(Group group) {
            if (!group.isHaveExtension()) {
                ArrayList<ApiGroupOutPeer> groups = new ArrayList<>();
                groups.add(new ApiGroupOutPeer(gid, group.getAccessHash()));
                return api(new RequestLoadFullGroups(groups)).map(r -> group.updateExt(r.getGroups().get(0)));
            } else {
                return Promise.failure(new RuntimeException("Already loaded"));
            }
        }
    }).then(r -> groups().addOrUpdateItem(r)).after((r, e) -> unfreeze());
}
Also used : ModuleContext(im.actor.core.modules.ModuleContext) RouterApplyGroups(im.actor.core.modules.groups.router.entity.RouterApplyGroups) Promise(im.actor.runtime.promise.Promise) UpdateGroupAvatarChanged(im.actor.core.api.updates.UpdateGroupAvatarChanged) RouterLoadFullGroup(im.actor.core.modules.groups.router.entity.RouterLoadFullGroup) UpdateGroupFullPermissionsChanged(im.actor.core.api.updates.UpdateGroupFullPermissionsChanged) RouterFetchMissingGroups(im.actor.core.modules.groups.router.entity.RouterFetchMissingGroups) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) UpdateGroupMemberChanged(im.actor.core.api.updates.UpdateGroupMemberChanged) ApiMapValue(im.actor.core.api.ApiMapValue) PromisesArray(im.actor.runtime.promise.PromisesArray) UpdateGroupMemberAdminChanged(im.actor.core.api.updates.UpdateGroupMemberAdminChanged) UpdateGroupTitleChanged(im.actor.core.api.updates.UpdateGroupTitleChanged) UpdateGroupTopicChanged(im.actor.core.api.updates.UpdateGroupTopicChanged) RouterInt(im.actor.core.modules.messaging.router.RouterInt) RouterGroupUpdate(im.actor.core.modules.groups.router.entity.RouterGroupUpdate) UpdateGroupMemberDiff(im.actor.core.api.updates.UpdateGroupMemberDiff) Tuple2(im.actor.runtime.function.Tuple2) ApiGroup(im.actor.core.api.ApiGroup) UpdateGroupDeleted(im.actor.core.api.updates.UpdateGroupDeleted) Void(im.actor.runtime.actors.messages.Void) UpdateGroupOwnerChanged(im.actor.core.api.updates.UpdateGroupOwnerChanged) Verified(im.actor.runtime.annotations.Verified) ApiMember(im.actor.core.api.ApiMember) Group(im.actor.core.entity.Group) UpdateGroupAboutChanged(im.actor.core.api.updates.UpdateGroupAboutChanged) UpdateGroupFullExtChanged(im.actor.core.api.updates.UpdateGroupFullExtChanged) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ModuleActor(im.actor.core.modules.ModuleActor) UpdateGroupPermissionsChanged(im.actor.core.api.updates.UpdateGroupPermissionsChanged) UpdateGroupMembersCountChanged(im.actor.core.api.updates.UpdateGroupMembersCountChanged) UpdateGroupMembersBecameAsync(im.actor.core.api.updates.UpdateGroupMembersBecameAsync) ApiGroupOutPeer(im.actor.core.api.ApiGroupOutPeer) ApiAvatar(im.actor.core.api.ApiAvatar) UpdateGroupHistoryShared(im.actor.core.api.updates.UpdateGroupHistoryShared) UpdateGroupShortNameChanged(im.actor.core.api.updates.UpdateGroupShortNameChanged) Function(im.actor.runtime.function.Function) RequestLoadFullGroups(im.actor.core.api.rpc.RequestLoadFullGroups) UpdateGroupExtChanged(im.actor.core.api.updates.UpdateGroupExtChanged) Update(im.actor.core.network.parser.Update) UpdateGroupMembersUpdated(im.actor.core.api.updates.UpdateGroupMembersUpdated) RouterLoadFullGroup(im.actor.core.modules.groups.router.entity.RouterLoadFullGroup) ApiGroup(im.actor.core.api.ApiGroup) Group(im.actor.core.entity.Group) Promise(im.actor.runtime.promise.Promise) RequestLoadFullGroups(im.actor.core.api.rpc.RequestLoadFullGroups) ArrayList(java.util.ArrayList) ApiGroupOutPeer(im.actor.core.api.ApiGroupOutPeer)

Aggregations

ApiAvatar (im.actor.core.api.ApiAvatar)1 ApiGroup (im.actor.core.api.ApiGroup)1 ApiGroupOutPeer (im.actor.core.api.ApiGroupOutPeer)1 ApiMapValue (im.actor.core.api.ApiMapValue)1 ApiMember (im.actor.core.api.ApiMember)1 RequestLoadFullGroups (im.actor.core.api.rpc.RequestLoadFullGroups)1 UpdateGroupAboutChanged (im.actor.core.api.updates.UpdateGroupAboutChanged)1 UpdateGroupAvatarChanged (im.actor.core.api.updates.UpdateGroupAvatarChanged)1 UpdateGroupDeleted (im.actor.core.api.updates.UpdateGroupDeleted)1 UpdateGroupExtChanged (im.actor.core.api.updates.UpdateGroupExtChanged)1 UpdateGroupFullExtChanged (im.actor.core.api.updates.UpdateGroupFullExtChanged)1 UpdateGroupFullPermissionsChanged (im.actor.core.api.updates.UpdateGroupFullPermissionsChanged)1 UpdateGroupHistoryShared (im.actor.core.api.updates.UpdateGroupHistoryShared)1 UpdateGroupMemberAdminChanged (im.actor.core.api.updates.UpdateGroupMemberAdminChanged)1 UpdateGroupMemberChanged (im.actor.core.api.updates.UpdateGroupMemberChanged)1 UpdateGroupMemberDiff (im.actor.core.api.updates.UpdateGroupMemberDiff)1 UpdateGroupMembersBecameAsync (im.actor.core.api.updates.UpdateGroupMembersBecameAsync)1 UpdateGroupMembersCountChanged (im.actor.core.api.updates.UpdateGroupMembersCountChanged)1 UpdateGroupMembersUpdated (im.actor.core.api.updates.UpdateGroupMembersUpdated)1 UpdateGroupOwnerChanged (im.actor.core.api.updates.UpdateGroupOwnerChanged)1