diff --git a/app/controllers/installations_controller.rb b/app/controllers/installations_controller.rb index fb819444a..66baf1050 100644 --- a/app/controllers/installations_controller.rb +++ b/app/controllers/installations_controller.rb @@ -38,10 +38,16 @@ class InstallationsController < ApplicationController render_ok end + # 同步bot信息,回调地址和名称 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.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 render_ok end @@ -66,7 +72,7 @@ class InstallationsController < ApplicationController @bot.owner_id = current_user.id ActiveRecord::Base.transaction do # 注册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对应用户 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?