mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 01:26:22 +00:00
fix: los guards se ejecutan todo el tiempo
This commit is contained in:
parent
591d56581e
commit
a1b5e385b0
1 changed files with 21 additions and 6 deletions
|
@ -13,15 +13,27 @@ class InstanceModeration < ApplicationRecord
|
|||
state :blocked
|
||||
|
||||
event :pause do
|
||||
transitions from: %i[allowed blocked], to: :paused, guard: :pause_remotely!
|
||||
transitions from: %i[allowed blocked], to: :paused
|
||||
|
||||
before do
|
||||
pause_remotely!
|
||||
end
|
||||
end
|
||||
|
||||
event :allow do
|
||||
transitions from: %i[paused blocked], to: :allowed, guard: :allow_remotely!
|
||||
transitions from: %i[paused blocked], to: :allowed
|
||||
|
||||
before do
|
||||
allow_remotely!
|
||||
end
|
||||
end
|
||||
|
||||
event :block do
|
||||
transitions from: %i[paused allowed], to: :blocked, guard: :block_remotely!
|
||||
transitions from: %i[paused allowed], to: :blocked
|
||||
|
||||
before do
|
||||
block_remotely!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,6 +41,7 @@ class InstanceModeration < ApplicationRecord
|
|||
#
|
||||
# @return [Boolean]
|
||||
def pause_remotely!
|
||||
raise AASM::InvalidTransition unless
|
||||
site.social_inbox.blocklist.delete(list: [instance.list_name]).ok? &&
|
||||
site.social_inbox.allowlist.delete(list: [instance.list_name]).ok?
|
||||
end
|
||||
|
@ -37,6 +50,7 @@ class InstanceModeration < ApplicationRecord
|
|||
#
|
||||
# @return [Boolean]
|
||||
def block_remotely!
|
||||
raise AASM::InvalidTransition unless
|
||||
site.social_inbox.allowlist.delete(list: [instance.list_name]).ok? &&
|
||||
site.social_inbox.blocklist.post(list: [instance.list_name]).ok?
|
||||
end
|
||||
|
@ -45,6 +59,7 @@ class InstanceModeration < ApplicationRecord
|
|||
#
|
||||
# @return [Boolean]
|
||||
def allow_remotely!
|
||||
raise AASM::InvalidTransition unless
|
||||
site.social_inbox.blocklist.delete(list: [instance.list_name]).ok? &&
|
||||
site.social_inbox.allowlist.post(list: [instance.list_name]).ok?
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue