2017-07-03 06:08:14 -04:00
|
|
|
# name: discourse-chat-integration
|
2017-06-26 10:08:06 -04:00
|
|
|
# about: This plugin integrates discourse with a number of chat providers
|
|
|
|
# version: 0.1
|
2017-07-03 06:08:14 -04:00
|
|
|
# url: https://github.com/discourse/discourse-chat-integration
|
2017-07-13 08:32:11 -04:00
|
|
|
# author: David Taylor
|
2017-06-26 10:08:06 -04:00
|
|
|
|
2017-07-03 06:08:14 -04:00
|
|
|
enabled_site_setting :chat_integration_enabled
|
2017-06-26 10:08:06 -04:00
|
|
|
|
2017-07-03 17:11:17 -04:00
|
|
|
register_asset "stylesheets/chat-integration-admin.scss"
|
|
|
|
|
2017-07-03 11:28:26 -04:00
|
|
|
# Site setting validators must be loaded before initialize
|
2017-07-13 08:32:11 -04:00
|
|
|
require_relative "lib/discourse_chat/provider/slack/slack_enabled_setting_validator"
|
2017-06-29 12:50:54 -04:00
|
|
|
|
2017-06-26 10:08:06 -04:00
|
|
|
after_initialize do
|
|
|
|
|
2017-07-13 08:32:11 -04:00
|
|
|
require_relative "app/initializers/discourse_chat"
|
2017-06-26 10:08:06 -04:00
|
|
|
|
2017-07-13 08:32:11 -04:00
|
|
|
require_relative "app/models/plugin_model"
|
|
|
|
require_relative "app/models/rule"
|
|
|
|
require_relative "app/models/channel"
|
2017-06-29 12:01:04 -04:00
|
|
|
|
2017-07-18 11:17:03 -04:00
|
|
|
require_relative "app/serializers/channel_serializer"
|
2017-07-13 08:32:11 -04:00
|
|
|
require_relative "app/serializers/rule_serializer"
|
|
|
|
|
|
|
|
require_relative "app/controllers/chat_controller"
|
2017-06-29 12:01:04 -04:00
|
|
|
|
2017-07-13 08:32:11 -04:00
|
|
|
require_relative "app/routes/discourse_chat"
|
|
|
|
require_relative "app/routes/discourse"
|
2017-06-29 12:01:04 -04:00
|
|
|
|
2017-07-13 08:32:11 -04:00
|
|
|
require_relative "app/helpers/helper"
|
|
|
|
|
|
|
|
require_relative "app/services/manager"
|
2017-06-29 12:01:04 -04:00
|
|
|
|
2017-07-13 08:32:11 -04:00
|
|
|
require_relative "app/jobs/regular/notify_chats"
|
2017-06-26 14:19:50 -04:00
|
|
|
|
2017-06-30 06:10:11 -04:00
|
|
|
require_relative "lib/discourse_chat/provider"
|
2017-07-13 08:32:11 -04:00
|
|
|
|
2017-06-30 06:10:11 -04:00
|
|
|
DiscourseEvent.on(:post_created) do |post|
|
2017-07-03 06:08:14 -04:00
|
|
|
if SiteSetting.chat_integration_enabled?
|
2017-06-30 06:10:11 -04:00
|
|
|
# This will run for every post, even PMs. Don't worry, they're filtered out later.
|
2017-07-13 08:32:11 -04:00
|
|
|
time = SiteSetting.chat_integration_delay_seconds.seconds
|
|
|
|
Jobs.enqueue_in(time, :notify_chats, post_id: post.id)
|
2017-06-29 12:50:54 -04:00
|
|
|
end
|
2017-06-26 14:19:50 -04:00
|
|
|
end
|
|
|
|
|
2017-07-03 10:53:26 -04:00
|
|
|
add_admin_route 'chat_integration.menu_title', 'chat'
|
2017-06-26 14:19:50 -04:00
|
|
|
|
2017-07-05 10:03:02 -04:00
|
|
|
DiscourseChat::Provider.mount_engines
|
|
|
|
|
2017-06-26 10:08:06 -04:00
|
|
|
end
|