Search in sources :

Example 6 with ApiGroup

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

the class Group method editMembersCount.

public Group editMembersCount(int membersCount) {
    ApiGroup w = getWrapped();
    ApiGroup res = new ApiGroup(w.getId(), w.getAccessHash(), w.getTitle(), w.getAvatar(), membersCount, w.isMember(), w.isHidden(), w.getGroupType(), w.getPermissions(), w.isDeleted(), w.getExt());
    res.setUnmappedObjects(w.getUnmappedObjects());
    return new Group(res, getWrappedExt());
}
Also used : ApiGroup(im.actor.core.api.ApiGroup) ApiGroup(im.actor.core.api.ApiGroup)

Example 7 with ApiGroup

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

the class Group method editIsDeleted.

public Group editIsDeleted(boolean isDeleted) {
    ApiGroup w = getWrapped();
    ApiGroup res = new ApiGroup(w.getId(), w.getAccessHash(), w.getTitle(), w.getAvatar(), w.getMembersCount(), w.isMember(), w.isHidden(), w.getGroupType(), w.getPermissions(), isDeleted, w.getExt());
    res.setUnmappedObjects(w.getUnmappedObjects());
    return new Group(res, getWrappedExt());
}
Also used : ApiGroup(im.actor.core.api.ApiGroup) ApiGroup(im.actor.core.api.ApiGroup)

Example 8 with ApiGroup

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

the class Group method editMembers.

public Group editMembers(List<ApiMember> added, List<Integer> removed, int count) {
    ApiGroupFull fullExt = null;
    if (getWrappedExt() != null) {
        ApiGroupFull e = getWrappedExt();
        ArrayList<ApiMember> nMembers = new ArrayList<>(e.getMembers());
        // Remove members
        for (Integer i : removed) {
            for (ApiMember m : nMembers) {
                if (m.getUid() == i) {
                    nMembers.remove(m);
                    break;
                }
            }
        }
        // Adding members
        for (ApiMember a : added) {
            for (ApiMember m : nMembers) {
                if (m.getUid() == a.getUid()) {
                    nMembers.remove(m);
                    break;
                }
            }
            nMembers.add(a);
        }
        fullExt = new ApiGroupFull(e.getId(), e.getCreateDate(), e.getOwnerUid(), nMembers, e.getTheme(), e.getAbout(), e.getExt(), e.isAsyncMembers(), e.isSharedHistory(), e.getShortName(), e.getPermissions());
        fullExt.setUnmappedObjects(e.getUnmappedObjects());
    }
    ApiGroup w = getWrapped();
    ApiGroup res = new ApiGroup(w.getId(), w.getAccessHash(), w.getTitle(), w.getAvatar(), count, w.isMember(), w.isHidden(), w.getGroupType(), w.getPermissions(), w.isDeleted(), w.getExt());
    return new Group(res, fullExt);
}
Also used : ApiGroup(im.actor.core.api.ApiGroup) ApiGroup(im.actor.core.api.ApiGroup) ArrayList(java.util.ArrayList) ApiGroupFull(im.actor.core.api.ApiGroupFull) ApiMember(im.actor.core.api.ApiMember)

Example 9 with ApiGroup

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

the class Group method editMembers.

//
// Members
//
public Group editMembers(List<ApiMember> members) {
    ApiGroupFull fullExt = null;
    if (getWrappedExt() != null) {
        ApiGroupFull e = getWrappedExt();
        fullExt = new ApiGroupFull(e.getId(), e.getCreateDate(), e.getOwnerUid(), members, e.getTheme(), e.getAbout(), e.getExt(), e.isAsyncMembers(), e.isSharedHistory(), e.getShortName(), e.getPermissions());
        fullExt.setUnmappedObjects(e.getUnmappedObjects());
    }
    ApiGroup w = getWrapped();
    ApiGroup res = new ApiGroup(w.getId(), w.getAccessHash(), w.getTitle(), w.getAvatar(), members.size(), w.isMember(), w.isHidden(), w.getGroupType(), w.getPermissions(), w.isDeleted(), w.getExt());
    return new Group(res, fullExt);
}
Also used : ApiGroup(im.actor.core.api.ApiGroup) ApiGroup(im.actor.core.api.ApiGroup) ApiGroupFull(im.actor.core.api.ApiGroupFull)

Example 10 with ApiGroup

use of im.actor.core.api.ApiGroup 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;
}
Also used : HandlerDifferenceUpdates(im.actor.core.modules.sequence.internal.HandlerDifferenceUpdates) ModuleContext(im.actor.core.modules.ModuleContext) ActorCreator(im.actor.runtime.actors.ActorCreator) Promise(im.actor.runtime.promise.Promise) ApiUser(im.actor.core.api.ApiUser) PromiseFunc(im.actor.runtime.promise.PromiseFunc) ArrayList(java.util.ArrayList) UpdateProcessor(im.actor.core.modules.sequence.processor.UpdateProcessor) HandlerRelatedResponse(im.actor.core.modules.sequence.internal.HandlerRelatedResponse) PromisesArray(im.actor.runtime.promise.PromisesArray) HandlerWeakUpdate(im.actor.core.modules.sequence.internal.HandlerWeakUpdate) RequestGetReferencedEntitites(im.actor.core.api.rpc.RequestGetReferencedEntitites) ApiGroup(im.actor.core.api.ApiGroup) Void(im.actor.runtime.actors.messages.Void) Runtime(im.actor.runtime.Runtime) Constructor(im.actor.runtime.function.Constructor) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ModuleActor(im.actor.core.modules.ModuleActor) HandlerSeqUpdate(im.actor.core.modules.sequence.internal.HandlerSeqUpdate) ApiGroupOutPeer(im.actor.core.api.ApiGroupOutPeer) ApiUserOutPeer(im.actor.core.api.ApiUserOutPeer) Log(im.actor.runtime.Log) NotNull(org.jetbrains.annotations.NotNull) Function(im.actor.runtime.function.Function) Update(im.actor.core.network.parser.Update) Promises(im.actor.runtime.promise.Promises) HandlerWeakUpdate(im.actor.core.modules.sequence.internal.HandlerWeakUpdate) HandlerSeqUpdate(im.actor.core.modules.sequence.internal.HandlerSeqUpdate) Update(im.actor.core.network.parser.Update) Void(im.actor.runtime.actors.messages.Void)

Aggregations

ApiGroup (im.actor.core.api.ApiGroup)10 ApiGroupFull (im.actor.core.api.ApiGroupFull)2 ArrayList (java.util.ArrayList)2 ApiGroupOutPeer (im.actor.core.api.ApiGroupOutPeer)1 ApiMember (im.actor.core.api.ApiMember)1 ApiUser (im.actor.core.api.ApiUser)1 ApiUserOutPeer (im.actor.core.api.ApiUserOutPeer)1 RequestGetReferencedEntitites (im.actor.core.api.rpc.RequestGetReferencedEntitites)1 ModuleActor (im.actor.core.modules.ModuleActor)1 ModuleContext (im.actor.core.modules.ModuleContext)1 HandlerDifferenceUpdates (im.actor.core.modules.sequence.internal.HandlerDifferenceUpdates)1 HandlerRelatedResponse (im.actor.core.modules.sequence.internal.HandlerRelatedResponse)1 HandlerSeqUpdate (im.actor.core.modules.sequence.internal.HandlerSeqUpdate)1 HandlerWeakUpdate (im.actor.core.modules.sequence.internal.HandlerWeakUpdate)1 UpdateProcessor (im.actor.core.modules.sequence.processor.UpdateProcessor)1 Update (im.actor.core.network.parser.Update)1 Log (im.actor.runtime.Log)1 Runtime (im.actor.runtime.Runtime)1 ActorCreator (im.actor.runtime.actors.ActorCreator)1 Void (im.actor.runtime.actors.messages.Void)1