Is it possible for me to query a channel to direct message only?
ikaru19 opened this issue · 1 comments
ikaru19 commented
What did you do?
I have this code to have filter to my chat for directs or group chat
if isDirectSelected {
channelFilter = .contains(.cid, value: "!members")
} else if isGroupSelected {
channelFilter = .nor([.contains(.cid, value: "!members")])
} else {
channelFilter = .equal(.hidden, to: false)
}
if !selectedUsers.isEmpty {
userFilter = .containMembers(userIds: userIds)
} else {
userFilter = .nonEmpty
}
let combinedFilter:Filter<ChannelListFilterScope> = .and([
.equal(.team, to: data.teamsId),
channelFilter,
userFilter
])
let query = ChannelListQuery(
filter: combinedFilter,
sort: [
.init(key: .lastMessageAt),
.init(key: .updatedAt)
]
)
What did you expect to happen?
I see public var isDirectMessageChannel: Bool { cid.id.hasPrefix("!members") }
this on Channel and Want to use that on channel query.
What happened instead?
got this error from api
{
"code" : 4,
"message" : "QueryChannels failed with error: \"operator \"$contains\" is not allowed for field \"cid\"\"",
"more_info" : "https:\/\/getstream.io\/chat\/docs\/api_errors_response",
"details" : [
],
"StatusCode" : 400,
"duration" : "0.00ms"
})
according to https://getstream.io/chat/docs/ios-swift/query_channels/?language=swift#query-options
is not work. but is there workaround that i can do? Thanks!
GetStream Environment
**GetStream Chat version:4.51.0
GetStream Chat frameworks: StreamChat, StreamChatUI
**iOS version:17.0.1
**Swift version:5
**Xcode version:15.3
Additional context
nuno-vieira commented
Hi @ikaru19,
Please reach out to our support team: https://support.getstream.io/hc/en-us; they will be able to help you with the queries.
Best,
Nuno