2007-10-14 05:33:00 +00:00
|
|
|
class IntegrationsController < ApplicationController
|
2011-10-04 20:14:36 +02:00
|
|
|
require 'mail'
|
|
|
|
|
|
|
|
skip_before_filter :login_required, :only => [:cloudmailin, :search_plugin, :google_gadget]
|
2012-06-29 16:48:30 +02:00
|
|
|
|
2007-10-14 05:33:00 +00:00
|
|
|
def index
|
|
|
|
@page_title = 'TRACKS::Integrations'
|
|
|
|
end
|
|
|
|
|
2007-12-05 06:48:24 +00:00
|
|
|
def rest_api
|
|
|
|
@page_title = 'TRACKS::REST API Documentation'
|
|
|
|
end
|
2012-07-12 13:14:21 +02:00
|
|
|
|
2007-10-14 05:33:00 +00:00
|
|
|
def get_quicksilver_applescript
|
2012-07-12 13:14:21 +02:00
|
|
|
get_applescript('quicksilver_applescript')
|
2007-10-14 05:33:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_applescript1
|
2012-07-12 13:14:21 +02:00
|
|
|
get_applescript('applescript1')
|
2007-10-14 05:33:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_applescript2
|
2012-07-12 13:14:21 +02:00
|
|
|
get_applescript('applescript2')
|
2007-10-14 05:33:00 +00:00
|
|
|
end
|
2008-12-10 21:30:43 +01:00
|
|
|
|
|
|
|
def search_plugin
|
2012-06-29 16:48:30 +02:00
|
|
|
@icon_data = [File.open(File.join(Rails.root, 'app', 'assets', 'images', 'done.png')).read].
|
2011-10-04 20:14:36 +02:00
|
|
|
pack('m').gsub(/\n/, '')
|
2008-12-10 21:30:43 +01:00
|
|
|
end
|
|
|
|
|
2009-08-04 09:54:45 +02:00
|
|
|
def google_gadget
|
|
|
|
render :layout => false, :content_type => Mime::XML
|
|
|
|
end
|
2011-10-04 20:14:36 +02:00
|
|
|
|
|
|
|
def cloudmailin
|
2011-10-05 23:53:49 +02:00
|
|
|
# verify cloudmailin signature
|
|
|
|
provided = request.request_parameters.delete(:signature)
|
|
|
|
signature = Digest::MD5.hexdigest(request.request_parameters.sort{|a,b| a[0].to_s <=> b[0].to_s}.map{|k,v| v}.join + SITE_CONFIG['cloudmailin'])
|
|
|
|
|
|
|
|
# if signature does not match, return 403
|
|
|
|
if provided != signature
|
2011-10-06 16:41:46 +02:00
|
|
|
render :text => "Message signature verification failed.", :status => 403
|
2011-10-05 23:53:49 +02:00
|
|
|
return false
|
|
|
|
end
|
2011-10-04 20:14:36 +02:00
|
|
|
|
2012-07-12 13:14:21 +02:00
|
|
|
if MessageGateway::receive(Mail.new(params[:message]))
|
|
|
|
render :text => 'success', :status => 200
|
2011-10-04 20:14:36 +02:00
|
|
|
else
|
2012-07-12 13:14:21 +02:00
|
|
|
render :text => "No user found or other error", :status => 404
|
2011-10-04 20:14:36 +02:00
|
|
|
end
|
|
|
|
end
|
2012-07-12 13:14:21 +02:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def get_applescript(partial_name)
|
|
|
|
context = current_user.contexts.find params[:context_id]
|
|
|
|
render :partial => partial_name, :locals => { :context => context }
|
|
|
|
end
|
|
|
|
|
2007-10-14 05:33:00 +00:00
|
|
|
end
|