Closed alucic closed 3 years ago
Same Concern Here
@pterk could you assist here? Thanks
Bans are global
. You can user queryUsers to find all banned users:
$client->queryUsers(["banned" => true]);
Hi @pterk , I double checked the docs https://getstream.io/chat/docs_rest/#ban-user and it seems there are two types of bans, channel and app level bans.
POST /moderation/ban Bans a user from a channel or entirely.
In my case, I can successfully ban a user from a single channel, that user can still post to other channels. That is wanted behavior ✅
I'm still not able to get a list of banned users, for a channel or "entirely".
I've tried getting banned users using "user query" and "channel query" here are the examples:
Getting global bans Request
$client->queryUsers(["banned" => true]);
Response
[
"users" => [] <<--- should this contain a banned user from the app and/or channels?
"duration" => "12.76ms"
]
Getting channel data Request
$channel = $client->Channel('livestream', $id, new \stdClass());
$channel->query([]);
Response
members
key is empty, the only place where I see users in messages
key
"messages" => array:1 [
0 => array:14 [
"id" => "messageID"
"text" => "a"
"html" => "<p>a</p>\n"
"type" => "regular"
"user" => array:9 [
"id" => "Banned User ID"
"role" => "user"
"created_at" => "2020-01-04T20:00:00.00000Z"
"updated_at" => "2020-01-04T20:00:00.00000Z"
"last_active" => "2020-01-04T20:00:00.00000Z"
"banned" => false << ------- This should be true, since this user can't post
"online" => true
"image" => "image"
"name" => "User Name"
]
This is a live streaming use case I'm trying to solve:
In step 3, I'd like to ban all users that were banned in step 2 so they don't have access to my new channel.
A workaround would be to have a single channel, so there's no need to create a new channel, but in that case, and truncate it before a new stream starts. But, we would like to have access to old messages when the stream ends.
Thank you
Query by id and banned = true returns []
$banned = $client->queryUsers(
[
'id' => 'bob-1',
'banned' => true,
]);
Query just by id
$user = $client->queryUsers(
[
'id' => 'bob-1',
]);
Returns user info and mutes
. "banned" => false
which explains the first query returning []
@alucic AFAICT the banned filter works w/ the latest version.
I checked w/ the chat-team: """ its possible to ban in the scope of a channel. but currently there is no way to know/query if a certain user is banned from a channel its still possible to query for global bans using queryUsers """
I also heard on the grapevine that an upcoming feature will allow to filter at the channel level. I don't know an ETA though.
Is there a way we could also get all the flag messages from the channel?
@alucic Query members is for channel level: $banned = $channel->queryMembers(['banned' => true]);
@Rajat117 not at the moment, please check with support for it later because it's related to API than SDK.
I have a channel that's using
livestream
default channel typeAfter a live stream is done I'd like to revisit my bans and unban some users if needed. I've tried using
queryChannels
API endpoint but:queryChannels
shows only current members, is there a way to get past members?queryChannel
response doesn't reflect the currentbanned
state for a member. Banned user who can't send messages is havingbanned => false
inside channel'smembers
keyWhat would be the best way to get all banned users for a channel?
Thanks!