mirror of
https://0xacab.org/sutty/sutty
synced 2025-02-24 02:11:52 +00:00
Merge branch 'rails' of 0xacab.org:sutty/sutty into production.panel.sutty.nl
This commit is contained in:
commit
4e989fa845
31 changed files with 98 additions and 79 deletions
|
@ -6,9 +6,15 @@
|
||||||
- paths:
|
- paths:
|
||||||
- "vendor/ruby"
|
- "vendor/ruby"
|
||||||
- ".bundle"
|
- ".bundle"
|
||||||
|
key:
|
||||||
|
files:
|
||||||
|
- "Gemfile.lock"
|
||||||
.cache-node: &cache-node
|
.cache-node: &cache-node
|
||||||
- paths:
|
- paths:
|
||||||
- "node_modules"
|
- "node_modules"
|
||||||
|
key:
|
||||||
|
files:
|
||||||
|
- "yarn.lock"
|
||||||
.cache-task: &cache-task
|
.cache-task: &cache-task
|
||||||
- paths:
|
- paths:
|
||||||
- ".task"
|
- ".task"
|
||||||
|
@ -22,7 +28,8 @@ assets:
|
||||||
stage: "deploy"
|
stage: "deploy"
|
||||||
only:
|
only:
|
||||||
- "rails"
|
- "rails"
|
||||||
- "17.3.alpine.panel.sutty.nl"
|
- "production.panel.sutty.nl"
|
||||||
|
- "panel.sutty.nl"
|
||||||
except:
|
except:
|
||||||
- "schedules"
|
- "schedules"
|
||||||
cache:
|
cache:
|
||||||
|
@ -30,14 +37,14 @@ assets:
|
||||||
- *cache-node
|
- *cache-node
|
||||||
- *cache-task
|
- *cache-task
|
||||||
before_script:
|
before_script:
|
||||||
|
- *apk-add
|
||||||
- "gitlab_ci_log_section --name git --header=\"Configuring git\""
|
- "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_CI_PUSH_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git\""
|
||||||
- "gitlab_ci_log_section --name git --end"
|
- "gitlab_ci_log_section --name git --end"
|
||||||
- "gitlab_ci_log_section --name apk --header=\"Installing dependencies\""
|
- "gitlab_ci_log_section --name apk --header=\"Installing dependencies\""
|
||||||
- "apk add brotli"
|
- "apk add brotli"
|
||||||
- *apk-add
|
|
||||||
- *disable-hainish
|
- *disable-hainish
|
||||||
- "gitlab_ci_log_section --name apk --end"
|
- "gitlab_ci_log_section --name apk --end"
|
||||||
script:
|
script:
|
||||||
|
@ -45,7 +52,7 @@ assets:
|
||||||
- "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]\""
|
||||||
- "git push -o ci.skip"
|
- "git push -o ci.skip origin HEAD:${CI_COMMIT_BRANCH}"
|
||||||
gem-audit:
|
gem-audit:
|
||||||
stage: "test"
|
stage: "test"
|
||||||
only:
|
only:
|
||||||
|
|
|
@ -185,9 +185,13 @@ tasks:
|
||||||
- "test -f ../hain/usr/bin/bundler-audit"
|
- "test -f ../hain/usr/bin/bundler-audit"
|
||||||
rubocop:
|
rubocop:
|
||||||
desc: "Ruby linting"
|
desc: "Ruby linting"
|
||||||
|
deps:
|
||||||
|
- "gems"
|
||||||
cmds:
|
cmds:
|
||||||
- "./bin/modified_files | ./bin/with_extension rb | xargs -r {{.HAINISH}} bundle exec rubocop {{.CLI_ARGS}}"
|
- "./bin/modified_files | ./bin/with_extension rb | xargs -r {{.HAINISH}} bundle exec rubocop {{.CLI_ARGS}}"
|
||||||
haml-lint:
|
haml-lint:
|
||||||
desc: "HAML linting"
|
desc: "HAML linting"
|
||||||
|
deps:
|
||||||
|
- "gems"
|
||||||
cmds:
|
cmds:
|
||||||
- "./bin/modified_files | ./bin/with_extension haml | xargs -r {{.HAINISH}} bundle exec haml-lint {{.CLI_ARGS}}"
|
- "./bin/modified_files | ./bin/with_extension haml | xargs -r {{.HAINISH}} bundle exec haml-lint {{.CLI_ARGS}}"
|
||||||
|
|
|
@ -14,7 +14,7 @@ class ApplicationController < ActionController::Base
|
||||||
after_action :store_location!
|
after_action :store_location!
|
||||||
|
|
||||||
before_action do
|
before_action do
|
||||||
Rack::MiniProfiler.authorize_request if current_usuarie&.email&.ends_with?('@' + ENV.fetch('SUTTY', 'sutty.nl'))
|
Rack::MiniProfiler.authorize_request if current_usuarie&.email&.ends_with?("@#{ENV.fetch('SUTTY', 'sutty.nl')}")
|
||||||
end
|
end
|
||||||
|
|
||||||
# No tenemos índice de sutty, vamos directamente a ver el listado de
|
# No tenemos índice de sutty, vamos directamente a ver el listado de
|
||||||
|
@ -58,9 +58,7 @@ class ApplicationController < ActionController::Base
|
||||||
def current_locale
|
def current_locale
|
||||||
locale = params[:change_locale_to]
|
locale = params[:change_locale_to]
|
||||||
|
|
||||||
if locale.present? && I18n.locale_available?(locale)
|
session[:locale] = params[:change_locale_to] if locale.present? && I18n.locale_available?(locale)
|
||||||
session[:locale] = params[:change_locale_to]
|
|
||||||
end
|
|
||||||
|
|
||||||
session[:locale] || current_usuarie&.lang || I18n.locale
|
session[:locale] || current_usuarie&.lang || I18n.locale
|
||||||
end
|
end
|
||||||
|
@ -119,5 +117,4 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
session[:usuarie_return_to] = request.fullpath
|
session[:usuarie_return_to] = request.fullpath
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ module ApplicationHelper
|
||||||
root = names.shift
|
root = names.shift
|
||||||
|
|
||||||
names.each do |n|
|
names.each do |n|
|
||||||
root += '[' + n.to_s + ']'
|
root += "[#{n}]"
|
||||||
end
|
end
|
||||||
|
|
||||||
[root, name]
|
[root, name]
|
||||||
|
@ -22,7 +22,7 @@ module ApplicationHelper
|
||||||
def plain_field_name_for(*names)
|
def plain_field_name_for(*names)
|
||||||
root, name = field_name_for(*names)
|
root, name = field_name_for(*names)
|
||||||
|
|
||||||
root + '[' + name.to_s + ']'
|
"#{root}[#{name}]"
|
||||||
end
|
end
|
||||||
|
|
||||||
def distance_of_time_in_words_if_more_than_a_minute(seconds)
|
def distance_of_time_in_words_if_more_than_a_minute(seconds)
|
||||||
|
|
|
@ -11,7 +11,7 @@ class ActivityPub
|
||||||
class FetchJob < ApplicationJob
|
class FetchJob < ApplicationJob
|
||||||
self.priority = 50
|
self.priority = 50
|
||||||
|
|
||||||
attr_reader :site, :object, :response
|
attr_reader :object, :response
|
||||||
|
|
||||||
# Notificar errores de JSON con el contenido, tomar los errores de
|
# Notificar errores de JSON con el contenido, tomar los errores de
|
||||||
# validación y conexión como errores temporales y notificar todo lo
|
# validación y conexión como errores temporales y notificar todo lo
|
||||||
|
@ -50,7 +50,8 @@ class ActivityPub
|
||||||
content = FastJsonparser.parse(response.body)
|
content = FastJsonparser.parse(response.body)
|
||||||
|
|
||||||
# Modificar atómicamente
|
# Modificar atómicamente
|
||||||
::ActivityPub::Object.lock.find(object_id).update!(content: content, type: ActivityPub::Object.type_from(content).name)
|
::ActivityPub::Object.lock.find(object_id).update!(content: content,
|
||||||
|
type: ActivityPub::Object.type_from(content).name)
|
||||||
|
|
||||||
object = ::ActivityPub::Object.find(object_id)
|
object = ::ActivityPub::Object.find(object_id)
|
||||||
# Actualiza la mención
|
# Actualiza la mención
|
||||||
|
|
|
@ -43,7 +43,9 @@ class ActivityPub
|
||||||
# Si alguna falló, reintentar
|
# Si alguna falló, reintentar
|
||||||
raise if logs.present?
|
raise if logs.present?
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
ExceptionNotifier.notify_exception(e, data: { site: site.name, logs: logs, blocklist: blocklist, allowlist: allowlist, pauselist: pauselist })
|
ExceptionNotifier.notify_exception(e,
|
||||||
|
data: { site: site.name, logs: logs, blocklist: blocklist,
|
||||||
|
allowlist: allowlist, pauselist: pauselist })
|
||||||
|
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ApplicationJob < ActiveJob::Base
|
||||||
# superpongan tareas
|
# superpongan tareas
|
||||||
#
|
#
|
||||||
# @return [Array<Integer>]
|
# @return [Array<Integer>]
|
||||||
RANDOM_WAIT = [3, 5, 7, 11, 13]
|
RANDOM_WAIT = [3, 5, 7, 11, 13].freeze
|
||||||
|
|
||||||
# @return [ActiveSupport::Duration]
|
# @return [ActiveSupport::Duration]
|
||||||
def self.random_wait
|
def self.random_wait
|
||||||
|
|
|
@ -55,9 +55,7 @@ class BacktraceJob < ApplicationJob
|
||||||
x['backtrace']
|
x['backtrace']
|
||||||
end.flatten.map do |x|
|
end.flatten.map do |x|
|
||||||
x['file'].split('@').last
|
x['file'].split('@').last
|
||||||
end.uniq.select do |x|
|
end.uniq.grep(%r{\Ahttps://})
|
||||||
%r{\Ahttps://} =~ x
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Descarga y devuelve los datos de un archivo
|
# Descarga y devuelve los datos de un archivo
|
||||||
|
|
|
@ -27,12 +27,11 @@ class DeployJob < ApplicationJob
|
||||||
if site.building?
|
if site.building?
|
||||||
notify = false
|
notify = false
|
||||||
|
|
||||||
if 10.minutes.ago >= time
|
raise DeployAlreadyRunningException unless 10.minutes.ago >= time
|
||||||
raise DeployTimedOutException,
|
|
||||||
"#{site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original"
|
raise DeployTimedOutException,
|
||||||
else
|
"#{site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original"
|
||||||
raise DeployAlreadyRunningException
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@deployed = {}
|
@deployed = {}
|
||||||
|
@ -50,9 +49,7 @@ class DeployJob < ApplicationJob
|
||||||
nil
|
nil
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
if d == site.deployment_list.last && !status
|
raise DeployException, 'Falló la compilación' if d == site.deployment_list.last && !status
|
||||||
raise DeployException, 'Falló la compilación'
|
|
||||||
end
|
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
status = false
|
status = false
|
||||||
seconds ||= 0
|
seconds ||= 0
|
||||||
|
@ -73,7 +70,7 @@ class DeployJob < ApplicationJob
|
||||||
|
|
||||||
return unless output
|
return unless output
|
||||||
|
|
||||||
puts (Terminal::Table.new do |t|
|
puts(Terminal::Table.new do |t|
|
||||||
t << (%w[type] + @deployed.values.first.keys)
|
t << (%w[type] + @deployed.values.first.keys)
|
||||||
t.add_separator
|
t.add_separator
|
||||||
@deployed.each do |type, row|
|
@deployed.each do |type, row|
|
||||||
|
|
|
@ -64,7 +64,7 @@ class ActivityPub < ApplicationRecord
|
||||||
# Array<String> o mezcla y obtener el que más nos convenga o
|
# Array<String> o mezcla y obtener el que más nos convenga o
|
||||||
# adivinar uno.
|
# adivinar uno.
|
||||||
when Array
|
when Array
|
||||||
links = object['url'].map.with_index do |link, i|
|
links = object['url'].map.with_index do |link, _i|
|
||||||
case link
|
case link
|
||||||
when Hash then link
|
when Hash then link
|
||||||
else { 'href' => link.to_s }
|
else { 'href' => link.to_s }
|
||||||
|
@ -93,7 +93,8 @@ class ActivityPub < ApplicationRecord
|
||||||
|
|
||||||
# Gestionar todos los errores
|
# Gestionar todos los errores
|
||||||
error_on_all_events do |e|
|
error_on_all_events do |e|
|
||||||
ExceptionNotifier.notify_exception(e, data: { site: site.name, activity_pub: self.id, activity: activities.first.uri })
|
ExceptionNotifier.notify_exception(e,
|
||||||
|
data: { site: site.name, activity_pub: id, activity: activities.first.uri })
|
||||||
end
|
end
|
||||||
|
|
||||||
# Se puede volver a pausa en caso de actualización remota, para
|
# Se puede volver a pausa en caso de actualización remota, para
|
||||||
|
|
|
@ -35,9 +35,9 @@ class ActivityPub
|
||||||
validates_inclusion_of :format, in: %w[mastodon fediblock none]
|
validates_inclusion_of :format, in: %w[mastodon fediblock none]
|
||||||
|
|
||||||
HOSTNAME_HEADERS = {
|
HOSTNAME_HEADERS = {
|
||||||
'mastodon' => '#domain',
|
'mastodon' => '#domain',
|
||||||
'fediblock' => 'domain'
|
'fediblock' => 'domain'
|
||||||
}
|
}.freeze
|
||||||
|
|
||||||
def client
|
def client
|
||||||
@client ||= Client.new
|
@client ||= Client.new
|
||||||
|
|
|
@ -39,13 +39,14 @@ class ActivityPub
|
||||||
def referenced(site)
|
def referenced(site)
|
||||||
require 'distributed_press/v1/social/referenced_object'
|
require 'distributed_press/v1/social/referenced_object'
|
||||||
|
|
||||||
@referenced ||= DistributedPress::V1::Social::ReferencedObject.new(object: content, dereferencer: site.social_inbox.dereferencer)
|
@referenced ||= DistributedPress::V1::Social::ReferencedObject.new(object: content,
|
||||||
|
dereferencer: site.social_inbox.dereferencer)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def uri_is_content_id?
|
def uri_is_content_id?
|
||||||
return if self.uri == content['id']
|
return if uri == content['id']
|
||||||
|
|
||||||
errors.add(:activity_pub_objects, 'El ID del objeto no coincide con su URI')
|
errors.add(:activity_pub_objects, 'El ID del objeto no coincide con su URI')
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,7 +40,8 @@ class ActivityPub
|
||||||
def content
|
def content
|
||||||
{
|
{
|
||||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
'id' => Rails.application.routes.url_helpers.v1_activity_pub_remote_flag_url(self, host: site.social_inbox_hostname),
|
'id' => Rails.application.routes.url_helpers.v1_activity_pub_remote_flag_url(self,
|
||||||
|
host: site.social_inbox_hostname),
|
||||||
'type' => 'Flag',
|
'type' => 'Flag',
|
||||||
'actor' => main_site.social_inbox.actor_id,
|
'actor' => main_site.social_inbox.actor_id,
|
||||||
'content' => message.to_s,
|
'content' => message.to_s,
|
||||||
|
@ -53,7 +54,7 @@ class ActivityPub
|
||||||
#
|
#
|
||||||
# @return [Site]
|
# @return [Site]
|
||||||
def main_site
|
def main_site
|
||||||
@main_site ||= Site.find(ENV.fetch('PANEL_ACTOR_SITE_ID') { 1 })
|
@main_site ||= Site.find(ENV.fetch('PANEL_ACTOR_SITE_ID', 1))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Tienda
|
||||||
|
|
||||||
return t if new_record?
|
return t if new_record?
|
||||||
|
|
||||||
t.blank? ? 'https://' + name + '.' + ENV.fetch('TIENDA', 'tienda.sutty.nl') : t
|
t.blank? ? "https://#{name}.#{ENV.fetch('TIENDA', 'tienda.sutty.nl')}" : t
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,7 +45,8 @@ class FediblockState < ApplicationRecord
|
||||||
private
|
private
|
||||||
|
|
||||||
def block_instances!
|
def block_instances!
|
||||||
ActivityPub::InstanceModerationJob.perform_later(site: site, hostnames: fediblock.hostnames, perform_remotely: false)
|
ActivityPub::InstanceModerationJob.perform_later(site: site, hostnames: fediblock.hostnames,
|
||||||
|
perform_remotely: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Pausar todas las moderaciones de las instancias que no estén
|
# Pausar todas las moderaciones de las instancias que no estén
|
||||||
|
|
|
@ -16,7 +16,9 @@ class InstanceModeration < ApplicationRecord
|
||||||
state :blocked
|
state :blocked
|
||||||
|
|
||||||
error_on_all_events do |e|
|
error_on_all_events do |e|
|
||||||
ExceptionNotifier.notify_exception(e, data: { site: site.name, instance: instance.hostname, instance_moderation: id })
|
ExceptionNotifier.notify_exception(e,
|
||||||
|
data: { site: site.name, instance: instance.hostname,
|
||||||
|
instance_moderation: id })
|
||||||
end
|
end
|
||||||
|
|
||||||
after_all_events do
|
after_all_events do
|
||||||
|
|
|
@ -130,7 +130,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
|
||||||
# En caso de que algún campo necesite realizar acciones antes de ser
|
# En caso de que algún campo necesite realizar acciones antes de ser
|
||||||
# guardado
|
# guardado
|
||||||
def save
|
def save
|
||||||
if !changed?
|
unless changed?
|
||||||
self[:value] = document_value if private?
|
self[:value] = document_value if private?
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -294,11 +294,11 @@ class Site < ApplicationRecord
|
||||||
# layouts. Si pasamos un layout que no existe, obtenemos un
|
# layouts. Si pasamos un layout que no existe, obtenemos un
|
||||||
# NoMethodError
|
# NoMethodError
|
||||||
@layouts_struct ||= Struct.new(*layout_keys, keyword_init: true)
|
@layouts_struct ||= Struct.new(*layout_keys, keyword_init: true)
|
||||||
@layouts ||= @layouts_struct.new(**data['layouts'].map do |name, metadata|
|
@layouts ||= @layouts_struct.new(**data['layouts'].to_h do |name, metadata|
|
||||||
[name.to_sym,
|
[name.to_sym,
|
||||||
Layout.new(site: self, name: name.to_sym, meta: metadata.delete('meta')&.with_indifferent_access,
|
Layout.new(site: self, name: name.to_sym, meta: metadata.delete('meta')&.with_indifferent_access,
|
||||||
metadata: metadata.with_indifferent_access)]
|
metadata: metadata.with_indifferent_access)]
|
||||||
end.to_h)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Si la estructura de datos no existe, vamos a producir una
|
# TODO: Si la estructura de datos no existe, vamos a producir una
|
||||||
|
@ -391,7 +391,7 @@ class Site < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload
|
def reload
|
||||||
super.tap do |s|
|
super.tap do |_s|
|
||||||
reload_jekyll!
|
reload_jekyll!
|
||||||
end
|
end
|
||||||
self
|
self
|
||||||
|
@ -481,7 +481,7 @@ class Site < ApplicationRecord
|
||||||
def clone_skel!
|
def clone_skel!
|
||||||
return if jekyll?
|
return if jekyll?
|
||||||
|
|
||||||
Rugged::Repository.clone_at(ENV['SKEL_SUTTY'], path, checkout_branch: design.gem)
|
Rugged::Repository.clone_at(ENV.fetch('SKEL_SUTTY', nil), path, checkout_branch: design.gem)
|
||||||
|
|
||||||
# Necesita un bloque
|
# Necesita un bloque
|
||||||
repository.rugged.remotes.rename('origin', 'upstream') {}
|
repository.rugged.remotes.rename('origin', 'upstream') {}
|
||||||
|
@ -575,11 +575,11 @@ class Site < ApplicationRecord
|
||||||
deploy_local = deploys.find_by_type('DeployLocal')
|
deploy_local = deploys.find_by_type('DeployLocal')
|
||||||
deploy_local.git_lfs
|
deploy_local.git_lfs
|
||||||
|
|
||||||
if !gems_installed? || gemfile_updated? || gemfile_lock_updated?
|
return unless !gems_installed? || gemfile_updated? || gemfile_lock_updated?
|
||||||
deploy_local.bundle
|
|
||||||
touch
|
deploy_local.bundle
|
||||||
FileUtils.touch(gemfile_path)
|
touch
|
||||||
end
|
FileUtils.touch(gemfile_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def gem_path
|
def gem_path
|
||||||
|
|
|
@ -45,7 +45,7 @@ class SocialInbox
|
||||||
# @param url [String]
|
# @param url [String]
|
||||||
# @return [DistributedPress::V1::Social::Client]
|
# @return [DistributedPress::V1::Social::Client]
|
||||||
def client_for(url)
|
def client_for(url)
|
||||||
raise "Falló generar un cliente" if url.blank?
|
raise 'Falló generar un cliente' if url.blank?
|
||||||
|
|
||||||
@client_for ||= {}
|
@client_for ||= {}
|
||||||
@client_for[url] ||=
|
@client_for[url] ||=
|
||||||
|
@ -54,7 +54,7 @@ class SocialInbox
|
||||||
public_key_url: public_key_url,
|
public_key_url: public_key_url,
|
||||||
private_key_pem: site.private_key_pem,
|
private_key_pem: site.private_key_pem,
|
||||||
logger: Rails.logger,
|
logger: Rails.logger,
|
||||||
cache_store: HTTParty::Cache::Store::Redis.new(redis_url: ENV['REDIS_SERVER'])
|
cache_store: HTTParty::Cache::Store::Redis.new(redis_url: ENV.fetch('REDIS_SERVER', nil))
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -76,10 +76,10 @@ class Usuarie < ApplicationRecord
|
||||||
# Si le usuarie (re)confirma su cuenta con una invitación pendiente,
|
# Si le usuarie (re)confirma su cuenta con una invitación pendiente,
|
||||||
# considerarla aceptada también.
|
# considerarla aceptada también.
|
||||||
def accept_invitation_after_confirmation!
|
def accept_invitation_after_confirmation!
|
||||||
if confirmed?
|
return unless confirmed?
|
||||||
self.invitation_token = nil
|
|
||||||
self.invitation_accepted_at ||= Time.now.utc
|
self.invitation_token = nil
|
||||||
end
|
self.invitation_accepted_at ||= Time.now.utc
|
||||||
end
|
end
|
||||||
|
|
||||||
# Muestra un error si el idioma no está disponible al cambiar el
|
# Muestra un error si el idioma no está disponible al cambiar el
|
||||||
|
@ -87,7 +87,7 @@ class Usuarie < ApplicationRecord
|
||||||
#
|
#
|
||||||
# @return [nil]
|
# @return [nil]
|
||||||
def locale_available!
|
def locale_available!
|
||||||
return if I18n.locale_available? self.lang
|
return if I18n.locale_available? lang
|
||||||
|
|
||||||
errors.add(:lang, I18n.t('activerecord.errors.models.usuarie.attributes.lang.not_available'))
|
errors.add(:lang, I18n.t('activerecord.errors.models.usuarie.attributes.lang.not_available'))
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -246,8 +246,6 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# Asignar un rol a cada deploy si no lo tenía ya
|
# Asignar un rol a cada deploy si no lo tenía ya
|
||||||
def add_role_to_deploys!(role = current_role)
|
def add_role_to_deploys!(role = current_role)
|
||||||
site.deploys.each do |deploy|
|
site.deploys.each do |deploy|
|
||||||
|
|
|
@ -62,7 +62,7 @@ Rails.application.configure do
|
||||||
config.log_tags = %i[request_id]
|
config.log_tags = %i[request_id]
|
||||||
|
|
||||||
# Use a different cache store in production.
|
# Use a different cache store in production.
|
||||||
config.cache_store = :redis_cache_store, { url: ENV['REDIS_SERVER'] }
|
config.cache_store = :redis_cache_store, { url: ENV.fetch('REDIS_SERVER', nil) }
|
||||||
|
|
||||||
config.action_mailer.perform_caching = false
|
config.action_mailer.perform_caching = false
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ Rails.application.configure do
|
||||||
config.lograge.enabled = true
|
config.lograge.enabled = true
|
||||||
# Use default logging formatter so that PID and timestamp are not
|
# Use default logging formatter so that PID and timestamp are not
|
||||||
# suppressed.
|
# suppressed.
|
||||||
config.log_formatter = ::Logger::Formatter.new
|
config.log_formatter = Logger::Formatter.new
|
||||||
|
|
||||||
# Use a different logger for distributed setups.
|
# Use a different logger for distributed setups.
|
||||||
require 'syslog/logger'
|
require 'syslog/logger'
|
||||||
|
@ -140,9 +140,10 @@ Rails.application.configure do
|
||||||
domain: ENV.fetch('SUTTY', 'sutty.nl'),
|
domain: ENV.fetch('SUTTY', 'sutty.nl'),
|
||||||
enable_starttls_auto: false
|
enable_starttls_auto: false
|
||||||
}
|
}
|
||||||
config.action_mailer.default_options = { from: ENV.fetch('DEFAULT_FROM', "noreply@sutty.nl") }
|
config.action_mailer.default_options = { from: ENV.fetch('DEFAULT_FROM', 'noreply@sutty.nl') }
|
||||||
|
|
||||||
config.middleware.use ExceptionNotification::Rack, gitlab: {}, error_grouping: true, ignore_exceptions: ['DeployJob::DeployAlreadyRunningException']
|
config.middleware.use ExceptionNotification::Rack, gitlab: {}, error_grouping: true,
|
||||||
|
ignore_exceptions: ['DeployJob::DeployAlreadyRunningException']
|
||||||
|
|
||||||
Rails.application.routes.default_url_options[:host] = "panel.#{ENV.fetch('SUTTY', 'sutty.nl')}"
|
Rails.application.routes.default_url_options[:host] = "panel.#{ENV.fetch('SUTTY', 'sutty.nl')}"
|
||||||
Rails.application.routes.default_url_options[:protocol] = 'https'
|
Rails.application.routes.default_url_options[:protocol] = 'https'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Que::Web.use(Rack::Auth::Basic) do |user, password|
|
Que::Web.use(Rack::Auth::Basic) do |user, password|
|
||||||
[user, password] == [ENV['HTTP_BASIC_USER'], ENV['HTTP_BASIC_PASSWORD']]
|
[user, password] == [ENV.fetch('HTTP_BASIC_USER', nil), ENV.fetch('HTTP_BASIC_PASSWORD', nil)]
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,9 +16,7 @@ class CreateFediblockStates < ActiveRecord::Migration[6.1]
|
||||||
# Todas las listas están activas por defecto
|
# Todas las listas están activas por defecto
|
||||||
DeploySocialDistributedPress.find_each do |deploy|
|
DeploySocialDistributedPress.find_each do |deploy|
|
||||||
ActivityPub::Fediblock.find_each do |fediblock|
|
ActivityPub::Fediblock.find_each do |fediblock|
|
||||||
FediblockState.create(site: deploy.site, fediblock: fediblock, aasm_state: 'disabled').tap do |f|
|
FediblockState.create(site: deploy.site, fediblock: fediblock, aasm_state: 'disabled').tap(&:enable!)
|
||||||
f.enable!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
# decompresión
|
# decompresión
|
||||||
class BrsDecompressorCorruptedSourceError < ActiveRecord::Migration[6.1]
|
class BrsDecompressorCorruptedSourceError < ActiveRecord::Migration[6.1]
|
||||||
def up
|
def up
|
||||||
raise unless HTTParty.get("https://mas.to/api/v2/instance", headers: { "Accept-Encoding": "br;q=1.0,gzip;q=1.0,deflate;q=0.6,identity;q=0.3" }).ok?
|
raise unless HTTParty.get('https://mas.to/api/v2/instance',
|
||||||
|
headers: { 'Accept-Encoding': 'br;q=1.0,gzip;q=1.0,deflate;q=0.6,identity;q=0.3' }).ok?
|
||||||
|
|
||||||
QueJob.where("last_error_message like '%BRS::DecompressorCorruptedSourceError%'").update_all(error_count: 0, run_at: Time.now)
|
QueJob.where("last_error_message like '%BRS::DecompressorCorruptedSourceError%'").update_all(error_count: 0,
|
||||||
|
run_at: Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
def down; end
|
def down; end
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
class FixActivityType < ActiveRecord::Migration[6.1]
|
class FixActivityType < ActiveRecord::Migration[6.1]
|
||||||
def up
|
def up
|
||||||
%w[Like Announce].each do |type|
|
%w[Like Announce].each do |type|
|
||||||
ActivityPub::Activity.where(Arel.sql("content->>'type' = '#{type}'")).update_all(type: "ActivityPub::Activity::#{type}", updated_at: Time.now)
|
ActivityPub::Activity.where(Arel.sql("content->>'type' = '#{type}'")).update_all(
|
||||||
|
type: "ActivityPub::Activity::#{type}", updated_at: Time.now
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# De alguna forma se guardaron objetos duplicados!
|
# De alguna forma se guardaron objetos duplicados!
|
||||||
class FixDuplicateObjects < ActiveRecord::Migration[6.1]
|
class FixDuplicateObjects < ActiveRecord::Migration[6.1]
|
||||||
def up
|
def up
|
||||||
ActivityPub::Object.group(:uri).count.select { |_, v| v > 1 }.keys.each do |uri|
|
ActivityPub::Object.group(:uri).count.select { |_, v| v > 1 }.each_key do |uri|
|
||||||
objects = ActivityPub::Object.where(uri: uri)
|
objects = ActivityPub::Object.where(uri: uri)
|
||||||
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,7 @@ class AddFedipactToFediblocks < ActiveRecord::Migration[6.1]
|
||||||
)
|
)
|
||||||
|
|
||||||
DeploySocialDistributedPress.find_each do |deploy|
|
DeploySocialDistributedPress.find_each do |deploy|
|
||||||
FediblockState.create(site: deploy.site, fediblock: fedipact, aasm_state: 'disabled').tap do |f|
|
FediblockState.create(site: deploy.site, fediblock: fedipact, aasm_state: 'disabled').tap(&:enable!)
|
||||||
f.enable!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
# no es válida y por eso teníamos objetos duplicados.
|
# no es válida y por eso teníamos objetos duplicados.
|
||||||
class AddMissingUniqueIndexes < ActiveRecord::Migration[6.1]
|
class AddMissingUniqueIndexes < ActiveRecord::Migration[6.1]
|
||||||
def up
|
def up
|
||||||
ActivityPub::Object.group(:uri).count.select { |_, v| v > 1 }.keys.each do |uri|
|
ActivityPub::Object.group(:uri).count.select { |_, v| v > 1 }.each_key do |uri|
|
||||||
objects = ActivityPub::Object.where(uri: uri)
|
objects = ActivityPub::Object.where(uri: uri)
|
||||||
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
||||||
|
|
||||||
ActivityPub.where(object_id: deleted_ids).update_all(object_id: objects.first.id, updated_at: Time.now)
|
ActivityPub.where(object_id: deleted_ids).update_all(object_id: objects.first.id, updated_at: Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
ActivityPub::Actor.group(:uri).count.select { |_, v| v > 1 }.keys.each do |uri|
|
ActivityPub::Actor.group(:uri).count.select { |_, v| v > 1 }.each_key do |uri|
|
||||||
objects = ActivityPub::Actor.where(uri: uri)
|
objects = ActivityPub::Actor.where(uri: uri)
|
||||||
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class AddMissingUniqueIndexes < ActiveRecord::Migration[6.1]
|
||||||
ActivityPub::RemoteFlag.where(actor_id: deleted_ids).update_all(actor_id: objects.first.id, updated_at: Time.now)
|
ActivityPub::RemoteFlag.where(actor_id: deleted_ids).update_all(actor_id: objects.first.id, updated_at: Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
ActivityPub::Instance.group(:hostname).count.select { |_, v| v > 1 }.keys.each do |hostname|
|
ActivityPub::Instance.group(:hostname).count.select { |_, v| v > 1 }.each_key do |hostname|
|
||||||
objects = ActivityPub::Instance.where(hostname: hostname)
|
objects = ActivityPub::Instance.where(hostname: hostname)
|
||||||
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,14 @@
|
||||||
description_en: "We're working towards adding more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)"
|
description_en: "We're working towards adding more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)"
|
||||||
description_es: "Estamos trabajando para que puedas tener más diseños. [¡Escribinos!](https://sutty.nl/#contacto)"
|
description_es: "Estamos trabajando para que puedas tener más diseños. [¡Escribinos!](https://sutty.nl/#contacto)"
|
||||||
priority: '3'
|
priority: '3'
|
||||||
|
- name_en: 'Worker-recovered factory'
|
||||||
|
name_es: 'Empresa recuperada'
|
||||||
|
gem: 'empresa-recuperada-jekyll-theme'
|
||||||
|
url: 'https://empresa-recuperada.sutty.nl/'
|
||||||
|
disabled: true
|
||||||
|
description_en: "A template for [empresas recuperadas](https://en.wikipedia.org/wiki/Workers%27_self-management#Empresas_recuperadas_movement). We're working towards adding more themes for you to use. [Contact us!](https://sutty.nl/en/#contact)"
|
||||||
|
description_es: "Estamos trabajando para que puedas tener más diseños. [¡Escribinos!](https://sutty.nl/#contacto)"
|
||||||
|
priority: '3'
|
||||||
- name_en: 'More themes'
|
- name_en: 'More themes'
|
||||||
name_es: 'Más plantillas'
|
name_es: 'Más plantillas'
|
||||||
gem: 'sutty-theme-own'
|
gem: 'sutty-theme-own'
|
||||||
|
|
Loading…
Reference in a new issue