5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2025-02-23 23:11:49 +00:00

Merge branch 'issue-13244' of 0xacab.org:sutty/sutty into production.panel.sutty.nl

This commit is contained in:
f 2024-05-02 15:30:44 -03:00
commit 81b06f75ab
No known key found for this signature in database
4 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
module AutoPublishConcern
extend ActiveSupport::Concern
included do
def auto_publish!
DeployJob.perform_later(site) if site.auto_publish?
end
end
end

View file

@ -3,6 +3,8 @@
# Este servicio se encarga de crear artículos y guardarlos en git,
# asignándoselos a une usuarie
PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
include AutoPublishConcern
# Crea un artículo nuevo
#
# @return Post
@ -29,6 +31,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
# Devolver el post aunque no se haya salvado para poder rescatar los
# errores
post
auto_publish!
end
# Crear un post anónimo, con opciones más limitadas. No usamos post.
@ -42,6 +45,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
commit(action: :created, add: files) if post.update(anon_post_params)
post
auto_publish!
end
def update
@ -66,6 +70,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
# Devolver el post aunque no se haya salvado para poder rescatar los
# errores
post
auto_publish!
end
def destroy

View file

@ -3,6 +3,8 @@
# Se encargar de guardar cambios en sitios
# TODO: Implementar rollback en la configuración
SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
include AutoPublishConcern
def deploy
site.enqueue!
DeployJob.perform_later site

View file

@ -0,0 +1,8 @@
# frozen_string_literal: true
# Agrega posibilidad de autopublicación del sitio
class AddAutopublishToSites < ActiveRecord::Migration[6.1]
def change
add_column :sites, :auto_publish, :boolean, default: false
end
end