-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplugin.rb
38 lines (28 loc) · 1.05 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
# frozen_string_literal: true
# name: discourse-nntp-bridge
# about: Discourse plugin to keep NNTP & Discourse in sync
# version: 0.1.14
# authors: Stuart Olivera
# url: https://github.com/sman591/discourse-nntp-bridge
enabled_site_setting :nntp_bridge_enabled
# install dependencies
gem 'active_attr', '0.10.3'
gem 'thoughtafter-nntp', '1.0.0.3', require: false
gem 'rfc2047', '0.3', github: 'ConradIrwin/rfc2047-ruby'
gem 'codeclimate-test-reporter', '0.5.0', require: nil if ENV['RUN_COVERAGE']
require 'nntp'
require_relative 'lib/discourse_nntp_bridge'
after_initialize do
class DiscourseNntpBridge::NntpPost < ActiveRecord::Base
belongs_to :post
validates :post_id, :message_id, presence: true
validates :message_id, uniqueness: true
end
Post.class_eval do
has_many :nntp_posts, class_name: 'DiscourseNntpBridge::NntpPost', dependent: :destroy
end
on(:post_created) do |post|
require_dependency File.expand_path('app/jobs/regular/nntp_bridge_exporter.rb', __dir__)
Jobs.enqueue(:nntp_bridge_exporter, post_id: post.id)
end
end