Skip to content

Commit

Permalink
相談部屋のコメントをDiscordチャットに通知する
Browse files Browse the repository at this point in the history
  • Loading branch information
garammasala29 committed Feb 15, 2022
1 parent 03afc32 commit 2689ceb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/models/comment/after_create_callback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def after_create(comment)

if comment.commentable.instance_of?(Talk)
notify_to_admins(comment)
notify_to_chat(comment) unless comment.sender.admin?
update_unreplied(comment)
end

Expand Down Expand Up @@ -107,4 +108,12 @@ def update_unreplied(comment)
unreplied = !comment.user.admin
comment.commentable.update!(unreplied: unreplied)
end

def notify_to_chat(comment)
ChatNotifier.message(<<~TEXT, webhook_url: ENV['DISCORD_ADMIN_WEBHOOK_URL'])
相談部屋にて#{comment.user.login_name}さんからコメントがありました。
本文: #{comment.description}
URL: https://bootcamp.fjord.jp/talks/#{comment.commentable_id}
TEXT
end
end

0 comments on commit 2689ceb

Please sign in to comment.