From 08cd248c26d1e0dda4309d6f27a8ab7099ce45f1 Mon Sep 17 00:00:00 2001 From: komagata Date: Thu, 5 Oct 2023 18:27:20 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Times=E3=83=81=E3=83=A3=E3=83=B3=E3=83=8D?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E4=BD=9C=E6=88=90=E5=87=A6=E7=90=86=E3=81=AB?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E5=87=BA=E5=8A=9B=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Timesチャンネル作成ができない不具合調査のため。 --- app/controllers/users_controller.rb | 10 ++++++++++ app/models/discord/server.rb | 5 ++++- app/models/discord/times_channel.rb | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 01bb48bcc1f..3e6a3731e7c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -54,6 +54,8 @@ def new end def create + logger.info "[Signup] 1. start create. #{user_params[:email]}" + @user = User.new(user_params) @user.course_id ||= Course.first.id @user.free = true if @user.trainee? @@ -80,11 +82,14 @@ def target_allowlist end def create_free_user! + logger.info "[Signup] 2. start create free user. #{@user.email}" if @user.save + logger.info "[Signup] 3. after save free user. #{@user.email}" UserMailer.welcome(@user).deliver_now notify_to_mentors(@user) notify_to_chat(@user) Newspaper.publish(:student_or_trainee_create, @user) if @user.trainee? + logger.info "[Signup] 4. after create times channel for free user. #{@user.email}" redirect_to root_url, notice: 'サインアップメールをお送りしました。メールからサインアップを完了させてください。' else render 'new' @@ -93,6 +98,7 @@ def create_free_user! # rubocop:disable Metrics/MethodLength, Metrics/BlockLength def create_user! + logger.info "[Signup] 2. start create user. #{@user.email}" @user.with_lock do unless @user.validate render 'new' @@ -108,6 +114,7 @@ def create_user! token = params[:idempotency_token] + logger.info "[Signup] 3. before create subscription. #{@user.email}" begin customer = Card.new.create(@user, params[:stripeToken], token) subscription = Subscription.new.create(customer['id'], "#{token}-subscription") @@ -117,15 +124,18 @@ def create_user! render 'new' return false end + logger.info "[Signup] 4. after create subscription.#{@user.email}" @user.customer_id = customer['id'] @user.subscription_id = subscription['id'] if @user.save + logger.info "[Signup] 5. after save user. #{@user.email}" UserMailer.welcome(@user).deliver_now notify_to_mentors(@user) notify_to_chat(@user) Newspaper.publish(:student_or_trainee_create, @user) if @user.student? + logger.info "[Signup] 8. after create times channel. #{@user.email}" redirect_to root_url, notice: 'サインアップメールをお送りしました。メールからサインアップを完了させてください。' else render 'new' diff --git a/app/models/discord/server.rb b/app/models/discord/server.rb index 0627d68b89e..d3f784e16a2 100644 --- a/app/models/discord/server.rb +++ b/app/models/discord/server.rb @@ -8,7 +8,10 @@ class Server class << self def create_text_channel(name:, parent: nil) guild = Discord::Server.find_by(id: guild_id, token: authorize_token) - return nil if guild.blank? + if guild.blank? + Rails.logger.error "[Discord API] Do not find server. guild_id: #{guild_id}, token: #{authorize_token}" + return nil + end channel_type = Discordrb::Channel::TYPES[:text] guild.create_channel(name, channel_type, parent: parent) diff --git a/app/models/discord/times_channel.rb b/app/models/discord/times_channel.rb index 2fb6f78bf07..c5666f099b6 100644 --- a/app/models/discord/times_channel.rb +++ b/app/models/discord/times_channel.rb @@ -8,6 +8,8 @@ def to_channel_name(username) end end + attr_reader :name + def initialize(username) @name = Discord::TimesChannel.to_channel_name(username) end From 324706687a1992d044292b23c0254aa7d8c7b5e1 Mon Sep 17 00:00:00 2001 From: komagata Date: Fri, 6 Oct 2023 01:21:11 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E5=90=8D?= =?UTF-8?q?=E3=81=AE=E3=83=9F=E3=82=B9=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同じテストクラスが二つあって衝突するため。 --- test/models/times_channel_destroyer_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/models/times_channel_destroyer_test.rb b/test/models/times_channel_destroyer_test.rb index edda241daa7..91d736156a7 100644 --- a/test/models/times_channel_destroyer_test.rb +++ b/test/models/times_channel_destroyer_test.rb @@ -2,7 +2,7 @@ require 'test_helper' -class TimesChannelCreatorTest < ActiveSupport::TestCase +class TimesChannelDestroyerTest < ActiveSupport::TestCase test '#call' do logs = [] user = users(:hajime) From 50dbb87944069c7eeb0a4867d883f49cabd35b1a Mon Sep 17 00:00:00 2001 From: komagata Date: Fri, 6 Oct 2023 03:31:23 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Discord=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=AE?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/models/discord/server_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/models/discord/server_test.rb b/test/models/discord/server_test.rb index 87ff1763e5b..5c43da5859e 100644 --- a/test/models/discord/server_test.rb +++ b/test/models/discord/server_test.rb @@ -91,7 +91,7 @@ class ServerTest < ActiveSupport::TestCase Discord::Server.authorize_token = 'Bot invalid token' actual = Discord::Server.create_text_channel(name: 'wakaran🔰') assert_nil actual - assert_equal '[Discord API] 401: Unauthorized', logs.pop + assert_equal '[Discord API] Do not find server. guild_id: 1234567890123456789, token: Bot invalid token', logs.pop end end end