-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.rb
executable file
·47 lines (37 loc) · 1.46 KB
/
plugin.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true
# name: discourse-livestream
# about: Plugin to add livestream functionality to Discourse
# version: 0.0.1
# authors: Discourse
# url: https://github.com/discourse/discourse-livestream
# required_version: 2.7.0
enabled_site_setting :discourse_livestream_enabled
register_asset "stylesheets/common/base-common.scss"
register_asset "stylesheets/desktop/base-desktop.scss", :desktop
register_asset "stylesheets/mobile/base-mobile.scss", :mobile
after_initialize do
module ::DiscourseLivestream
PLUGIN_NAME = "discourse-livestream"
class Engine < ::Rails::Engine
engine_name PLUGIN_NAME
isolate_namespace DiscourseLivestream
end
end
Discourse::Application.routes.append { mount ::DiscourseLivestream::Engine, at: "/" }
require_relative "lib/discourse_livestream/topic_extension"
require_relative "lib/discourse_livestream/handle_topic_chat_channel_creation"
require_relative "app/models/discourse_livestream/topic_chat_channel"
reloadable_patch do
Topic.prepend DiscourseLivestream::TopicExtension
add_to_serializer(:topic_view, :chat_channel_id) do
return nil if object.topic.topic_chat_channel.blank?
object.topic.topic_chat_channel.chat_channel_id
end
on(:post_edited) do |post, _, _|
DiscourseLivestream.handle_topic_chat_channel_creation(post.topic)
end
on(:topic_created) do |topic, _, _|
DiscourseLivestream.handle_topic_chat_channel_creation(topic)
end
end
end