/ SDKs / Unreal
SDKs
Chat SDKs Unreal v3
Chat SDKs Unreal
Chat SDKs
Unreal
Version 3

Filter group channels by users

Copy link

To filter channels by users, use the SetUsersExactFilter() or SetUsersIncludeFilter(). Let's assume the ID of the current user is Jane and the user is a member of two group channels:

  • channelA consists of Katherine, Jane, and Julia.
  • channelB consists of Katherine, Jane, Julia, and Tyler.

An ExactFilter returns the list of channels containing exactly the queried users.

SBDGroupChannelListQuery* query = SBDGroupChannel::CreateMyGroupChannelListQuery();

std::vector<SBDUser> users;
users.push_back(USER_1);    // L"Katherine"
users.push_back(USER_2);    // L"Jane"
users.push_back(USER_3);    // L"Julia"

query->SetUsersExactFilter(users);
query->LoadNextPage([](std::vector<SBDGroupChannel*> groupChannels, SBDError* error) {
    if (error != nullptr) {
        // Handle error.
        return;
    }

    // Only channelA is returned in a result list through the groupChannels parameter of the callback function.
});

An IncludeFilter returns channels where the userIDs are included. This method can return one of two different results, based on the parameter SBDGroupChannelListQueryType.

SBDGroupChannelListQuery* query = SBDGroupChannel::CreateMyGroupChannelListQuery();

std::vector<SBDUser> users;
users.push_back(USER_2);    // L"Jane"
users.push_back(USER_3);    // L"Julia"
users.push_back(USER_4);    // L"Tyler"

query->SetUsersIncludeFilter(users, SBDGroupChannelListQueryType::And);
query->LoadNextPage([](std::vector<SBDGroupChannel*> groupChannels, SBDError* error) {
    if (error != nullptr) {
        // Handle error.
        return;
    }

    // Only channelB including {'Jane', 'Julia', 'Tyler'} as a subset is returned in a result list.
});
SBDGroupChannelListQuery* query = SBDGroupChannel::CreateMyGroupChannelListQuery();

std::vector<SBDUser> users;
users.push_back(USER_2);    // L"Jane"
users.push_back(USER_3);    // L"Julia"
users.push_back(USER_4);    // L"Tyler"

query->SetUsersIncludeFilter(users, SBDGroupChannelListQueryType::Or);
query->LoadNextPage([](std::vector<SBDGroupChannel*> groupChannels, SBDError* error) {
    if (error != nullptr) {
        // Handle error.
        return;
    }

    // If channelA and channelB include {'Jane'}, channelA and channelB include {'Julia'}, and channelB includes {'Tyler'},
    // both channelA and channelB are returned in a result list.    
});