iosobjective-cchatquickbloxq-municate

How to remove dialog from dialog list Using QMServicesManager in case of Group and Public chat?


This question is extension to my previous question with new requirements. This is My Previous question.

So My New Requirement is :

Now If I want to delete group chat how I should handle this ? If I use the same method inside it we are passing forAllUsers as "NO" which is hard coded. written inside QMChatServices.m

- (void)deleteDialogWithID:(NSString *)dialogId completion:(void (^)(QBResponse *))completion {

    NSParameterAssert(dialogId);

    __weak __typeof(self)weakSelf = self;

    [QBRequest deleteDialogsWithIDs:[NSSet setWithObject:dialogId] forAllUsers:NO successBlock:^(QBResponse *response, NSArray *deletedObjectsIDs, NSArray *notFoundObjectsIDs, NSArray *wrongPermissionsObjectsIDs) {
        //
        [weakSelf.dialogsMemoryStorage deleteChatDialogWithID:dialogId];
        [weakSelf.messagesMemoryStorage deleteMessagesWithDialogID:dialogId];

        if ([weakSelf.multicastDelegate respondsToSelector:@selector(chatService:didDeleteChatDialogWithIDFromMemoryStorage:)]) {
            [weakSelf.multicastDelegate chatService:weakSelf didDeleteChatDialogWithIDFromMemoryStorage:dialogId];
        }

        [weakSelf.loadedAllMessages removeObjectsForKeys:deletedObjectsIDs];

        if (completion) {
            completion(response);
        }
    } errorBlock:^(QBResponse *response) {
        //
        if (response.status == QBResponseStatusCodeNotFound || response.status == 403) {
            [weakSelf.dialogsMemoryStorage deleteChatDialogWithID:dialogId];

            if ([weakSelf.multicastDelegate respondsToSelector:@selector(chatService:didDeleteChatDialogWithIDFromMemoryStorage:)]) {
                [weakSelf.multicastDelegate chatService:weakSelf didDeleteChatDialogWithIDFromMemoryStorage:dialogId];
            }
        }
        else {

            [weakSelf.serviceManager handleErrorResponse:response];
        }

        if (completion) {
            completion(response);
        }
    }];
}

So Now my doubt is..

Question 1 : What if we want to delete dialog for all the users. Question 2 : Lets say there are 3 users. User1 , User2 and User3. Now User1 has created group with User2 and User3.

So how this method is useful for all the different 3 users. I mean What happens if User1 uses

[ServicesManager.instance.chatService deleteDialogWithID:dialog.ID completion:nil];

and what happens if User2 and User3 uses the same method.

Weather it works as exit from the dialog or deleting dialog. I'm little confused how this method works for different users in case of group and public chat.

Question 3 : Is there any other way to exit from the group chat ? I hope it is clear !!


Solution

    1. You right, there is no interface for deleting dialog for all users right now. But keep in mind that only the owner of group dialog (its creator) can delete it. And owner cannot be changed, even if he will left the dialog. We will consider adding such method in a near future, but for now you can easily modify it for your needs (you are welcome to fork from our services repository).

    2. If any of the user uses this method - he will be out of that group (by server), but group itself will still exist with other members. But other members will only know about left users when they will redownload dialog from REST. So in order to notify them live, we are sending XMPP notifications before leaving, like this one

    3. Pretty much what I said in 2. Notifying users live about our leaving and deleting dialog through REST (QBRequest) request.