From 400d5c3e3307fbe1547eb39615a083f673590a90 Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Tue, 2 Jan 2024 23:46:50 +0900 Subject: [PATCH 1/4] =?UTF-8?q?newspaper=E3=81=AE=E5=BC=95=E6=95=B0?= =?UTF-8?q?=E3=82=92=E3=83=8F=E3=83=83=E3=82=B7=E3=83=A5=E3=81=A7=E3=81=AE?= =?UTF-8?q?=E5=8F=97=E3=81=91=E6=B8=A1=E3=81=97=E3=81=AB=E7=B5=B1=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin/users_controller.rb | 2 +- app/controllers/announcements_controller.rb | 6 +++--- app/controllers/api/answers_controller.rb | 8 ++++---- app/controllers/api/correct_answers_controller.rb | 2 +- app/controllers/api/questions_controller.rb | 2 +- app/controllers/events_controller.rb | 2 +- app/controllers/graduation_controller.rb | 2 +- app/controllers/pages_controller.rb | 4 ++-- app/controllers/questions_controller.rb | 2 +- app/controllers/regular_events_controller.rb | 4 ++-- app/controllers/reports_controller.rb | 6 +++--- app/controllers/retirement_controller.rb | 2 +- .../scheduler/daily/auto_retire_controller.rb | 2 +- app/controllers/users_controller.rb | 6 +++--- app/models/ai_answer_creator.rb | 3 ++- app/models/announcement_notification_destroyer.rb | 3 ++- app/models/announcement_notifier.rb | 3 ++- app/models/answer_cache_destroyer.rb | 3 ++- app/models/answer_notifier.rb | 3 ++- app/models/answerer_watcher.rb | 3 ++- app/models/correct_answer_notifier.rb | 3 ++- app/models/event_organizer_watcher.rb | 3 ++- app/models/first_report_notifier.rb | 3 ++- app/models/graduation_notifier.rb | 3 ++- app/models/mentors_watch_for_question_creator.rb | 3 ++- app/models/notifier_to_watching_user.rb | 3 ++- app/models/page_notifier.rb | 3 ++- app/models/question_notifier.rb | 3 ++- app/models/regular_event_update_notifier.rb | 3 ++- app/models/report_notifier.rb | 3 ++- app/models/sad_streak_updater.rb | 3 ++- app/models/sign_up_notifier.rb | 3 ++- app/models/times_channel_creator.rb | 3 ++- app/models/times_channel_destroyer.rb | 3 ++- app/models/unfinished_data_destroyer.rb | 3 ++- test/models/event_organizer_watcher_test.rb | 2 +- test/models/times_channel_creator_test.rb | 10 +++++----- test/models/times_channel_destroyer_test.rb | 4 ++-- 38 files changed, 75 insertions(+), 54 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index a1f66f9a587..53224498bb9 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -23,7 +23,7 @@ def edit; end def update if @user.update(user_params) destroy_subscription(@user) - Newspaper.publish(:retirement_create, @user) if @user.saved_change_to_retired_on? + Newspaper.publish(:retirement_create, { user: @user }) if @user.saved_change_to_retired_on? redirect_to admin_users_url, notice: 'ユーザー情報を更新しました。' else render :edit diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 059817fa873..8f2b5deae4e 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -38,7 +38,7 @@ def update set_wip if @announcement.update(announcement_params) - Newspaper.publish(:announcement_update, @announcement) + Newspaper.publish(:announcement_update, { announcement: @announcement }) redirect_to Redirection.determin_url(self, @announcement), notice: notice_message(@announcement) else render :edit @@ -50,7 +50,7 @@ def create @announcement.user_id = current_user.id set_wip if @announcement.save - Newspaper.publish(:announcement_create, @announcement) + Newspaper.publish(:announcement_create, { announcement: @announcement }) redirect_to Redirection.determin_url(self, @announcement), notice: notice_message(@announcement) else render :new @@ -59,7 +59,7 @@ def create def destroy @announcement.destroy - Newspaper.publish(:announcement_destroy, @announcement) + Newspaper.publish(:announcement_destroy, { announcement: @announcement }) redirect_to announcements_path, notice: 'お知らせを削除しました' end diff --git a/app/controllers/api/answers_controller.rb b/app/controllers/api/answers_controller.rb index 4d88d5f8661..9446baf6e85 100644 --- a/app/controllers/api/answers_controller.rb +++ b/app/controllers/api/answers_controller.rb @@ -29,8 +29,8 @@ def create @answer = question.answers.new(answer_params) @answer.user = current_user if @answer.save - Newspaper.publish(:answer_create, @answer) - Newspaper.publish(:answer_save, @answer) + Newspaper.publish(:answer_create, { answer: @answer }) + Newspaper.publish(:answer_save, { answer: @answer }) render :create, status: :created else head :bad_request @@ -39,7 +39,7 @@ def create def update if @answer.update(answer_params) - Newspaper.publish(:answer_save, @answer) + Newspaper.publish(:answer_save, { answer: @answer }) head :ok else head :bad_request @@ -48,7 +48,7 @@ def update def destroy @answer.destroy - Newspaper.publish(:answer_destroy, @answer) + Newspaper.publish(:answer_destroy, { answer: @answer }) end private diff --git a/app/controllers/api/correct_answers_controller.rb b/app/controllers/api/correct_answers_controller.rb index ec9d3a3efa4..d84c3369c17 100644 --- a/app/controllers/api/correct_answers_controller.rb +++ b/app/controllers/api/correct_answers_controller.rb @@ -9,7 +9,7 @@ def create @answer.type = 'CorrectAnswer' if @answer.save Newspaper.publish(:answer_save, @answer) - Newspaper.publish(:correct_answer_save, @answer) + Newspaper.publish(:correct_answer_save, { answer: @answer }) ChatNotifier.message("質問:「#{@answer.question.title}」のベストアンサーが選ばれました。\r#{url_for(@answer.question)}") render json: @answer else diff --git a/app/controllers/api/questions_controller.rb b/app/controllers/api/questions_controller.rb index b28ced39704..ea7c664932b 100644 --- a/app/controllers/api/questions_controller.rb +++ b/app/controllers/api/questions_controller.rb @@ -31,7 +31,7 @@ def show def update question = Question.find(params[:id]) if question.update(question_params) - Newspaper.publish(:question_update, question) if question.saved_change_to_wip? + Newspaper.publish(:question_update, { question: }) if question.saved_change_to_wip? head :ok else head :bad_request diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index bde3917dc6d..87ad24fe082 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -23,7 +23,7 @@ def create set_wip if @event.save update_published_at - Newspaper.publish(:event_create, @event) + Newspaper.publish(:event_create, { event: @event }) url = publish_with_announcement? ? new_announcement_path(event_id: @event.id) : Redirection.determin_url(self, @event) redirect_to url, notice: notice_message(@event) else diff --git a/app/controllers/graduation_controller.rb b/app/controllers/graduation_controller.rb index 9e9d6126a8f..f2fa004c90d 100644 --- a/app/controllers/graduation_controller.rb +++ b/app/controllers/graduation_controller.rb @@ -9,7 +9,7 @@ class GraduationController < ApplicationController def update if @user.update(graduated_on: Date.current) Subscription.new.destroy(@user.subscription_id) if @user.subscription_id - Newspaper.publish(:graduation_update, @user) + Newspaper.publish(:graduation_update, { user: @user }) redirect_to @redirect_url, notice: 'ユーザー情報を更新しました。' else redirect_to @redirect_url, alert: 'ユーザー情報の更新に失敗しました' diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index eb3b1b927c0..e81e55e496d 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -42,7 +42,7 @@ def create if @page.save url = Redirection.determin_url(self, @page) if !@page.wip? - Newspaper.publish(:page_create, @page) + Newspaper.publish(:page_create, { page: @page }) url = new_announcement_url(page_id: @page.id) if @page.announcement_of_publication? end @@ -60,7 +60,7 @@ def update if @page.update(page_params) url = Redirection.determin_url(self, @page) if @page.saved_change_to_attribute?(:wip, from: true, to: false) && @page.published_at.nil? - Newspaper.publish(:page_update, @page) + Newspaper.publish(:page_update, { page: @page }) url = new_announcement_path(page_id: @page.id) if @page.announcement_of_publication? end diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index af2db197e1b..647b5b26e58 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -63,7 +63,7 @@ def create @question.user = current_user @question.wip = params[:commit] == 'WIP' if @question.save - Newspaper.publish(:question_create, @question) + Newspaper.publish(:question_create, { question: @question }) redirect_to @question, notice: notice_message(@question) else render :new diff --git a/app/controllers/regular_events_controller.rb b/app/controllers/regular_events_controller.rb index d1fd907d0a5..2995ff939f8 100644 --- a/app/controllers/regular_events_controller.rb +++ b/app/controllers/regular_events_controller.rb @@ -25,7 +25,7 @@ def create if @regular_event.save update_publised_at Organizer.create(user_id: current_user.id, regular_event_id: @regular_event.id) - Newspaper.publish(:event_create, @regular_event) + Newspaper.publish(:event_create, { event: @regular_event }) set_all_user_participants_and_watchers path = publish_with_announcement? ? new_announcement_path(regular_event_id: @regular_event.id) : Redirection.determin_url(self, @regular_event) redirect_to path, notice: notice_message(@regular_event) @@ -40,7 +40,7 @@ def update set_wip if @regular_event.update(regular_event_params) update_publised_at - Newspaper.publish(:regular_event_update, @regular_event) + Newspaper.publish(:regular_event_update, { regular_event: @regular_event }) set_all_user_participants_and_watchers path = publish_with_announcement? ? new_announcement_path(regular_event_id: @regular_event.id) : Redirection.determin_url(self, @regular_event) redirect_to path, notice: notice_message(@regular_event) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 6e92e2fc16d..e037224b7d3 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -50,7 +50,7 @@ def create set_wip canonicalize_learning_times(@report) if @report.save - Newspaper.publish(:report_save, @report) + Newspaper.publish(:report_save, { report: @report }) redirect_to redirect_url(@report), notice: notice_message(@report), flash: flash_contents(@report) else render :new @@ -63,7 +63,7 @@ def update @report.assign_attributes(report_params) canonicalize_learning_times(@report) if @report.save - Newspaper.publish(:report_save, @report) + Newspaper.publish(:report_save, { report: @report }) redirect_to redirect_url(@report), notice: notice_message(@report), flash: flash_contents(@report) else render :edit @@ -72,7 +72,7 @@ def update def destroy @report.destroy - Newspaper.publish(:report_destroy, @report) + Newspaper.publish(:report_destroy, { report: @report }) redirect_to reports_url, notice: '日報を削除しました。' end diff --git a/app/controllers/retirement_controller.rb b/app/controllers/retirement_controller.rb index 9c45bc1e968..3d24ce74bd0 100644 --- a/app/controllers/retirement_controller.rb +++ b/app/controllers/retirement_controller.rb @@ -13,7 +13,7 @@ def create if current_user.save(context: :retirement) user = current_user current_user.delete_and_assign_new_organizer - Newspaper.publish(:retirement_create, user) + Newspaper.publish(:retirement_create, { user: }) begin UserMailer.retire(user).deliver_now rescue Postmark::InactiveRecipientError => e diff --git a/app/controllers/scheduler/daily/auto_retire_controller.rb b/app/controllers/scheduler/daily/auto_retire_controller.rb index 8e0a8cc4331..996077a8be2 100644 --- a/app/controllers/scheduler/daily/auto_retire_controller.rb +++ b/app/controllers/scheduler/daily/auto_retire_controller.rb @@ -15,7 +15,7 @@ def auto_retire user.hibernated_at = nil user.save!(validate: false) - Newspaper.publish(:retirement_create, user) + Newspaper.publish(:retirement_create, { user: }) begin UserMailer.auto_retire(user).deliver_now rescue Postmark::InactiveRecipientError => e diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9b3baa12ab3..a43953d8838 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -67,7 +67,7 @@ def create @user.course_id ||= Course.first.id @user.free = true if @user.trainee? @user.build_discord_profile - Newspaper.publish(:user_create, @user) + Newspaper.publish(:user_create, { user: @user }) if @user.staff? || @user.trainee? create_free_user! else @@ -95,7 +95,7 @@ def create_free_user! UserMailer.welcome(@user).deliver_now notify_to_mentors(@user) notify_to_chat(@user) - Newspaper.publish(:student_or_trainee_create, @user) if @user.trainee? + Newspaper.publish(:student_or_trainee_create, { user: @user }) if @user.trainee? logger.info "[Signup] 4. after create times channel for free user. #{@user.email}" redirect_to root_url, notice: 'サインアップメールをお送りしました。メールからサインアップを完了させてください。' else @@ -141,7 +141,7 @@ def create_user! UserMailer.welcome(@user).deliver_now notify_to_mentors(@user) notify_to_chat(@user) - Newspaper.publish(:student_or_trainee_create, @user) if @user.student? + Newspaper.publish(:student_or_trainee_create, { user: @user }) if @user.student? logger.info "[Signup] 8. after create times channel. #{@user.email}" redirect_to root_url, notice: 'サインアップメールをお送りしました。メールからサインアップを完了させてください。' else diff --git a/app/models/ai_answer_creator.rb b/app/models/ai_answer_creator.rb index 455b4bb750e..c12f8bba2ef 100644 --- a/app/models/ai_answer_creator.rb +++ b/app/models/ai_answer_creator.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class AIAnswerCreator - def call(question) + def call(payload) + question = payload[:question] question.update(ai_answer: '') AIAnswerCreateJob.perform_later(question_id: question.id) end diff --git a/app/models/announcement_notification_destroyer.rb b/app/models/announcement_notification_destroyer.rb index 34e696f2157..215dab100c4 100644 --- a/app/models/announcement_notification_destroyer.rb +++ b/app/models/announcement_notification_destroyer.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class AnnouncementNotificationDestroyer - def call(announce) + def call(payload) + announce = payload[:announcement] Notification.where(link: "/announcements/#{announce.id}").destroy_all end end diff --git a/app/models/announcement_notifier.rb b/app/models/announcement_notifier.rb index a4220592711..8c15cbe1fa5 100644 --- a/app/models/announcement_notifier.rb +++ b/app/models/announcement_notifier.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class AnnouncementNotifier - def call(announce) + def call(payload) + announce = payload[:announcement] return if announce.wip? || announce.published_at? announce.update(published_at: Time.current) diff --git a/app/models/answer_cache_destroyer.rb b/app/models/answer_cache_destroyer.rb index a123971bfa7..c374dc9650d 100644 --- a/app/models/answer_cache_destroyer.rb +++ b/app/models/answer_cache_destroyer.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class AnswerCacheDestroyer - def call(_answer) + def call(payload) + _answer = payload[:answer] Cache.delete_not_solved_question_count end end diff --git a/app/models/answer_notifier.rb b/app/models/answer_notifier.rb index d7bf6640b51..82ce7842c9a 100644 --- a/app/models/answer_notifier.rb +++ b/app/models/answer_notifier.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class AnswerNotifier - def call(answer) + def call(payload) + answer = payload[:answer] return if answer.sender == answer.receiver question = answer.question diff --git a/app/models/answerer_watcher.rb b/app/models/answerer_watcher.rb index 49eec104a7a..b2806571fab 100644 --- a/app/models/answerer_watcher.rb +++ b/app/models/answerer_watcher.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class AnswererWatcher - def call(answer) + def call(payload) + answer = payload[:answer] question = Question.find(answer.question_id) return if question.watches.pluck(:user_id).include?(answer.sender.id) diff --git a/app/models/correct_answer_notifier.rb b/app/models/correct_answer_notifier.rb index 813789d1f0d..6060f256ca6 100644 --- a/app/models/correct_answer_notifier.rb +++ b/app/models/correct_answer_notifier.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class CorrectAnswerNotifier - def call(answer) + def call(payload) + answer = payload[:answer] notify_correct_answer(answer) if answer.saved_change_to_attribute?('type', to: 'CorrectAnswer') end diff --git a/app/models/event_organizer_watcher.rb b/app/models/event_organizer_watcher.rb index 360fb52961d..07d35b7914a 100644 --- a/app/models/event_organizer_watcher.rb +++ b/app/models/event_organizer_watcher.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class EventOrganizerWatcher - def call(event) + def call(payload) + event = payload[:event] Watch.create!(user: event.user, watchable: event) end end diff --git a/app/models/first_report_notifier.rb b/app/models/first_report_notifier.rb index 2edafa94359..c6af69acd4b 100644 --- a/app/models/first_report_notifier.rb +++ b/app/models/first_report_notifier.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class FirstReportNotifier - def call(report) + def call(payload) + report = payload[:report] return if report.wip || !report.first? || Notification.find_by(kind: :first_report, sender_id: report.user.id).present? User.admins_and_mentors.each do |receiver| diff --git a/app/models/graduation_notifier.rb b/app/models/graduation_notifier.rb index d8014c3cebf..6ee13c4eada 100644 --- a/app/models/graduation_notifier.rb +++ b/app/models/graduation_notifier.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class GraduationNotifier - def call(user) + def call(payload) + user = payload[:user] User.mentor.each do |mentor| ActivityDelivery.with(sender: user, receiver: mentor).notify(:graduated) end diff --git a/app/models/mentors_watch_for_question_creator.rb b/app/models/mentors_watch_for_question_creator.rb index f4adfd2daa0..5ec7b653856 100644 --- a/app/models/mentors_watch_for_question_creator.rb +++ b/app/models/mentors_watch_for_question_creator.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class MentorsWatchForQuestionCreator - def call(question) + def call(payload) + question = payload[:question] return if question.wip? || question.watched? watch_question_records = watch_records(question) diff --git a/app/models/notifier_to_watching_user.rb b/app/models/notifier_to_watching_user.rb index 5656e55e36f..aef50bf573c 100644 --- a/app/models/notifier_to_watching_user.rb +++ b/app/models/notifier_to_watching_user.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class NotifierToWatchingUser - def call(answer) + def call(payload) + answer = payload[:answer] question = Question.find(answer.question_id) mention_user_ids = answer.new_mention_users.ids diff --git a/app/models/page_notifier.rb b/app/models/page_notifier.rb index f796e8f4b65..3d6685629cf 100644 --- a/app/models/page_notifier.rb +++ b/app/models/page_notifier.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class PageNotifier - def call(page) + def call(payload) + page = payload[:page] send_notification(page) notify_to_chat(page) diff --git a/app/models/question_notifier.rb b/app/models/question_notifier.rb index f60e6baefea..b93cf7cced7 100644 --- a/app/models/question_notifier.rb +++ b/app/models/question_notifier.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class QuestionNotifier - def call(question) + def call(payload) + question = payload[:question] return if question.wip? ChatNotifier.message(<<~TEXT) diff --git a/app/models/regular_event_update_notifier.rb b/app/models/regular_event_update_notifier.rb index bf799358adc..50eb8654fd8 100644 --- a/app/models/regular_event_update_notifier.rb +++ b/app/models/regular_event_update_notifier.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class RegularEventUpdateNotifier - def call(regular_event) + def call(payload) + regular_event = payload[:regular_event] participants = regular_event.participants participants.each do |participant| diff --git a/app/models/report_notifier.rb b/app/models/report_notifier.rb index 951ef733523..fbe0934df9d 100644 --- a/app/models/report_notifier.rb +++ b/app/models/report_notifier.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class ReportNotifier - def call(report) + def call(payload) + report = payload[:report] Cache.delete_unchecked_report_count return unless report.first_public? diff --git a/app/models/sad_streak_updater.rb b/app/models/sad_streak_updater.rb index 2823c464743..f230b0c71d6 100644 --- a/app/models/sad_streak_updater.rb +++ b/app/models/sad_streak_updater.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class SadStreakUpdater - def call(report) + def call(payload) + report = payload[:report] report.user.update_sad_streak end end diff --git a/app/models/sign_up_notifier.rb b/app/models/sign_up_notifier.rb index 2fd08b005d2..1eba0552ba3 100644 --- a/app/models/sign_up_notifier.rb +++ b/app/models/sign_up_notifier.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class SignUpNotifier - def call(user) + def call(payload) + user = payload[:user] user.unsubscribe_email_token = SecureRandom.urlsafe_base64 end end diff --git a/app/models/times_channel_creator.rb b/app/models/times_channel_creator.rb index 848853d4698..3a1fba9ea7b 100644 --- a/app/models/times_channel_creator.rb +++ b/app/models/times_channel_creator.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class TimesChannelCreator - def call(user) + def call(payload) + user = payload[:user] raise ArgumentError, "#{user.login_name}は現役生または研修生ではありません。" unless user.student_or_trainee? times_channel = Discord::TimesChannel.new(user.login_name) diff --git a/app/models/times_channel_destroyer.rb b/app/models/times_channel_destroyer.rb index 9483690e50a..116d2542b40 100644 --- a/app/models/times_channel_destroyer.rb +++ b/app/models/times_channel_destroyer.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class TimesChannelDestroyer - def call(user) + def call(payload) + user = payload[:user] return unless user.discord_profile.times_id if Discord::Server.delete_text_channel(user.discord_profile.times_id) diff --git a/app/models/unfinished_data_destroyer.rb b/app/models/unfinished_data_destroyer.rb index 457ed121599..2f2b6a16b2e 100644 --- a/app/models/unfinished_data_destroyer.rb +++ b/app/models/unfinished_data_destroyer.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class UnfinishedDataDestroyer - def call(user) + def call(payload) + user = payload[:user] Product.where(user: user).unchecked.destroy_all Report.where(user: user).wip.destroy_all user.update(job_seeking: false) diff --git a/test/models/event_organizer_watcher_test.rb b/test/models/event_organizer_watcher_test.rb index 535a9198037..f4bc979d6c8 100644 --- a/test/models/event_organizer_watcher_test.rb +++ b/test/models/event_organizer_watcher_test.rb @@ -6,7 +6,7 @@ class EventOrganizerWatcherTest < ActiveSupport::TestCase test '#call' do event = events(:event3) assert_difference 'Watch.where(user: event.user, watchable: event).count', 1 do - EventOrganizerWatcher.new.call(event) + EventOrganizerWatcher.new.call({ event: }) end end end diff --git a/test/models/times_channel_creator_test.rb b/test/models/times_channel_creator_test.rb index e1288082250..e92a9fd32f5 100644 --- a/test/models/times_channel_creator_test.rb +++ b/test/models/times_channel_creator_test.rb @@ -10,13 +10,13 @@ class TimesChannelCreatorTest < ActiveSupport::TestCase Rails.logger.stub(:warn, ->(message) { logs << message }) do Discord::TimesChannel.stub(:new, ->(_) { InvalidTimesChannel.new }) do - TimesChannelCreator.new.call(user) + TimesChannelCreator.new.call({ user: }) end assert_nil user.discord_profile.times_id assert_equal "[Discord API] #{user.login_name}の分報チャンネルが作成できませんでした。", logs.pop Discord::TimesChannel.stub(:new, ->(_) { ValidTimesChannel.new }) do - TimesChannelCreator.new.call(user) + TimesChannelCreator.new.call({ user: }) end assert_equal '1234567890123456789', user.discord_profile.times_id assert_nil logs.last @@ -27,21 +27,21 @@ class TimesChannelCreatorTest < ActiveSupport::TestCase user = users(:adminonly) assert user.admin? assert_raise ArgumentError do - TimesChannelCreator.new.call(user) + TimesChannelCreator.new.call({ user: }) end assert_not user.student_or_trainee? user = users(:mentormentaro) assert user.mentor? assert_raise ArgumentError do - TimesChannelCreator.new.call(user) + TimesChannelCreator.new.call({ user: }) end assert_not user.student_or_trainee? user = users(:senpai) assert user.adviser? assert_raise ArgumentError do - TimesChannelCreator.new.call(user) + TimesChannelCreator.new.call({ user: }) end assert_not user.student_or_trainee? end diff --git a/test/models/times_channel_destroyer_test.rb b/test/models/times_channel_destroyer_test.rb index 91d736156a7..6a5cece0d88 100644 --- a/test/models/times_channel_destroyer_test.rb +++ b/test/models/times_channel_destroyer_test.rb @@ -9,7 +9,7 @@ class TimesChannelDestroyerTest < ActiveSupport::TestCase user.discord_profile.update!(times_id: '987654321987654321') Rails.logger.stub(:warn, ->(message) { logs << message }) do Discord::Server.stub(:delete_text_channel, true) do - TimesChannelDestroyer.new.call(user) + TimesChannelDestroyer.new.call({ user: }) end assert_nil user.discord_profile.times_id assert_nil logs.last @@ -22,7 +22,7 @@ class TimesChannelDestroyerTest < ActiveSupport::TestCase user.discord_profile.update!(times_id: '987654321987654321') Rails.logger.stub(:warn, ->(message) { logs << message }) do Discord::Server.stub(:delete_text_channel, nil) do - TimesChannelDestroyer.new.call(user) + TimesChannelDestroyer.new.call({ user: }) end assert_equal '987654321987654321', user.discord_profile.times_id assert_equal "[Discord API] #{user.login_name}の分報チャンネルが削除できませんでした。", logs.last From 54f453827ead2f87802265abd10bbbbd03eee7be Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Wed, 3 Jan 2024 15:57:43 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=E5=AF=BE=E5=BF=9C=E3=81=8C=E6=BC=8F?= =?UTF-8?q?=E3=82=8C=E3=81=A6=E3=81=84=E3=81=9F=E5=BC=95=E6=95=B0=E3=81=AE?= =?UTF-8?q?=E3=83=8F=E3=83=83=E3=82=B7=E3=83=A5=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/correct_answers_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/correct_answers_controller.rb b/app/controllers/api/correct_answers_controller.rb index d84c3369c17..96dc0313725 100644 --- a/app/controllers/api/correct_answers_controller.rb +++ b/app/controllers/api/correct_answers_controller.rb @@ -8,7 +8,7 @@ def create @answer = @question.answers.find(params[:answer_id]) @answer.type = 'CorrectAnswer' if @answer.save - Newspaper.publish(:answer_save, @answer) + Newspaper.publish(:answer_save, { answer: @answer }) Newspaper.publish(:correct_answer_save, { answer: @answer }) ChatNotifier.message("質問:「#{@answer.question.title}」のベストアンサーが選ばれました。\r#{url_for(@answer.question)}") render json: @answer @@ -20,7 +20,7 @@ def create def update answer = @question.answers.find(params[:answer_id]) answer.update!(type: '') - Newspaper.publish(:answer_save, @answer) + Newspaper.publish(:answer_save, { answer: @answer }) end private From fc32d45f4231fe46c9fc63e03fdbc999e9669ff6 Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Wed, 10 Jan 2024 09:23:54 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=82=92=E4=BB=A3?= =?UTF-8?q?=E5=85=A5=E3=81=99=E3=82=8B=E5=A4=89=E6=95=B0=E5=90=8D=E3=82=92?= =?UTF-8?q?=E3=83=8F=E3=83=83=E3=82=B7=E3=83=A5=E3=81=AE=E3=82=AD=E3=83=BC?= =?UTF-8?q?=E3=81=A8=E5=90=8C=E3=81=98announcement=E3=81=AB=E7=B5=B1?= =?UTF-8?q?=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../announcement_notification_destroyer.rb | 4 ++-- app/models/announcement_notifier.rb | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/announcement_notification_destroyer.rb b/app/models/announcement_notification_destroyer.rb index 215dab100c4..35b96d54b86 100644 --- a/app/models/announcement_notification_destroyer.rb +++ b/app/models/announcement_notification_destroyer.rb @@ -2,7 +2,7 @@ class AnnouncementNotificationDestroyer def call(payload) - announce = payload[:announcement] - Notification.where(link: "/announcements/#{announce.id}").destroy_all + announcement = payload[:announcement] + Notification.where(link: "/announcements/#{announcement.id}").destroy_all end end diff --git a/app/models/announcement_notifier.rb b/app/models/announcement_notifier.rb index 8c15cbe1fa5..3e4d2dbd0b1 100644 --- a/app/models/announcement_notifier.rb +++ b/app/models/announcement_notifier.rb @@ -2,18 +2,18 @@ class AnnouncementNotifier def call(payload) - announce = payload[:announcement] - return if announce.wip? || announce.published_at? + announcement = payload[:announcement] + return if announcement.wip? || announcement.published_at? - announce.update(published_at: Time.current) - DiscordNotifier.with(announce: announce).announced.notify_now - Watch.create!(user: announce.user, watchable: announce) + announcement.update(published_at: Time.current) + DiscordNotifier.with(announce: announcement).announced.notify_now + Watch.create!(user: announcement.user, watchable: announcement) - target_users = User.announcement_receiver(announce.target) + target_users = User.announcement_receiver(announcement.target) target_users.each do |target| - next if announce.sender == target + next if announcement.sender == target - ActivityDelivery.with(announcement: announce, receiver: target).notify(:post_announcement) + ActivityDelivery.with(announcement: announcement, receiver: target).notify(:post_announcement) end end end From 88dedbc043d5815a579f958634a74030f4a3b382 Mon Sep 17 00:00:00 2001 From: nicole2525 Date: Thu, 11 Jan 2024 08:36:09 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E3=82=AD=E3=83=BC=E3=81=A8=E5=80=A4?= =?UTF-8?q?=E3=81=8C=E5=90=8C=E5=80=A4=E3=81=A7=E3=81=82=E3=82=8B=E3=83=8F?= =?UTF-8?q?=E3=83=83=E3=82=B7=E3=83=A5=E3=81=AE=E8=A8=98=E8=BF=B0=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/announcement_notifier.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/announcement_notifier.rb b/app/models/announcement_notifier.rb index 3e4d2dbd0b1..a0c3e8b9807 100644 --- a/app/models/announcement_notifier.rb +++ b/app/models/announcement_notifier.rb @@ -13,7 +13,7 @@ def call(payload) target_users.each do |target| next if announcement.sender == target - ActivityDelivery.with(announcement: announcement, receiver: target).notify(:post_announcement) + ActivityDelivery.with(announcement:, receiver: target).notify(:post_announcement) end end end