diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 31a2051e..7f007135 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -104,6 +104,10 @@ module ApplicationHelper "#{attribute.join('-')}-datalist" end + def local_channel + "sutty-#{I18n.locale}" + end + private def post_t(*attribute, post:, type:) diff --git a/app/models/usuarie.rb b/app/models/usuarie.rb index c2704a1a..b9d9bf90 100644 --- a/app/models/usuarie.rb +++ b/app/models/usuarie.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'open-uri' + # Usuarie de la plataforma class Usuarie < ApplicationRecord devise :invitable, :database_authenticatable, @@ -11,6 +13,8 @@ class Usuarie < ApplicationRecord has_many :roles has_many :sites, through: :roles + after_create :register_in_lounge!, if: Rails.env.production? + def name email.split('@', 2).first end @@ -34,4 +38,15 @@ class Usuarie < ApplicationRecord increment_failed_attempts lock_access! if attempts_exceeded? && !access_locked? end + + private + + # XXX: Tenemos que hacer esto en línea porque necesitamos la + # contraseña y no la queremos dejar registrada por error en ningún + # lado + def register_in_lounge! + Thread.new do + open("https://chat.#{Site.domain}/#{ENV['LOUNGE']}/#{email}/#{password}") + end + end end diff --git a/app/views/layouts/_breadcrumb.haml b/app/views/layouts/_breadcrumb.haml index 8a0393f0..56a64889 100644 --- a/app/views/layouts/_breadcrumb.haml +++ b/app/views/layouts/_breadcrumb.haml @@ -21,6 +21,8 @@ %li.breadcrumb-item= crumb %ul.navbar-nav - %li + %li.nav-item + = link_to t('.mutual_aid'), mutual_aid_url(local_channel) + %li.nav-item = link_to t('.logout'), destroy_usuarie_session_path, method: :delete, role: 'button', class: 'btn btn-primary' diff --git a/config/locales/en.yml b/config/locales/en.yml index 16145635..f6e88859 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -91,6 +91,7 @@ en: breadcrumb: title: 'Your location in Sutty' logout: Exit + mutual_aid: Mutual aid collaborations: collaborate: submit: Register diff --git a/config/locales/es.yml b/config/locales/es.yml index db5984cb..82f54af5 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -97,6 +97,7 @@ es: breadcrumb: title: 'Tu ubicación en Sutty' logout: Salir + mutual_aid: Ayuda mutua collaborations: collaborate: submit: Registrarme diff --git a/config/routes.rb b/config/routes.rb index 87c3b61f..1c2f79d1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,10 @@ Rails.application.routes.draw do root 'application#index' + direct :mutual_aid do |channel| + "https://chat.#{Site.domain}/?channels=#{channel}" + end + get 'markdown', to: 'application#markdown' # XXX Mantenemos solo esta ruta acá porque form_for no reconoce @site