diff options
author | Kit Redgrave <qwertyitis@gmail.com> | 2017-02-05 19:51:56 -0600 |
---|---|---|
committer | Kit Redgrave <qwertyitis@gmail.com> | 2017-03-01 22:31:21 -0600 |
commit | 442fdbfc5309f46c23a073829e5fe16d10c7c6ca (patch) | |
tree | ee8195e874e83722990cfaca7b65fc54383caaf9 /app/services | |
parent | 89fc2d7f4810ecdf66b17543f4603c1089a0c3f5 (diff) |
Mute button progress so far. WIP, doesn't entirely work correctly.
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/mute_service.rb | 23 | ||||
-rw-r--r-- | app/services/unmute_service.rb | 9 |
2 files changed, 32 insertions, 0 deletions
diff --git a/app/services/mute_service.rb b/app/services/mute_service.rb new file mode 100644 index 000000000..0050cfc8d --- /dev/null +++ b/app/services/mute_service.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +class MuteService < BaseService + def call(account, target_account) + return if account.id == target_account.id + clear_home_timeline(account, target_account) + account.mute!(target_account) + end + + private + + def clear_home_timeline(account, target_account) + home_key = FeedManager.instance.key(:home, account.id) + + target_account.statuses.select('id').find_each do |status| + redis.zrem(home_key, status.id) + end + end + + def redis + Redis.current + end +end diff --git a/app/services/unmute_service.rb b/app/services/unmute_service.rb new file mode 100644 index 000000000..ed268b7c5 --- /dev/null +++ b/app/services/unmute_service.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class UnmuteService < BaseService + def call(account, target_account) + return unless account.muting?(target_account) + + account.unmute!(target_account) + end +end |