Skip to content

Commit

Permalink
Add Remove Members from Channel closes #29
Browse files Browse the repository at this point in the history
  • Loading branch information
khushboo9024 committed Nov 26, 2024
1 parent e1a5b28 commit 72b60f2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
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]
}
}

0 comments on commit 72b60f2

Please # to comment.