mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 00:46:23 +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
|
state :blocked
|
||||||
|
|
||||||
event :pause do
|
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
|
end
|
||||||
|
|
||||||
event :allow do
|
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
|
end
|
||||||
|
|
||||||
event :block do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,7 +41,8 @@ class InstanceModeration < ApplicationRecord
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def pause_remotely!
|
def pause_remotely!
|
||||||
site.social_inbox.blocklist.delete(list: [instance.list_name]).ok? &&
|
raise AASM::InvalidTransition unless
|
||||||
|
site.social_inbox.blocklist.delete(list: [instance.list_name]).ok? &&
|
||||||
site.social_inbox.allowlist.delete(list: [instance.list_name]).ok?
|
site.social_inbox.allowlist.delete(list: [instance.list_name]).ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,7 +50,8 @@ class InstanceModeration < ApplicationRecord
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def block_remotely!
|
def block_remotely!
|
||||||
site.social_inbox.allowlist.delete(list: [instance.list_name]).ok? &&
|
raise AASM::InvalidTransition unless
|
||||||
|
site.social_inbox.allowlist.delete(list: [instance.list_name]).ok? &&
|
||||||
site.social_inbox.blocklist.post(list: [instance.list_name]).ok?
|
site.social_inbox.blocklist.post(list: [instance.list_name]).ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,7 +59,8 @@ class InstanceModeration < ApplicationRecord
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def allow_remotely!
|
def allow_remotely!
|
||||||
site.social_inbox.blocklist.delete(list: [instance.list_name]).ok? &&
|
raise AASM::InvalidTransition unless
|
||||||
|
site.social_inbox.blocklist.delete(list: [instance.list_name]).ok? &&
|
||||||
site.social_inbox.allowlist.post(list: [instance.list_name]).ok?
|
site.social_inbox.allowlist.post(list: [instance.list_name]).ok?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue