diff --git a/app/models/onboarding_scenarios/default_join.rb b/app/models/onboarding_scenarios/default_join.rb index 5b13a28..27681b0 100644 --- a/app/models/onboarding_scenarios/default_join.rb +++ b/app/models/onboarding_scenarios/default_join.rb @@ -17,6 +17,6 @@ module OnboardingScenarios def slack_channels = Rails.configuration.slack_channels.slice(:waiting_room).values - def promotion_channels = Rails.configuration.slack_channels.slice(:announcements, :welcome, :ship, :neighbourhood, :library, :lounge).values + def promotion_channels = Rails.configuration.slack_channels.slice(:announcements, :happenings, :community, :hardware, :code, :ship, :neighbourhood, :library, :lounge).values end end diff --git a/config/slack_channels.yml b/config/slack_channels.yml index 2305962..1de866b 100644 --- a/config/slack_channels.yml +++ b/config/slack_channels.yml @@ -1,5 +1,10 @@ production: announcements: C0266FRGT + happenings: C05B6DBN802 + community: C01D7AHKMPF + ysws: C0710J7F4U9 + hardware: C6C026NHJ + code: C0EA9S0A0 library: C078Q8PBD4G ship: C0M8PUPU6 welcome: C75M7C0SY diff --git a/lib/tasks/slack.rake b/lib/tasks/slack.rake new file mode 100644 index 0000000..39c9740 --- /dev/null +++ b/lib/tasks/slack.rake @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +namespace :slack do + desc "Join all channels defined in config/slack_channels.yml" + task join_channels: :environment do + config = YAML.load_file(Rails.root.join("config/slack_channels.yml")) + client = SlackService.client + joined_ids = Set.new + + config.each do |env, channels| + puts "\n=== #{env} ===" + channels.each do |name, channel_id| + next if joined_ids.include?(channel_id) + + joined_ids << channel_id + print "Joining ##{name} (#{channel_id})... " + client.conversations_join(channel: channel_id) + puts "✓" + rescue Slack::Web::Api::Errors::MethodNotSupportedForChannelType + puts "skipped (DM or unsupported type)" + rescue Slack::Web::Api::Errors::ChannelNotFound + puts "not found" + rescue Slack::Web::Api::Errors::SlackError => e + puts "failed: #{e.message}" + end + end + + puts "\nDone!" + end +end