softbot补充和调整接口
This commit is contained in:
parent
9f123995ee
commit
f0dca4c0c1
|
@ -2,10 +2,23 @@ class InstallationsController < ApplicationController
|
|||
include RegisterHelper
|
||||
before_action :require_login
|
||||
|
||||
# app详情
|
||||
def app
|
||||
@bot = Bot.find_by(uid: current_user.id)
|
||||
end
|
||||
|
||||
def index
|
||||
@install_bots = BotInstall.where(:installer_id => current_user.id)
|
||||
end
|
||||
|
||||
def show
|
||||
@install_bot = BotInstall.find params[:id]
|
||||
end
|
||||
|
||||
def repositories
|
||||
@install_bots = BotInstall.where(:installer_id => current_user.id)
|
||||
end
|
||||
|
||||
def update_secret
|
||||
ActiveRecord::Base.transaction do
|
||||
bot = Bot.find params[:id]
|
||||
|
@ -25,6 +38,24 @@ class InstallationsController < ApplicationController
|
|||
render_ok
|
||||
end
|
||||
|
||||
def update_callback_url
|
||||
bot = Bot.find params[:id]
|
||||
application = Doorkeeper::Application.find_by(uid: bot.client_id, secret: bot.client_secret)
|
||||
# application.redirect_uri = bot.callback_url
|
||||
application.save
|
||||
render_ok
|
||||
end
|
||||
|
||||
def suspended
|
||||
@install_bot = BotInstall.find params[:id]
|
||||
@install_bot.update_attributes!(state: 0)
|
||||
render_ok
|
||||
end
|
||||
def unsuspended
|
||||
@install_bot = BotInstall.find params[:id]
|
||||
@install_bot.update_attributes!(state: 1)
|
||||
render_ok
|
||||
end
|
||||
def auth_active
|
||||
begin
|
||||
@bot = Bot.find params[:id]
|
||||
|
@ -60,6 +91,7 @@ class InstallationsController < ApplicationController
|
|||
:expires_in => "604800",
|
||||
:use_refresh_token => true
|
||||
})
|
||||
@install_bot.update_attributes!(state: 1)
|
||||
render_ok(token: @access_token.token)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
json.partial! "commons/success"
|
||||
|
||||
json.extract! @bot, :id, :bot_name, :bot_des, :webhook, :is_public, :logo, :state, :web_url, :install_num, :owner_id, :create_time, :update_time
|
||||
|
|
@ -4,5 +4,8 @@ json.data do
|
|||
json.array! @install_bots do |install_bot|
|
||||
json.installation_id install_bot.id
|
||||
json.extract! install_bot.bot, :id, :name
|
||||
json.bot_id install_bot.bot.id
|
||||
json.bot_name install_bot.bot.name
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,15 @@
|
|||
json.status 0
|
||||
json.message "success"
|
||||
json.total_count @install_bots.size
|
||||
json.repositories do
|
||||
json.array! @install_bots do |install_bot|
|
||||
project = Project.find_by(id: install_bot.store_id)
|
||||
if project.present?
|
||||
json.id install_bot.store_id
|
||||
json.url "#{base_url}/#{project.owner.login}/#{project.owner.identifier}.git"
|
||||
json.name project.owner.identifier
|
||||
json.owner_name project.owner.login
|
||||
json.is_public project.is_public
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
json.partial! "commons/success"
|
||||
|
||||
json.extract! @install_bot, :id, :bot_id, :installer_id, :state, :create_time, :update_time
|
||||
json.bot_name @install_bot.bot.name
|
||||
|
|
@ -1064,18 +1064,23 @@ Rails.application.routes.draw do
|
|||
resources :commit_logs, :only => [:create]
|
||||
|
||||
scope '/app' do
|
||||
get '/', to: 'installations#app'
|
||||
post ':id/auth_active', to: 'installations#auth_active'
|
||||
post ':id/update_private_key', to: 'installations#update_private_key'
|
||||
post ':id/update_secret', to: 'installations#update_secret'
|
||||
resources :installations do
|
||||
get :repositories, on: :collection
|
||||
resources :installations, only: [:index, :show] do
|
||||
member do
|
||||
post :access_tokens
|
||||
put :suspended
|
||||
put :suspended, to: 'installations#suspended'
|
||||
delete :suspended, to: 'installations#unsuspended'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
resources :installations, only: [] do
|
||||
get :repositories, on: :collection
|
||||
end
|
||||
|
||||
root 'main#index'
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue