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

channel := client.Chat().Channel("messaging", "general")

channel.Update(ctx, &getstream.UpdateChannelRequest{
	Invites: getstream.PtrTo([]getstream.ChannelMemberRequest{{UserID: getstream.PtrTo("thierry")}}),
})

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!").

channel.Update(ctx, &getstream.UpdateChannelRequest{
	AcceptInvite: getstream.PtrTo(true),
	UserID:       getstream.PtrTo("thierry"),
})

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.

channel.Update(ctx, &getstream.UpdateChannelRequest{
	RejectInvite: getstream.PtrTo(true),
	UserID:       getstream.PtrTo("thierry"),
})

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

client.Chat().QueryChannels(ctx, &getstream.QueryChannelsRequest{
	FilterConditions: getstream.PtrTo(map[string]any{"invite": "accepted"}),
})

Query Rejected Invites

client.Chat().QueryChannels(ctx, &getstream.QueryChannelsRequest{
	FilterConditions: getstream.PtrTo(map[string]any{"invite": "rejected"}),
})

Query Pending Invites

client.Chat().QueryChannels(ctx, &getstream.QueryChannelsRequest{
	FilterConditions: getstream.PtrTo(map[string]any{"invite": "pending"}),
})