forum: automatically post new forum posts to Discord.
This commit is contained in:
@@ -23,6 +23,7 @@ class ForumPost < ApplicationRecord
|
||||
after_destroy(:if => ->(rec) {rec.updater_id != rec.creator_id}) do |rec|
|
||||
ModAction.log("#{CurrentUser.user.name} deleted forum ##{rec.id}", :forum_post_delete)
|
||||
end
|
||||
after_create_commit :async_send_discord_notification
|
||||
|
||||
deletable
|
||||
mentionable(
|
||||
@@ -153,6 +154,15 @@ class ForumPost < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def async_send_discord_notification
|
||||
DiscordNotificationJob.perform_later(forum_post: self)
|
||||
end
|
||||
|
||||
def send_discord_notification
|
||||
return unless policy(User.anonymous).show?
|
||||
DiscordApiClient.new.post_message(self)
|
||||
end
|
||||
|
||||
def build_response
|
||||
dup.tap do |x|
|
||||
x.body = x.quoted_response
|
||||
|
||||
Reference in New Issue
Block a user