Browse Source

Stub out Glitch::ApplyKeywordMutesService. #199.

This service will apply/unapply keyword mutes to home and mentions
timelines.  Maybe other timelines if I find a way to make it work.
199-add-remove-keyword-mutes-should-remove-add-statuses-to-the-feeds
David Yip 3 years ago
parent
commit
083f78b8fb
No known key found for this signature in database GPG Key ID: 7DA0036508FCC0CC
  1. 4
      app/controllers/settings/keyword_mutes_controller.rb
  2. 6
      app/services/glitch/apply_keyword_mutes_service.rb
  3. 13
      app/workers/glitch/apply_keyword_mutes_worker.rb
  4. 5
      spec/services/glitch/apply_keyword_mutes_service_spec.rb

4
app/controllers/settings/keyword_mutes_controller.rb

@ -15,6 +15,7 @@ class Settings::KeywordMutesController < Settings::BaseController
@keyword_mute = keyword_mutes_for_account.create(keyword_mute_params)
if @keyword_mute.persisted?
Glitch::ApplyKeywordMutesWorker.perform_async(current_account.id)
redirect_to settings_keyword_mutes_path, notice: I18n.t('generic.changes_saved_msg')
else
render :new
@ -23,6 +24,7 @@ class Settings::KeywordMutesController < Settings::BaseController
def update
if @keyword_mute.update(keyword_mute_params)
Glitch::ApplyKeywordMutesWorker.perform_async(current_account.id)
redirect_to settings_keyword_mutes_path, notice: I18n.t('generic.changes_saved_msg')
else
render :edit
@ -32,12 +34,14 @@ class Settings::KeywordMutesController < Settings::BaseController
def destroy
@keyword_mute.destroy!
Glitch::ApplyKeywordMutesWorker.perform_async(current_account.id)
redirect_to settings_keyword_mutes_path, notice: I18n.t('generic.changes_saved_msg')
end
def destroy_all
keyword_mutes_for_account.delete_all
Glitch::ApplyKeywordMutesWorker.perform_async(current_account.id)
redirect_to settings_keyword_mutes_path, notice: I18n.t('generic.changes_saved_msg')
end

6
app/services/glitch/apply_keyword_mutes_service.rb

@ -0,0 +1,6 @@
module Glitch
class ApplyKeywordMutesService < BaseService
def call(account)
end
end
end

13
app/workers/glitch/apply_keyword_mutes_worker.rb

@ -0,0 +1,13 @@
# frozen_string_literal: true
module Glitch
class ApplyKeywordMutesWorker
include Sidekiq::Worker
sidekiq_options unique: :until_executed
def perform(account_id)
Glitch::ApplyKeywordMutesService.new.call(Account.find(account_id))
end
end
end

5
spec/services/glitch/apply_keyword_mutes_service_spec.rb

@ -0,0 +1,5 @@
require 'rails_helper'
describe Glitch::ApplyKeywordMutesService, type: :service do
end
Loading…
Cancel
Save