/app/controllers/bitbucket_service_controller.rb

https://bitbucket.org/daenoor/redmine_bitbucket · Ruby · 27 lines · 20 code · 7 blank · 0 comment · 2 complexity · 8ba2cc077875fa3ac3103df228c9fee8 MD5 · raw file

  1. require "json"
  2. class BitbucketServiceController < ApplicationController
  3. unloadable
  4. skip_before_filter :verify_authenticity_token, :check_if_login_required
  5. def index
  6. bitbucket = BitbucketService.new
  7. unless bitbucket.service_enabled? && bitbucket.valid_key?(params[:key])
  8. return render :nothing => true, :status => 404
  9. end
  10. result = bitbucket.find_and_update_repository(params[:project_id], params[:payload])
  11. if result.nil?
  12. logger.debug { "BitbucketPlugin: Invalid repository" }
  13. return render :nothing => true, :status => 500
  14. end
  15. render :nothing => true, :status => 200
  16. rescue ActiveRecord::RecordNotFound
  17. logger.debug { "BitbucketPlugin: Record not found" }
  18. render :nothing => true, :status => 404
  19. end
  20. end