forked from gdpelican/babble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.rb
96 lines (79 loc) · 3.08 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# name: babble
# about: Shoutbox plugin for Discourse
# version: 4.2.0
# authors: James Kiesel (gdpelican)
# url: https://github.com/gdpelican/babble
register_asset "stylesheets/babble.scss"
enabled_site_setting :babble_enabled
if respond_to?(:register_svg_icon)
register_svg_icon "expand"
register_svg_icon "bullhorn"
register_svg_icon "paperclip"
register_svg_icon "far-trash-alt"
end
def babble_require(path)
require Rails.root.join('plugins', 'babble', 'app', path).to_s
end
babble_require 'extras/position_options'
after_initialize do
module ::Babble
BABBLE_PLUGIN_NAME ||= 'babble'
class Engine < ::Rails::Engine
engine_name BABBLE_PLUGIN_NAME
isolate_namespace Babble
end
end
babble_require 'routes/babble'
babble_require 'routes/discourse'
babble_require 'controllers/controller'
babble_require 'controllers/admin/chats_controller'
babble_require 'controllers/root_controller'
babble_require 'controllers/topics_controller'
babble_require 'controllers/posts_controller'
babble_require 'serializers/basic_topic_serializer'
babble_require 'serializers/notification_serializer'
babble_require 'serializers/post_serializer'
babble_require 'serializers/site_serializer'
babble_require 'serializers/summary_serializer'
babble_require 'serializers/topic_serializer'
babble_require 'serializers/user_serializer'
babble_require 'serializers/boot_serializer'
babble_require 'services/backfiller'
babble_require 'services/post_creator'
babble_require 'services/post_alerter'
babble_require 'services/post_destroyer'
babble_require 'services/post_revisor'
babble_require 'services/broadcaster'
babble_require 'services/post_stream_window'
babble_require 'models/archetype'
babble_require 'models/chat'
babble_require 'models/guardian'
babble_require 'models/group'
babble_require 'models/notification'
babble_require 'models/post'
babble_require 'models/search'
babble_require 'models/topic_query'
babble_require 'models/topic'
babble_require 'models/user'
babble_require 'models/user_action'
babble_require 'models/user_summary'
babble_require 'models/chats/base'
babble_require 'models/chats/category'
babble_require 'models/chats/group'
babble_require 'models/chats/pm'
babble_require 'jobs/regular/babble_post_alert'
babble_require 'jobs/scheduled/babble_prune_history'
Babble::Backfiller.backfill_visibility_level
register_editable_user_custom_field :babble_disabled
register_editable_user_custom_field :babble_sound
register_editable_user_custom_field :babble_open_by_default
DiscoursePluginRegistry.serialized_current_user_fields << 'babble_disabled'
DiscoursePluginRegistry.serialized_current_user_fields << 'babble_sound'
DiscoursePluginRegistry.serialized_current_user_fields << 'babble_open_by_default'
on :post_created do |post, opts, user|
if post.topic&.archetype == Archetype.chat
TopicUser.update_last_read(user, post.topic_id, post.post_number, post.post_number, PostTiming::MAX_READ_TIME_PER_BATCH)
Jobs.enqueue(:babble_post_alert, post_id: post.id)
end
end
end