同步bot信息,回调地址和名称
This commit is contained in:
parent
7045fb3960
commit
3d61b920ac
|
@ -38,10 +38,16 @@ class InstallationsController < ApplicationController
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 同步bot信息,回调地址和名称
|
||||||
def update_callback_url
|
def update_callback_url
|
||||||
bot = Bot.find params[:id]
|
bot = Bot.find params[:id]
|
||||||
application = Doorkeeper::Application.find_by(uid: bot.client_id, secret: bot.client_secret)
|
application = Doorkeeper::Application.find_by(uid: bot.client_id, secret: bot.client_secret)
|
||||||
# application.redirect_uri = bot.callback_url
|
application.redirect_uri = bot.oauth_callback_url
|
||||||
|
application.name = bot.name
|
||||||
|
if bot.uid.present?
|
||||||
|
bot_user = User.find_by(id: bot.uid)
|
||||||
|
bot_user.update_column(:nickname, bot.name) if bot_user.present?
|
||||||
|
end
|
||||||
application.save
|
application.save
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
|
@ -66,7 +72,7 @@ class InstallationsController < ApplicationController
|
||||||
@bot.owner_id = current_user.id
|
@bot.owner_id = current_user.id
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
# 注册bot对应oauth应用
|
# 注册bot对应oauth应用
|
||||||
Doorkeeper::Application.create!(name: @bot.name, uid: @bot.client_id, secret: @bot.client_secret, redirect_uri: "https://gitlink.org.cn")
|
Doorkeeper::Application.create!(name: @bot.name, uid: @bot.client_id, secret: @bot.client_secret, redirect_uri: @bot.oauth_callback_url)
|
||||||
# 注册bot对应用户
|
# 注册bot对应用户
|
||||||
result = autologin_register(User.generate_user_login('b'), nil, "#{SecureRandom.hex(6)}", 'bot', nil, @bot.name)
|
result = autologin_register(User.generate_user_login('b'), nil, "#{SecureRandom.hex(6)}", 'bot', nil, @bot.name)
|
||||||
tip_exception(-1, result[:message]) if result[:message].present?
|
tip_exception(-1, result[:message]) if result[:message].present?
|
||||||
|
|
Loading…
Reference in New Issue