fix deac?

This commit is contained in:
24c02 2026-01-01 13:03:34 -05:00
parent abb3d8c14b
commit 34b447d4d0
2 changed files with 18 additions and 19 deletions

View file

@ -129,21 +129,20 @@ class SAMLController < ApplicationController
def try_assign_to_slack_workspace
return unless current_identity.slack_id.present?
# Check if user is already in workspace
if SlackService.user_in_workspace?(user_id: current_identity.slack_id)
case SlackService.user_workspace_status(user_id: current_identity.slack_id)
when :in_workspace
current_identity.update(is_in_workspace: true) unless current_identity.is_in_workspace
return
when :not_in_workspace
scenario = current_identity.onboarding_scenario_instance
return unless scenario.slack_channels.any?
AssignSlackWorkspaceJob.perform_later(
slack_id: current_identity.slack_id,
user_type: :multi_channel_guest,
channel_ids: scenario.slack_channels,
identity_id: current_identity.id
)
end
scenario = current_identity.onboarding_scenario_instance
return unless scenario.slack_channels.any?
AssignSlackWorkspaceJob.perform_later(
slack_id: current_identity.slack_id,
user_type: :multi_channel_guest,
channel_ids: scenario.slack_channels,
identity_id: current_identity.id
)
end
def check_enterprise_features!

View file

@ -52,18 +52,18 @@ module SlackService
false
end
def user_in_workspace?(user_id:)
def user_workspace_status(user_id:)
response = client.users_info(user: user_id)
user = response.dig("user")
return false unless user
return false if user["deleted"]
return :unknown unless user
return :deactivated if user["deleted"]
teams = user["teams"] || []
teams.include?(team_id)
teams.include?(team_id) ? :in_workspace : :not_in_workspace
rescue => e
Rails.logger.warn "Could not check if user #{user_id} is in workspace: #{e.message}"
false
Rails.logger.warn "Could not check workspace status for user #{user_id}: #{e.message}"
:unknown
end
end
end