From 3d61b920ace96af566e0a81bd5dac39680688667 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 29 Mar 2023 17:29:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5bot=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E5=9B=9E=E8=B0=83=E5=9C=B0=E5=9D=80=E5=92=8C=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/installations_controller.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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?