Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

相談部屋のコメントをDiscordチャットに通知する #4206

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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