Class: IntegrationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/integrations_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#admin_login_required, #all_done_todos_for, #boolean_param, cas_enabled?, #cas_enabled?, #count_deferred_todos, #count_undone_todos, #count_undone_todos_phrase, #done_todos_for, #enable_mobile_content_negotiation, #for_autocomplete, #format_date, #format_dependencies_as_json_for_auto_complete, #handle_unverified_request, #init_data_for_sidebar, #init_not_done_counts, #init_project_hidden_todo_counts, #mobile?, #notify, #openid_enabled?, openid_enabled?, #parse_date_per_user_prefs, #prefered_auth?, prefered_auth?, #redirect_back_or_home, #render_failure, #sanitize, #set_charset, #set_group_view_by, #set_locale, #set_session_expiration, #set_time_zone, #set_zindex_counter, #todo_xml_params

Methods included from LoginSystem

#access_denied, #authorize?, #basic_auth_denied, #current_user, #get_basic_auth_data, #get_current_user, #logged_in?, #login_from_cookie, #login_optional, #login_or_feed_token_required, #login_required, #logout_user, #prefs, #protect?, #redirect_back_or_default, #redirect_to_login, #set_current_user, #store_location

Instance Method Details

#cloudmailinObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/integrations_controller.rb', line 24

def cloudmailin
  if !verify_cloudmailin_signature
    render :text => "Message signature verification failed.", :status => 403
    return false
  end

  if process_message(params[:message])
    render :text => 'success', :status => 200
  else
    render :text => "No user found or other error", :status => 404
  end
end

#flatten_params(params, title = nil, result = {}) ⇒ Object (private)



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/integrations_controller.rb', line 49

def flatten_params(params, title = nil, result = {})
  params.each do |key, value|
    if value.kind_of?(Hash)
      key_name = title ? "#{title}[#{key}]" : key
      flatten_params(value, key_name, result)
    else
      key_name = title ? "#{title}[#{key}]" : key
      result[key_name] = value
    end
  end

  return result
end

#google_gadgetObject



20
21
22
# File 'app/controllers/integrations_controller.rb', line 20

def google_gadget
  render :layout => false, :content_type => Mime::XML
end

#indexObject



7
8
9
# File 'app/controllers/integrations_controller.rb', line 7

def index
  @page_title = 'TRACKS::Integrations'
end

#process_message(message) ⇒ Object (private)



39
40
41
# File 'app/controllers/integrations_controller.rb', line 39

def process_message(message)
  MessageGateway::receive(Mail.new(message))
end

#rest_apiObject



11
12
13
# File 'app/controllers/integrations_controller.rb', line 11

def rest_api
  @page_title = 'TRACKS::REST API Documentation'
end

#search_pluginObject



15
16
17
18
# File 'app/controllers/integrations_controller.rb', line 15

def search_plugin
  @icon_data = [File.open(File.join(Rails.root, 'app', 'assets', 'images', 'done.png')).read].
    pack('m').gsub(/\n/, '')
end

#verify_cloudmailin_signatureObject (private)



43
44
45
46
47
# File 'app/controllers/integrations_controller.rb', line 43

def verify_cloudmailin_signature
  provided = request.request_parameters.delete(:signature)
  signature = Digest::MD5.hexdigest(flatten_params(request.request_parameters).sort.map{|k,v| v}.join + SITE_CONFIG['cloudmailin'])
  return provided == signature
end