Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing JS snippets #564

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.deactivateUser({
user_id: '<id>',
});

//reactivate
client.reactivateUsers({
user_ids: ['<id>'],
});

// deactivativating users in bulk can take some time
const deactivateResponse = client.deactivateUsers({
user_ids: ['<id1>', '<id2>'...],
});

// you need to poll this endpoint
const taskResponse = await client.getTaskStatus({id: deactivateResponse.task_id})

console.log(taskResponse.status === 'completed');
```

</TabItem>
<TabItem value="py" label="Python">

```py
# deactivate one user
client.deactivate_user(user_id=alice.id)

# reactivates the user
client.reactivate_user(user_id=alice.id)

# deactivates users in bulk, this is an async operation
response = client.deactivate_users(user_ids=[alice.id, bob.id])
task_id = response.data.task_id

# get information about the task
task_status = client.get_task(task_id)

# just an example, in reality it can take a few seconds for a task to be processed
if task_status.data.status == "completed":
print(task_status.data.result)
```

</TabItem>

<TabItem value="curl" label="cURL">

```bash
# Deactivate users
curl -X POST https://video.stream-io-api.com/api/v2/users/deactivate?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'

# Reactivate users
curl -X POST https://video.stream-io-api.com/api/v2/users/deactivate?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'

# Reactivate users in bulk can take some time, you can poll task status using the task id from the response
# When finished, task status will be completed
curl -X GET https://video.stream-io-api.com/api/v2/tasks/${TASK_ID}?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt"
```

</TabItem>
</Tabs>
39 changes: 3 additions & 36 deletions docusaurus/video/docusaurus/docs/api/basics/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ title: Users & Tokens

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import DeactivateReactivate from '../_common_/deactivate-reactivate.mdx';

## Creating users

Expand Down Expand Up @@ -227,15 +228,6 @@ Delete has the following opitions:
<TabItem value="js" label="JavaScript">

```js
client.deactivateUser({
user_id: '<id>',
});

//reactivate
client.reactivateUsers({
user_ids: ['<id>'],
});

client.deleteUsers({ user_ids: ['<id>'] });

//restore
Expand All @@ -247,15 +239,6 @@ client.restoreUsers({ user_ids: ['<id>'] });
<TabItem value="py" label="Python">

```py
client.deactivate_user(
user_id="<id>",
)

# reactivate
client.reactivate_users(
user_ids=["<id>"],
)

client.delete_users(user_ids=["<id>"])

# restore
Expand All @@ -266,24 +249,6 @@ client.restore_users(user_ids=["<id>"])
<TabItem value="curl" label="cURL">

```bash
# Deactivate users
curl -X POST https://video.stream-io-api.com/api/v2/users/deactivate?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'

# Reactivate users
curl -X POST https://video.stream-io-api.com/api/v2/users/deactivate?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'

# Delete users
curl -X POST https://video.stream-io-api.com/api/v2/users/delete?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
Expand All @@ -306,6 +271,8 @@ curl -X POST https://video.stream-io-api.com/api/v2/users/restore?api_key=${API_
</TabItem>
</Tabs>

<DeactivateReactivate/>

## User tokens

Stream uses JWT (JSON Web Tokens) to authenticate chat users, enabling them to log in. Knowing whether a user is authorized to perform certain actions is managed separately via a role-based permissions system. Tokens need to be generated server-side.
Expand Down
85 changes: 29 additions & 56 deletions docusaurus/video/docusaurus/docs/api/moderation/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ title: Overview

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import DeactivateReactivate from '../_common_/deactivate-reactivate.mdx';

When running calls with a larger audience, you’ll often need moderation features to prevent abuse. Participants can share inappropriate content via

Expand Down Expand Up @@ -136,6 +137,7 @@ You can also mute every other participant’s video or audio.
call.muteUsers({
mute_all_users: true,
audio: true,
muted_by_id: 'john'
});
```

Expand Down Expand Up @@ -180,6 +182,7 @@ call.muteUsers({
video: true,
screenshare: true,
screenshare_audio: true,
muted_by_id: 'john'
});
```

Expand Down Expand Up @@ -318,7 +321,31 @@ Users can be banned, when doing that they are not allowed to join or create call
<TabItem value="js" label="JavaScript">

```js
// TODO: not implemented yet
client.banUser({
target_user_id: '<bad user id>',
user_id: '<moderator id>',
reason: '<reason>'
});

// remove the ban for a user
client.unbanUser({
targetUserId: '<user id>'
});

// ban a user for 30 minutes
client.banUser({
target_user_id: '<bad user id>',
user_id: '<moderator id>',
timeout: 30
});

// ban a user and all users sharing the same IP
client.banUser({
target_user_id: '<bad user id>',
user_id: '<moderator id>',
reason: '<reason>',
ip_ban: true
});
```

</TabItem>
Expand Down Expand Up @@ -406,58 +433,4 @@ curl -X POST https://video.stream-io-api.com/api/v2/moderation/ban?api_key=${API

Deactivated users are no longer able to make any API call or connect to websockets (and receive updates on event of any kind).

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
// TODO: not implemented yet
```

</TabItem>
<TabItem value="py" label="Python">

```py
# deactivate one user
client.deactivate_user(user_id=alice.id)

# reactivates the user
client.reactivate_user(user_id=alice.id)

# deactivates users in bulk, this is an async operation
response = client.deactivate_users(user_ids=[alice.id, bob.id])
task_id = response.data.task_id

# get information about the task
task_status = client.get_task(task_id)

# just an example, in reality it can take a few seconds for a task to be processed
if task_status.data.status == "completed":
print(task_status.data.result)
```

</TabItem>

<TabItem value="curl" label="cURL">

```bash
# Deactivate users
curl -X POST https://video.stream-io-api.com/api/v2/users/deactivate?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'

# Reactivate users
curl -X POST https://video.stream-io-api.com/api/v2/users/deactivate?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'
```

</TabItem>
</Tabs>
<DeactivateReactivate/>
Loading