forked from External/greenlight
		
	properly handle post_publish event
This commit is contained in:
		@@ -92,7 +92,9 @@ renderActiveMeeting = function(m){
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
removeActiveMeeting = function(meeting){
 | 
					removeActiveMeeting = function(meeting){
 | 
				
			||||||
 | 
					  if(meeting){
 | 
				
			||||||
    $('#' + meeting['name'].replace(' ', '_')).remove()
 | 
					    $('#' + meeting['name'].replace(' ', '_')).remove()
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Directly join a meeting from active meetings.
 | 
					// Directly join a meeting from active meetings.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -111,7 +111,8 @@ class BbbController < ApplicationController
 | 
				
			|||||||
    head(:ok) && return unless validate_checksum
 | 
					    head(:ok) && return unless validate_checksum
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    begin
 | 
					    begin
 | 
				
			||||||
      data = JSON.parse(params['event'])
 | 
					      event = params['event']
 | 
				
			||||||
 | 
					      data = event.is_a?(String) ? JSON.parse(params['event']) : event
 | 
				
			||||||
      treat_callback_event(data)
 | 
					      treat_callback_event(data)
 | 
				
			||||||
    rescue Exception => e
 | 
					    rescue Exception => e
 | 
				
			||||||
      logger.error "Error parsing webhook data. Data: #{data}, exception: #{e.inspect}"
 | 
					      logger.error "Error parsing webhook data. Data: #{data}, exception: #{e.inspect}"
 | 
				
			||||||
@@ -314,6 +315,9 @@ class BbbController < ApplicationController
 | 
				
			|||||||
    checksum = params["checksum"]
 | 
					    checksum = params["checksum"]
 | 
				
			||||||
    return false unless checksum
 | 
					    return false unless checksum
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Message is only encoded if it comes from the bbb-webhooks node application.
 | 
				
			||||||
 | 
					    # The post process script does not encode it's response body.
 | 
				
			||||||
 | 
					    begin
 | 
				
			||||||
      # Decode and break the body into parts.
 | 
					      # Decode and break the body into parts.
 | 
				
			||||||
      parts = URI.decode_www_form(read_body(request))
 | 
					      parts = URI.decode_www_form(read_body(request))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -322,10 +326,15 @@ class BbbController < ApplicationController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      # Manually remove the space between the two elements.
 | 
					      # Manually remove the space between the two elements.
 | 
				
			||||||
      converted_data[converted_data.rindex("timestamp") - 2] = ''
 | 
					      converted_data[converted_data.rindex("timestamp") - 2] = ''
 | 
				
			||||||
 | 
					 | 
				
			||||||
      callback_url = uri_remove_param(request.original_url, "checksum")
 | 
					      callback_url = uri_remove_param(request.original_url, "checksum")
 | 
				
			||||||
 | 
					 | 
				
			||||||
      checksum_str = "#{callback_url}#{converted_data}#{secret}"
 | 
					      checksum_str = "#{callback_url}#{converted_data}#{secret}"
 | 
				
			||||||
 | 
					    rescue
 | 
				
			||||||
 | 
					      # Data was not recieved encoded (sent from post process script).
 | 
				
			||||||
 | 
					      data = read_body(request)
 | 
				
			||||||
 | 
					      callback_url = uri_remove_param(request.original_url, "checksum")
 | 
				
			||||||
 | 
					      checksum_str = "#{callback_url}#{data}#{secret}"
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    calculated_checksum = Digest::SHA1.hexdigest(checksum_str)
 | 
					    calculated_checksum = Digest::SHA1.hexdigest(checksum_str)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if calculated_checksum != checksum
 | 
					    if calculated_checksum != checksum
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user