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 Remove Members from Channel closes #29 #30

Open
wants to merge 1 commit into
base: release/v1.1.0
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion pipelines/channel/create_channel.fp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pipeline "create_channel" {
}

request_body = jsonencode({
name = param.channel
name = param.channel_name
is_private = param.is_private
})

Expand Down
47 changes: 47 additions & 0 deletions pipelines/channel/kick_users_from_channel.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
pipeline "kick_users_from_channel" {
title = "Remove Users from Channel"
description = "Removes users from a Slack channel."

param "conn" {
type = connection.slack
description = local.conn_param_description
default = connection.slack.default
}

param "channel" {
type = string
description = "The ID of the public or private channel to remove user(s) from."
}

param "users" {
type = list(string)
description = "A list of user IDs to remove from the channel."
}

step "http" "remove_user_from_channel" {
for_each = param.users

method = "post"
url = "https://slack.com/api/conversations.kick"

request_headers = {
Content-Type = "application/json; charset=utf-8"
Authorization = "Bearer ${param.conn.token}"
}

request_body = jsonencode({
channel = param.channel
user = each.value
})

throw {
if = result.response_body.ok == false
message = result.response_body.error
}
}

output "kicked_users" {
description = "List of users successfully removed from the channel."
value = [for user in param.users: user if step.http.remove_user_from_channel[user].response_body.ok == true]
}
}