mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 00:51:41 +00:00
Merge branch 'issue-15109' of 0xacab.org:sutty/sutty into production.panel.sutty.nl
This commit is contained in:
commit
6a0ccbd004
2 changed files with 26 additions and 11 deletions
|
@ -38,21 +38,33 @@ module Api
|
|||
head :accepted
|
||||
end
|
||||
|
||||
# Cuando aprobamos una actividad, recibimos la confirmación y
|
||||
# cambiamos el estado.
|
||||
# Cuando la Social Inbox acepta una actividad, la recibimos
|
||||
# igual y la guardamos por si cambiamos de idea.
|
||||
#
|
||||
# @todo DRY
|
||||
def onapproved
|
||||
ActivityPub.transaction do
|
||||
activity_pub.approve! if activity_pub.waiting?
|
||||
actor.present?
|
||||
instance.present?
|
||||
object.present?
|
||||
activity.present?
|
||||
activity_pub.approve!
|
||||
end
|
||||
|
||||
head :accepted
|
||||
end
|
||||
|
||||
# Cuando rechazamos una actividad, recibimos la confirmación y
|
||||
# cambiamos el estado
|
||||
# Cuando la Social Inbox rechaza una actividad, la recibimos
|
||||
# igual y la guardamos por si cambiamos de idea.
|
||||
#
|
||||
# @todo DRY
|
||||
def onrejected
|
||||
ActivityPub.transaction do
|
||||
activity_pub.reject! if activity_pub.waiting?
|
||||
actor.present?
|
||||
instance.present?
|
||||
object.present?
|
||||
activity.present?
|
||||
activity_pub.reject!
|
||||
end
|
||||
|
||||
head :accepted
|
||||
|
|
|
@ -21,8 +21,6 @@ class ActivityPub < ApplicationRecord
|
|||
aasm do
|
||||
# Todavía no hay una decisión sobre el objeto
|
||||
state :paused, initial: true
|
||||
# Estamos esperando respuesta desde la Social Inbox
|
||||
state :waiting
|
||||
# Le usuarie aprobó el objeto
|
||||
state :approved
|
||||
# Le usuarie rechazó el objeto
|
||||
|
@ -46,17 +44,22 @@ class ActivityPub < ApplicationRecord
|
|||
# Si un objeto previamente aprobado fue actualizado, volvemos a
|
||||
# pausarlo.
|
||||
event :pause do
|
||||
transitions from: %i[waiting approved rejected], to: :paused
|
||||
transitions from: %i[approved rejected], to: :paused
|
||||
end
|
||||
|
||||
# La actividad se aprueba
|
||||
event :approve do
|
||||
transitions from: :waiting, to: :approved
|
||||
transitions from: %i[paused rejected], to: :approved
|
||||
end
|
||||
|
||||
# La actividad fue rechazada
|
||||
event :reject do
|
||||
transitions from: :waiting, to: :rejected
|
||||
transitions from: %i[paused approved], to: :rejected
|
||||
end
|
||||
|
||||
# Solo podemos reportarla luego de rechazarla
|
||||
event :report do
|
||||
transitions from: :rejected, to: :reported
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue