mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-22 21:01:51 +00:00
Merge branch 'production.panel.sutty.nl' into panel.testing.sutty.nl
This commit is contained in:
commit
e93cdcfd7b
10 changed files with 65 additions and 31 deletions
|
@ -1,5 +1,5 @@
|
||||||
.apk-add: &apk-add
|
.apk-add: &apk-add
|
||||||
- "apk add go-task diffutils"
|
- "apk add go-task diffutils gitlab_ci_log_section"
|
||||||
.disable-hainish: &disable-hainish
|
.disable-hainish: &disable-hainish
|
||||||
- "rm -f .env.development"
|
- "rm -f .env.development"
|
||||||
.cache-ruby: &cache-ruby
|
.cache-ruby: &cache-ruby
|
||||||
|
@ -30,13 +30,18 @@ assets:
|
||||||
- *cache-node
|
- *cache-node
|
||||||
- *cache-task
|
- *cache-task
|
||||||
before_script:
|
before_script:
|
||||||
|
- "gitlab_ci_log_section --name git --header=\"Configuring git\""
|
||||||
- "git config --global user.email \"${GIT_USER_EMAIL:-$GITLAB_USER_EMAIL}\""
|
- "git config --global user.email \"${GIT_USER_EMAIL:-$GITLAB_USER_EMAIL}\""
|
||||||
- "git config --global user.name \"${GIT_USER_NAME:-$GITLAB_USER_NAME}\""
|
- "git config --global user.name \"${GIT_USER_NAME:-$GITLAB_USER_NAME}\""
|
||||||
- "git remote set-url --push origin \"https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git\""
|
- "git remote set-url --push origin \"https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git\""
|
||||||
|
- "gitlab_ci_log_section --name git --end"
|
||||||
|
- "gitlab_ci_log_section --name apk --header=\"Installing dependencies\""
|
||||||
- "apk add brotli"
|
- "apk add brotli"
|
||||||
- *apk-add
|
- *apk-add
|
||||||
- *disable-hainish
|
- *disable-hainish
|
||||||
|
- "gitlab_ci_log_section --name apk --end"
|
||||||
script:
|
script:
|
||||||
|
- "gitlab_ci_log_section --name assets --header=\"Building\""
|
||||||
- "go-task assets"
|
- "go-task assets"
|
||||||
after_script:
|
after_script:
|
||||||
- "git add public && git commit -m \"ci: assets [skip ci]\""
|
- "git add public && git commit -m \"ci: assets [skip ci]\""
|
||||||
|
|
|
@ -18,7 +18,8 @@ module ActiveStorage
|
||||||
# para que puedan propagarse correctamente a través de todo el
|
# para que puedan propagarse correctamente a través de todo el
|
||||||
# stack.
|
# stack.
|
||||||
def blob_args
|
def blob_args
|
||||||
params.require(:blob).permit(:filename, :byte_size, :checksum, :content_type, metadata: {}).to_h.symbolize_keys.tap do |ba|
|
params.require(:blob).permit(:filename, :byte_size, :checksum, :content_type,
|
||||||
|
metadata: {}).to_h.symbolize_keys.tap do |ba|
|
||||||
ba[:filename] = ba[:filename].unicode_normalize.sub(/\A_+/, '')
|
ba[:filename] = ba[:filename].unicode_normalize.sub(/\A_+/, '')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,21 +38,33 @@ module Api
|
||||||
head :accepted
|
head :accepted
|
||||||
end
|
end
|
||||||
|
|
||||||
# Cuando aprobamos una actividad, recibimos la confirmación y
|
# Cuando la Social Inbox acepta una actividad, la recibimos
|
||||||
# cambiamos el estado.
|
# igual y la guardamos por si cambiamos de idea.
|
||||||
|
#
|
||||||
|
# @todo DRY
|
||||||
def onapproved
|
def onapproved
|
||||||
ActivityPub.transaction do
|
ActivityPub.transaction do
|
||||||
activity_pub.approve! if activity_pub.waiting?
|
actor.present?
|
||||||
|
instance.present?
|
||||||
|
object.present?
|
||||||
|
activity.present?
|
||||||
|
activity_pub.approve!
|
||||||
end
|
end
|
||||||
|
|
||||||
head :accepted
|
head :accepted
|
||||||
end
|
end
|
||||||
|
|
||||||
# Cuando rechazamos una actividad, recibimos la confirmación y
|
# Cuando la Social Inbox rechaza una actividad, la recibimos
|
||||||
# cambiamos el estado
|
# igual y la guardamos por si cambiamos de idea.
|
||||||
|
#
|
||||||
|
# @todo DRY
|
||||||
def onrejected
|
def onrejected
|
||||||
ActivityPub.transaction do
|
ActivityPub.transaction do
|
||||||
activity_pub.reject! if activity_pub.waiting?
|
actor.present?
|
||||||
|
instance.present?
|
||||||
|
object.present?
|
||||||
|
activity.present?
|
||||||
|
activity_pub.reject!
|
||||||
end
|
end
|
||||||
|
|
||||||
head :accepted
|
head :accepted
|
||||||
|
|
|
@ -105,7 +105,7 @@ class GitlabNotifierJob < ApplicationJob
|
||||||
def title
|
def title
|
||||||
@title ||= ''.dup.tap do |t|
|
@title ||= ''.dup.tap do |t|
|
||||||
t << "[#{exception.class}] " unless javascript?
|
t << "[#{exception.class}] " unless javascript?
|
||||||
t << exception.message
|
t << exception.message[0..200]
|
||||||
t << " [#{issue_data[:count]}]"
|
t << " [#{issue_data[:count]}]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,8 +21,6 @@ class ActivityPub < ApplicationRecord
|
||||||
aasm do
|
aasm do
|
||||||
# Todavía no hay una decisión sobre el objeto
|
# Todavía no hay una decisión sobre el objeto
|
||||||
state :paused, initial: true
|
state :paused, initial: true
|
||||||
# Estamos esperando respuesta desde la Social Inbox
|
|
||||||
state :waiting
|
|
||||||
# Le usuarie aprobó el objeto
|
# Le usuarie aprobó el objeto
|
||||||
state :approved
|
state :approved
|
||||||
# Le usuarie rechazó el objeto
|
# Le usuarie rechazó el objeto
|
||||||
|
@ -46,17 +44,22 @@ class ActivityPub < ApplicationRecord
|
||||||
# Si un objeto previamente aprobado fue actualizado, volvemos a
|
# Si un objeto previamente aprobado fue actualizado, volvemos a
|
||||||
# pausarlo.
|
# pausarlo.
|
||||||
event :pause do
|
event :pause do
|
||||||
transitions from: %i[waiting approved rejected], to: :paused
|
transitions from: %i[approved rejected], to: :paused
|
||||||
end
|
end
|
||||||
|
|
||||||
# La actividad se aprueba
|
# La actividad se aprueba
|
||||||
event :approve do
|
event :approve do
|
||||||
transitions from: :waiting, to: :approved
|
transitions from: %i[paused rejected], to: :approved
|
||||||
end
|
end
|
||||||
|
|
||||||
# La actividad fue rechazada
|
# La actividad fue rechazada
|
||||||
event :reject do
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -130,7 +130,7 @@ class DeployDistributedPress < Deploy
|
||||||
#
|
#
|
||||||
# @return [nil]
|
# @return [nil]
|
||||||
def create_remote_site!
|
def create_remote_site!
|
||||||
self.hostname = site.hostname
|
self.hostname ||= site.hostname
|
||||||
|
|
||||||
created_site = site_client.create(create_site)
|
created_site = site_client.create(create_site)
|
||||||
|
|
||||||
|
|
|
@ -260,5 +260,10 @@ class Site
|
||||||
|
|
||||||
r&.success?
|
r&.success?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def lfs_cleanup
|
||||||
|
git_sh("git", "lfs", "prune")
|
||||||
|
git_sh("git", "lfs", "dedup")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,9 +67,12 @@ class SocialInbox
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# El hostname puede estar en varios lados...
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
def hostname
|
def hostname
|
||||||
@hostname ||=
|
@hostname ||=
|
||||||
site.config.dig('activity_pub', 'hostname') || site.hostname
|
site.config.dig('activity_pub', 'hostname') || site.config['hostname'] || site.hostname
|
||||||
end
|
end
|
||||||
|
|
||||||
# Genera una URI dentro de este sitio
|
# Genera una URI dentro de este sitio
|
||||||
|
|
|
@ -31,7 +31,7 @@ class CleanupService
|
||||||
site.deploys.find_each(&:cleanup!)
|
site.deploys.find_each(&:cleanup!)
|
||||||
|
|
||||||
site.repository.gc
|
site.repository.gc
|
||||||
lfs_cleanup
|
site.repository.lfs_cleanup
|
||||||
site.touch
|
site.touch
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -46,14 +46,8 @@ class CleanupService
|
||||||
Rails.logger.info "Limpiando repositorio git de #{site.name}"
|
Rails.logger.info "Limpiando repositorio git de #{site.name}"
|
||||||
|
|
||||||
site.repository.gc
|
site.repository.gc
|
||||||
lfs_cleanup
|
site.repository.lfs_cleanup
|
||||||
site.touch
|
site.touch
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
def lfs_cleanup
|
|
||||||
site.repository.git_sh("git", "lfs", "prune")
|
|
||||||
site.repository.git_sh("git", "lfs", "dedup")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
||||||
def create
|
def create
|
||||||
self.site = Site.new params
|
self.site = Site.new params
|
||||||
|
|
||||||
add_role temporal: false, rol: 'usuarie'
|
role = site.roles.build(usuarie: usuarie, temporal: false, rol: 'usuarie')
|
||||||
site.deploys.build type: 'DeployLocal'
|
site.deploys.build type: 'DeployLocal'
|
||||||
# Los sitios de testing no se sincronizan
|
# Los sitios de testing no se sincronizan
|
||||||
sync_nodes unless site.name.end_with? '.testing'
|
sync_nodes unless site.name.end_with? '.testing'
|
||||||
|
@ -26,6 +26,8 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
||||||
# que no haya estados intermedios.
|
# que no haya estados intermedios.
|
||||||
site.locales = [usuarie.lang]
|
site.locales = [usuarie.lang]
|
||||||
|
|
||||||
|
add_role_to_deploys! role
|
||||||
|
|
||||||
site.save &&
|
site.save &&
|
||||||
site.config.write &&
|
site.config.write &&
|
||||||
commit_config(action: :create) &&
|
commit_config(action: :create) &&
|
||||||
|
@ -43,7 +45,10 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
||||||
# Actualiza el sitio y guarda los cambios en la configuración
|
# Actualiza el sitio y guarda los cambios en la configuración
|
||||||
def update
|
def update
|
||||||
I18n.with_locale(usuarie&.lang&.to_sym || I18n.default_locale) do
|
I18n.with_locale(usuarie&.lang&.to_sym || I18n.default_locale) do
|
||||||
site.update(params) &&
|
site.assign_attributes(params)
|
||||||
|
add_role_to_deploys!
|
||||||
|
|
||||||
|
site.save &&
|
||||||
site.config.write &&
|
site.config.write &&
|
||||||
commit_config(action: :update) &&
|
commit_config(action: :update) &&
|
||||||
site.reset.nil? &&
|
site.reset.nil? &&
|
||||||
|
@ -113,11 +118,6 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
||||||
GitPushJob.perform_later(site)
|
GitPushJob.perform_later(site)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_role(temporal: true, rol: 'invitade')
|
|
||||||
site.roles << Rol.new(site: site, usuarie: usuarie,
|
|
||||||
temporal: temporal, rol: rol)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Crea la licencia del sitio para cada locale disponible en el sitio
|
# Crea la licencia del sitio para cada locale disponible en el sitio
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
|
@ -236,6 +236,17 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# Asignar un rol a cada deploy si no lo tenía ya
|
||||||
|
def add_role_to_deploys!(role = current_role)
|
||||||
|
site.deploys.each do |deploy|
|
||||||
|
deploy.rol ||= role
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_role
|
||||||
|
@current_role ||= usuarie.rol_for_site(site)
|
||||||
|
end
|
||||||
|
|
||||||
def with_all_locales(&block)
|
def with_all_locales(&block)
|
||||||
site.locales.map do |locale|
|
site.locales.map do |locale|
|
||||||
next unless I18n.available_locales.include? locale
|
next unless I18n.available_locales.include? locale
|
||||||
|
|
Loading…
Reference in a new issue