use GetStream\ChatClient;
use GetStream\GeneratedModels as Models;
$client = new ChatClient("{{ api_key }}", "{{ api_secret }}");
$client->updateChannel("messaging", "team-chat-5", new Models\UpdateChannelRequest(
invites: [new Models\ChannelMemberRequest(userID: "thierry")],
));Invites
Invites allow you to add users to a channel with a pending state. The invited user receives a notification and can accept or reject the invite.
Unread counts are not incremented for channels with a pending invite.
Invite Users
Accept an Invite
Call acceptInvite to accept a pending invite. You can optionally include a message parameter to post a system message when the user joins (e.g., "Nick joined this channel!").
// Accept the invite
$client->updateChannel("messaging", "team-chat-5", new Models\UpdateChannelRequest(
acceptInvite: true,
userID: "elon",
));Reject an Invite
Call rejectInvite to decline a pending invite. Client-side calls use the currently connected user. Server-side calls require a user_id parameter.
// Reject the invite
$client->updateChannel("messaging", "team-chat-5", new Models\UpdateChannelRequest(
rejectInvite: true,
userID: "elon",
));Query Invites by Status
Use queryChannels with the invite filter to retrieve channels based on invite status. Valid values are pending, accepted, and rejected.
Query Accepted Invites
$response = $client->queryChannels(new Models\QueryChannelsRequest(
filterConditions: (object)["invite" => "accepted"],
userID: "jenny",
));Query Rejected Invites
$response = $client->queryChannels(new Models\QueryChannelsRequest(
filterConditions: (object)["invite" => "rejected"],
userID: "jenny",
));Query Pending Invites
$response = $client->queryChannels(new Models\QueryChannelsRequest(
filterConditions: (object)["invite" => "pending"],
userID: "jenny",
));