Skip to content

Commit

Permalink
Added setting to ignore specific NNTP messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sman591 committed Jul 4, 2016
1 parent 3ea961b commit 4fedc13
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ en:
nntp_bridge_invalid_body_replacement: "Post body to use when the body from NNTP is invalid."
nntp_bridge_nntp_user_agent: "User agent header for NNTP posts created by Discourse"
nntp_bridge_default_newsgroup: "Default NNTP newsgroup"
nntp_bridge_ignore_messages: "Skip importing these message IDs. Comma-separated."
3 changes: 3 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ plugins:
nntp_bridge_default_newsgroup:
default: general
client: true
nntp_bridge_ignore_messages:
default: ""
client: true
5 changes: 3 additions & 2 deletions lib/discourse_nntp_bridge/newsgroup_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ def sync!(newsgroup)
local_message_ids = NntpPost.pluck(:message_id)
remote_message_ids = @server.message_ids([newsgroup])
# message_ids_to_destroy = local_message_ids - remote_message_ids
message_ids_to_import = remote_message_ids - local_message_ids
message_ids_to_import = message_ids_to_import
ignore_ids = SiteSetting.nntp_bridge_ignore_messages.split(",").collect(&:strip)

message_ids_to_import = remote_message_ids - local_message_ids - ignore_ids

# if message_ids_to_destroy.any?
# puts "Deleting #{message_ids_to_destroy.size} posts" if File.basename($0) == 'rake'
Expand Down

0 comments on commit 4fedc13

Please sign in to comment.