From 4f8bf1c1d97aad95d9963c0ff556b5ef39e49648 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 24 Jan 2025 13:40:55 -0300 Subject: [PATCH] fix: all dp sites are public by default --- config/locales/en.yml | 3 +++ config/locales/es.yml | 3 +++ ...0123203140_distributed_sites_are_public.rb | 22 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 db/migrate/20250123203140_distributed_sites_are_public.rb diff --git a/config/locales/en.yml b/config/locales/en.yml index 4e0fd4f0..977d99e3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -512,6 +512,9 @@ en: storage network may continue retaining copies of the data indefinitely. + Also, your site will be featured on the [Distributed + Press directory](https://explore.distributed.press/). + [Learn more](https://sutty.nl/learn-more-about-publish-to-dweb-functionality/) deploy_social_distributed_press: title: 'Publish on the Fediverse' diff --git a/config/locales/es.yml b/config/locales/es.yml index 8f3fdea7..0a54d3ab 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -516,6 +516,9 @@ es: nodos en la red de almacenamiento distribuida puedan retener copias de tu contenido indefinidamente. + Además, tu sitio aparecerá en el [directorio de Distributed + Press](https://explore.distributed.press/) + [Saber más](https://sutty.nl/saber-mas-sobre-publicar-a-la-web-distribuida/) deploy_social_distributed_press: title: 'Publicar al Fediverso' diff --git a/db/migrate/20250123203140_distributed_sites_are_public.rb b/db/migrate/20250123203140_distributed_sites_are_public.rb new file mode 100644 index 00000000..a29724b2 --- /dev/null +++ b/db/migrate/20250123203140_distributed_sites_are_public.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +# Los sitios alojados en Distributed Press son públicos por defecto y no +# tienen HTTP, porque lo hace Sutty +class DistributedSitesArePublic < ActiveRecord::Migration[6.1] + def up + require 'distributed_press/v1/schemas/update_site' + + DeployDistributedPress.all.reject do |deploy| + deploy.values.dig(*%w[remote_info distributed_press public]).present? + end.map do |deploy| + update_site = DistributedPress::V1::Schemas::UpdateSite.new.call(id: deploy.hostname, public: true, protocols: { http: false, hyper: true, ipfs: true }) + deploy.send(:site_client).update(update_site) + updated_site = deploy.send(:site_client).show(update_site) + + deploy.remote_info[:distributed_press] = updated_site.to_h + deploy.save + end + end + + def down; end +end