Class: AiRootShield::Enterprise::TeamsChannel

Inherits:
Object
  • Object
show all
Defined in:
lib/ai_root_shield/enterprise/alert_system.rb

Overview

Microsoft Teams channel implementation

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ TeamsChannel

Returns a new instance of TeamsChannel.



531
532
533
# File 'lib/ai_root_shield/enterprise/alert_system.rb', line 531

def initialize(config)
  @config = config
end

Instance Method Details

#send_alert(alert) ⇒ Object



535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'lib/ai_root_shield/enterprise/alert_system.rb', line 535

def send_alert(alert)
  return { success: false, error: "No Teams webhook URL configured" } unless @config[:webhook_url]
  
  payload = format_teams_payload(alert)
  
  uri = URI(@config[:webhook_url])
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  
  request = Net::HTTP::Post.new(uri)
  request['Content-Type'] = 'application/json'
  request.body = payload.to_json
  
  response = http.request(request)
  
  if response.code == '200'
    { success: true, channel: 'teams' }
  else
    { success: false, error: "Teams API error: #{response.body}", channel: 'teams' }
  end
rescue StandardError => e
  { success: false, error: e.message, channel: 'teams' }
end