mirror of
https://github.com/discourse/discourse-chat-integration.git
synced 2025-07-05 13:42:09 +00:00
Minor refactor.
This commit is contained in:
parent
2e69d6a934
commit
efddfe1d9b
@ -34,17 +34,20 @@ module DiscourseChat::Provider::SlackProvider
|
|||||||
|
|
||||||
provider = DiscourseChat::Provider::SlackProvider::PROVIDER_NAME
|
provider = DiscourseChat::Provider::SlackProvider::PROVIDER_NAME
|
||||||
|
|
||||||
channel = DiscourseChat::Channel.with_provider(provider).with_data_value('identifier', channel_id).first
|
channel = DiscourseChat::Channel.with_provider(provider)
|
||||||
|
.with_data_value('identifier', channel_id)
|
||||||
|
.first
|
||||||
|
|
||||||
# Create channel if doesn't exist
|
channel ||= DiscourseChat::Channel.create!(
|
||||||
channel ||= DiscourseChat::Channel.create!(provider: provider, data: { identifier: channel_id })
|
provider: provider,
|
||||||
|
data: { identifier: channel_id }
|
||||||
|
)
|
||||||
|
|
||||||
if tokens[0] == 'post'
|
if tokens[0] == 'post'
|
||||||
return process_post_request(channel, tokens, params[:channel_id], channel_id, params[:response_url])
|
process_post_request(channel, tokens, params[:channel_id], channel_id, params[:response_url])
|
||||||
|
else
|
||||||
|
{ text: ::DiscourseChat::Helper.process_command(channel, tokens) }
|
||||||
end
|
end
|
||||||
|
|
||||||
return { text: ::DiscourseChat::Helper.process_command(channel, tokens) }
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_post_request(channel, tokens, slack_channel_id, channel_name, response_url)
|
def process_post_request(channel, tokens, slack_channel_id, channel_name, response_url)
|
||||||
@ -89,7 +92,6 @@ module DiscourseChat::Provider::SlackProvider
|
|||||||
end
|
end
|
||||||
|
|
||||||
return { text: I18n.t("chat_integration.provider.slack.transcript.loading") }
|
return { text: I18n.t("chat_integration.provider.slack.transcript.loading") }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def interactive
|
def interactive
|
||||||
|
12
plugin.rb
12
plugin.rb
@ -12,19 +12,15 @@ register_asset "stylesheets/chat-integration-admin.scss"
|
|||||||
require_relative "lib/discourse_chat/provider/slack/slack_enabled_setting_validator"
|
require_relative "lib/discourse_chat/provider/slack/slack_enabled_setting_validator"
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
|
|
||||||
require_relative "app/initializers/discourse_chat"
|
require_relative "app/initializers/discourse_chat"
|
||||||
|
|
||||||
DiscourseEvent.on(:post_created) do |post|
|
on(:post_created) do |post|
|
||||||
if SiteSetting.chat_integration_enabled?
|
# This will run for every post, even PMs. Don't worry, they're filtered out later.
|
||||||
# This will run for every post, even PMs. Don't worry, they're filtered out later.
|
time = SiteSetting.chat_integration_delay_seconds.seconds
|
||||||
time = SiteSetting.chat_integration_delay_seconds.seconds
|
Jobs.enqueue_in(time, :notify_chats, post_id: post.id)
|
||||||
Jobs.enqueue_in(time, :notify_chats, post_id: post.id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
add_admin_route 'chat_integration.menu_title', 'chat'
|
add_admin_route 'chat_integration.menu_title', 'chat'
|
||||||
|
|
||||||
DiscourseChat::Provider.mount_engines
|
DiscourseChat::Provider.mount_engines
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user