about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2017-10-21 14:47:17 -0500
committerDavid Yip <yipdw@member.fsf.org>2017-10-21 14:54:36 -0500
commit670e6a33f8eeca628707dc020e02ce32502d74a4 (patch)
tree527043ee2b85d5a18dc5c51acd7277fc560b3e78 /app
parentcd04e3df58c09b0faca81ccc820b2cd5e12c2890 (diff)
Move KeywordMute into Glitch namespace.
There are two motivations for this:

1. It looks like we're going to add other features that require
   server-side storage (e.g. user notes).

2. Namespacing glitchsoc modifications is a good idea anyway: even if we
   do not end up doing (1), if upstream introduces a keyword-mute feature
   that also uses a "KeywordMute" model, we can avoid some merge
   conflicts this way and work on the more interesting task of
   choosing which implementation to use.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/settings/keyword_mutes_controller.rb2
-rw-r--r--app/lib/feed_manager.rb2
-rw-r--r--app/models/glitch.rb7
-rw-r--r--app/models/glitch/keyword_mute.rb (renamed from app/models/keyword_mute.rb)6
4 files changed, 12 insertions, 5 deletions
diff --git a/app/controllers/settings/keyword_mutes_controller.rb b/app/controllers/settings/keyword_mutes_controller.rb
index d9f99af09..6ae05108d 100644
--- a/app/controllers/settings/keyword_mutes_controller.rb
+++ b/app/controllers/settings/keyword_mutes_controller.rb
@@ -55,7 +55,7 @@ class Settings::KeywordMutesController < ApplicationController
   end
 
   def keyword_mutes_for_account
-    KeywordMute.where(account: @account)
+    Glitch::KeywordMute.where(account: @account)
   end
 
   def load_keyword_mute
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 516bd81af..1123f88bb 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -138,7 +138,7 @@ class FeedManager
   end
 
   def filter_from_home?(status, receiver_id)
-    return true if KeywordMute.matcher_for(receiver_id) =~ status.text
+    return true if Glitch::KeywordMute.matcher_for(receiver_id) =~ status.text
 
     return false if receiver_id == status.account_id
     return true  if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
diff --git a/app/models/glitch.rb b/app/models/glitch.rb
new file mode 100644
index 000000000..0e497babc
--- /dev/null
+++ b/app/models/glitch.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+module Glitch
+  def self.table_name_prefix
+    'glitch_'
+  end
+end
diff --git a/app/models/keyword_mute.rb b/app/models/glitch/keyword_mute.rb
index b0229923d..3b0b47f52 100644
--- a/app/models/keyword_mute.rb
+++ b/app/models/glitch/keyword_mute.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 # == Schema Information
 #
-# Table name: keyword_mutes
+# Table name: glitch_keyword_mutes
 #
 #  id         :integer          not null, primary key
 #  account_id :integer          not null
@@ -11,7 +11,7 @@
 #  updated_at :datetime         not null
 #
 
-class KeywordMute < ApplicationRecord
+class Glitch::KeywordMute < ApplicationRecord
   belongs_to :account, required: true
 
   validates_presence_of :keyword
@@ -33,7 +33,7 @@ class KeywordMute < ApplicationRecord
 
     def initialize(account_id)
       re = [].tap do |arr|
-        KeywordMute.where(account_id: account_id).select(:keyword, :id, :whole_word).find_each do |m|
+        Glitch::KeywordMute.where(account_id: account_id).select(:keyword, :id, :whole_word).find_each do |m|
           boundary = m.whole_word ? '\b' : ''
           arr << "#{boundary}#{Regexp.escape(m.keyword.strip)}#{boundary}"
         end