Merge branch 'master' into live
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
b82ab45c99
@ -9,4 +9,12 @@ class Admin::Settings::RegistrationsController < Admin::SettingsController
|
||||
success: "Settings saved"
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def setting_params
|
||||
params.require(:setting).permit([
|
||||
:reserved_usernames, default_services: []
|
||||
])
|
||||
end
|
||||
end
|
||||
|
@ -9,11 +9,12 @@ class Admin::SettingsController < Admin::BaseController
|
||||
changed_keys = []
|
||||
|
||||
setting_params.keys.each do |key|
|
||||
next if setting_params[key].nil? ||
|
||||
(Setting.send(key).to_s == setting_params[key].strip)
|
||||
next if clean_param(key).nil? ||
|
||||
(Setting.send(key).to_s == clean_param(key))
|
||||
|
||||
changed_keys.push(key)
|
||||
setting = Setting.new(var: key)
|
||||
setting.value = setting_params[key].strip
|
||||
setting.value = clean_param(key)
|
||||
unless setting.valid?
|
||||
@errors.merge!(setting.errors)
|
||||
end
|
||||
@ -24,7 +25,7 @@ class Admin::SettingsController < Admin::BaseController
|
||||
end
|
||||
|
||||
changed_keys.each do |key|
|
||||
Setting.send("#{key}=", setting_params[key].strip)
|
||||
Setting.send("#{key}=", clean_param(key))
|
||||
end
|
||||
end
|
||||
|
||||
@ -37,4 +38,12 @@ class Admin::SettingsController < Admin::BaseController
|
||||
def setting_params
|
||||
params.require(:setting).permit(Setting.editable_keys.map(&:to_sym))
|
||||
end
|
||||
|
||||
def clean_param(key)
|
||||
if Setting.get_field(key)[:type] == :string
|
||||
setting_params[key].strip
|
||||
else
|
||||
setting_params[key]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ class Services::ChatController < Services::BaseController
|
||||
before_action :require_service_available
|
||||
|
||||
def show
|
||||
@service_enabled = current_user.service_enabled?(:xmpp)
|
||||
@service_enabled = current_user.service_enabled?(:ejabberd)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -10,8 +10,14 @@ class WellKnownController < ApplicationController
|
||||
relay_url = Setting.nostr_relay_url.presence
|
||||
|
||||
if params[:name] == "_"
|
||||
if domain == Setting.primary_domain
|
||||
# pubkey for the primary domain without a username (e.g. kosmos.org)
|
||||
res = { names: { "_": Setting.nostr_public_key_primary_domain || Setting.nostr_public_key } }
|
||||
else
|
||||
# pubkey for the akkounts domain without a username (e.g. accounts.kosmos.org)
|
||||
res = { names: { "_": Setting.nostr_public_key } }
|
||||
end
|
||||
|
||||
res[:relays] = { "_" => [ relay_url ] } if relay_url
|
||||
else
|
||||
@user = User.where(cn: params[:name], ou: domain).first
|
||||
|
@ -1,2 +0,0 @@
|
||||
module DashboardHelper
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
module DonationsHelper
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
module InvitationsHelper
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
module LnurlpayHelper
|
||||
end
|
12
app/helpers/services_helper.rb
Normal file
12
app/helpers/services_helper.rb
Normal file
@ -0,0 +1,12 @@
|
||||
module ServicesHelper
|
||||
|
||||
def service_human_name(key, category = :external)
|
||||
SERVICES[category][key][:name] || key.to_s
|
||||
end
|
||||
|
||||
def service_display_name(key, category = :external)
|
||||
SERVICES[category][key][:display_name] ||
|
||||
service_human_name(key, category)
|
||||
end
|
||||
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
module SettingsHelper
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
module SignupHelper
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
module UsersHelper
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
module WalletHelper
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
module WelcomeHelper
|
||||
end
|
@ -2,8 +2,8 @@ class XmppExchangeContactsJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(inviter, invitee)
|
||||
return unless inviter.service_enabled?(:xmpp) &&
|
||||
invitee.service_enabled?(:xmpp) &&
|
||||
return unless inviter.service_enabled?(:ejabberd) &&
|
||||
invitee.service_enabled?(:ejabberd) &&
|
||||
inviter.preferences[:xmpp_exchange_contacts_with_invitees]
|
||||
|
||||
ejabberd = EjabberdApiClient.new
|
||||
|
24
app/models/concerns/settings/btcpay_settings.rb
Normal file
24
app/models/concerns/settings/btcpay_settings.rb
Normal file
@ -0,0 +1,24 @@
|
||||
module Settings
|
||||
module BtcpaySettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :btcpay_api_url, type: :string,
|
||||
default: ENV["BTCPAY_API_URL"].presence
|
||||
|
||||
field :btcpay_enabled, type: :boolean,
|
||||
default: ENV["BTCPAY_API_URL"].present?
|
||||
|
||||
field :btcpay_public_url, type: :string,
|
||||
default: ENV["BTCPAY_PUBLIC_URL"].presence
|
||||
|
||||
field :btcpay_store_id, type: :string,
|
||||
default: ENV["BTCPAY_STORE_ID"].presence
|
||||
|
||||
field :btcpay_auth_token, type: :string,
|
||||
default: ENV["BTCPAY_AUTH_TOKEN"].presence
|
||||
|
||||
field :btcpay_publish_wallet_balances, type: :boolean, default: true
|
||||
end
|
||||
end
|
||||
end
|
16
app/models/concerns/settings/discourse_settings.rb
Normal file
16
app/models/concerns/settings/discourse_settings.rb
Normal file
@ -0,0 +1,16 @@
|
||||
module Settings
|
||||
module DiscourseSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :discourse_public_url, type: :string,
|
||||
default: ENV["DISCOURSE_PUBLIC_URL"].presence
|
||||
|
||||
field :discourse_enabled, type: :boolean,
|
||||
default: ENV["DISCOURSE_PUBLIC_URL"].present?
|
||||
|
||||
field :discourse_connect_secret, type: :string,
|
||||
default: ENV["DISCOURSE_CONNECT_SECRET"].presence
|
||||
end
|
||||
end
|
||||
end
|
13
app/models/concerns/settings/drone_ci_settings.rb
Normal file
13
app/models/concerns/settings/drone_ci_settings.rb
Normal file
@ -0,0 +1,13 @@
|
||||
module Settings
|
||||
module DroneCiSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :droneci_public_url, type: :string,
|
||||
default: ENV["DRONECI_PUBLIC_URL"].presence
|
||||
|
||||
field :droneci_enabled, type: :boolean,
|
||||
default: ENV["DRONECI_PUBLIC_URL"].present?
|
||||
end
|
||||
end
|
||||
end
|
19
app/models/concerns/settings/ejabberd_settings.rb
Normal file
19
app/models/concerns/settings/ejabberd_settings.rb
Normal file
@ -0,0 +1,19 @@
|
||||
module Settings
|
||||
module EjabberdSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :ejabberd_enabled, type: :boolean,
|
||||
default: ENV["EJABBERD_API_URL"].present?
|
||||
|
||||
field :ejabberd_api_url, type: :string,
|
||||
default: ENV["EJABBERD_API_URL"].presence
|
||||
|
||||
field :ejabberd_admin_url, type: :string,
|
||||
default: ENV["EJABBERD_ADMIN_URL"].presence
|
||||
|
||||
field :ejabberd_buddy_roster, type: :string,
|
||||
default: "Buddies"
|
||||
end
|
||||
end
|
||||
end
|
28
app/models/concerns/settings/email_settings.rb
Normal file
28
app/models/concerns/settings/email_settings.rb
Normal file
@ -0,0 +1,28 @@
|
||||
module Settings
|
||||
module EmailSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :email_enabled, type: :boolean,
|
||||
default: ENV["EMAIL_SMTP_HOST"].present?
|
||||
|
||||
# field :email_smtp_host, type: :string,
|
||||
# default: ENV["EMAIL_SMTP_HOST"].presence
|
||||
#
|
||||
# field :email_smtp_port, type: :string,
|
||||
# default: ENV["EMAIL_SMTP_PORT"].presence || 587
|
||||
#
|
||||
# field :email_smtp_enable_starttls, type: :string,
|
||||
# default: ENV["EMAIL_SMTP_PORT"].presence || true
|
||||
#
|
||||
# field :email_auth_method, type: :string,
|
||||
# default: ENV["EMAIL_AUTH_METHOD"].presence || "plain"
|
||||
#
|
||||
# field :email_imap_host, type: :string,
|
||||
# default: ENV["EMAIL_IMAP_HOST"].presence
|
||||
#
|
||||
# field :email_imap_port, type: :string,
|
||||
# default: ENV["EMAIL_IMAP_PORT"].presence || 993
|
||||
end
|
||||
end
|
||||
end
|
34
app/models/concerns/settings/general_settings.rb
Normal file
34
app/models/concerns/settings/general_settings.rb
Normal file
@ -0,0 +1,34 @@
|
||||
module Settings
|
||||
module GeneralSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :primary_domain, type: :string,
|
||||
default: ENV["PRIMARY_DOMAIN"].presence
|
||||
|
||||
field :accounts_domain, type: :string,
|
||||
default: ENV["AKKOUNTS_DOMAIN"].presence
|
||||
|
||||
#
|
||||
# Internal services
|
||||
#
|
||||
|
||||
field :redis_url, type: :string,
|
||||
default: ENV["REDIS_URL"] || "redis://localhost:6379/0"
|
||||
|
||||
field :s3_enabled, type: :boolean,
|
||||
default: ENV["S3_ENABLED"] && ENV["S3_ENABLED"].to_s != "false"
|
||||
|
||||
field :sentry_enabled, type: :boolean, readonly: true,
|
||||
default: ENV["SENTRY_DSN"].present?
|
||||
|
||||
#
|
||||
# Registrations
|
||||
#
|
||||
|
||||
field :reserved_usernames, type: :array, default: %w[
|
||||
account accounts donations mail webmaster support
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
13
app/models/concerns/settings/gitea_settings.rb
Normal file
13
app/models/concerns/settings/gitea_settings.rb
Normal file
@ -0,0 +1,13 @@
|
||||
module Settings
|
||||
module GiteaSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :gitea_public_url, type: :string,
|
||||
default: ENV["GITEA_PUBLIC_URL"].presence
|
||||
|
||||
field :gitea_enabled, type: :boolean,
|
||||
default: ENV["GITEA_PUBLIC_URL"].present?
|
||||
end
|
||||
end
|
||||
end
|
25
app/models/concerns/settings/lightning_network_settings.rb
Normal file
25
app/models/concerns/settings/lightning_network_settings.rb
Normal file
@ -0,0 +1,25 @@
|
||||
module Settings
|
||||
module LightningNetworkSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :lndhub_api_url, type: :string,
|
||||
default: ENV["LNDHUB_API_URL"].presence
|
||||
|
||||
field :lndhub_enabled, type: :boolean,
|
||||
default: ENV["LNDHUB_API_URL"].present?
|
||||
|
||||
field :lndhub_admin_token, type: :string,
|
||||
default: ENV["LNDHUB_ADMIN_TOKEN"].presence
|
||||
|
||||
field :lndhub_admin_enabled, type: :boolean,
|
||||
default: ENV["LNDHUB_ADMIN_UI"] || false
|
||||
|
||||
field :lndhub_public_key, type: :string,
|
||||
default: (ENV["LNDHUB_PUBLIC_KEY"] || "")
|
||||
|
||||
field :lndhub_keysend_enabled, type: :boolean,
|
||||
default: -> { self.lndhub_public_key.present? }
|
||||
end
|
||||
end
|
||||
end
|
16
app/models/concerns/settings/mastodon_settings.rb
Normal file
16
app/models/concerns/settings/mastodon_settings.rb
Normal file
@ -0,0 +1,16 @@
|
||||
module Settings
|
||||
module MastodonSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :mastodon_public_url, type: :string,
|
||||
default: ENV["MASTODON_PUBLIC_URL"].presence
|
||||
|
||||
field :mastodon_enabled, type: :boolean,
|
||||
default: ENV["MASTODON_PUBLIC_URL"].present?
|
||||
|
||||
field :mastodon_address_domain, type: :string,
|
||||
default: ENV["MASTODON_ADDRESS_DOMAIN"].presence || self.primary_domain
|
||||
end
|
||||
end
|
||||
end
|
13
app/models/concerns/settings/media_wiki_settings.rb
Normal file
13
app/models/concerns/settings/media_wiki_settings.rb
Normal file
@ -0,0 +1,13 @@
|
||||
module Settings
|
||||
module MediaWikiSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :mediawiki_public_url, type: :string,
|
||||
default: ENV["MEDIAWIKI_PUBLIC_URL"].presence
|
||||
|
||||
field :mediawiki_enabled, type: :boolean,
|
||||
default: ENV["MEDIAWIKI_PUBLIC_URL"].present?
|
||||
end
|
||||
end
|
||||
end
|
25
app/models/concerns/settings/nostr_settings.rb
Normal file
25
app/models/concerns/settings/nostr_settings.rb
Normal file
@ -0,0 +1,25 @@
|
||||
module Settings
|
||||
module NostrSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :nostr_enabled, type: :boolean,
|
||||
default: ENV["NOSTR_PRIVATE_KEY"].present?
|
||||
|
||||
field :nostr_private_key, type: :string,
|
||||
default: ENV["NOSTR_PRIVATE_KEY"].presence
|
||||
|
||||
field :nostr_public_key, type: :string,
|
||||
default: ENV["NOSTR_PUBLIC_KEY"].presence
|
||||
|
||||
field :nostr_public_key_primary_domain, type: :string,
|
||||
default: ENV["NOSTR_PUBLIC_KEY_PRIMARY_DOMAIN"].presence
|
||||
|
||||
field :nostr_relay_url, type: :string,
|
||||
default: ENV["NOSTR_RELAY_URL"].presence
|
||||
|
||||
field :nostr_zaps_relay_limit, type: :integer,
|
||||
default: 12
|
||||
end
|
||||
end
|
||||
end
|
9
app/models/concerns/settings/open_collective_settings.rb
Normal file
9
app/models/concerns/settings/open_collective_settings.rb
Normal file
@ -0,0 +1,9 @@
|
||||
module Settings
|
||||
module OpenCollectiveSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :opencollective_enabled, type: :boolean, default: true
|
||||
end
|
||||
end
|
||||
end
|
16
app/models/concerns/settings/remote_storage_settings.rb
Normal file
16
app/models/concerns/settings/remote_storage_settings.rb
Normal file
@ -0,0 +1,16 @@
|
||||
module Settings
|
||||
module RemoteStorageSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :remotestorage_enabled, type: :boolean,
|
||||
default: ENV["RS_STORAGE_URL"].present?
|
||||
|
||||
field :rs_storage_url, type: :string,
|
||||
default: ENV["RS_STORAGE_URL"].presence
|
||||
|
||||
field :rs_redis_url, type: :string,
|
||||
default: ENV["RS_REDIS_URL"] || "redis://localhost:6379/1"
|
||||
end
|
||||
end
|
||||
end
|
11
app/models/concerns/settings/xmpp_settings.rb
Normal file
11
app/models/concerns/settings/xmpp_settings.rb
Normal file
@ -0,0 +1,11 @@
|
||||
module Settings
|
||||
module XmppSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
field :xmpp_default_rooms, type: :array, default: []
|
||||
field :xmpp_autojoin_default_rooms, type: :boolean, default: false
|
||||
field :xmpp_notifications_from_address, type: :string, default: primary_domain
|
||||
end
|
||||
end
|
||||
end
|
@ -2,226 +2,30 @@
|
||||
class Setting < RailsSettings::Base
|
||||
cache_prefix { "v1" }
|
||||
|
||||
field :primary_domain, type: :string,
|
||||
default: ENV["PRIMARY_DOMAIN"].presence
|
||||
|
||||
field :accounts_domain, type: :string,
|
||||
default: ENV["AKKOUNTS_DOMAIN"].presence
|
||||
|
||||
#
|
||||
# Internal services
|
||||
#
|
||||
|
||||
field :redis_url, type: :string,
|
||||
default: ENV["REDIS_URL"] || "redis://localhost:6379/0"
|
||||
|
||||
field :s3_enabled, type: :boolean,
|
||||
default: ENV["S3_ENABLED"] && ENV["S3_ENABLED"].to_s != "false"
|
||||
|
||||
#
|
||||
# Registrations
|
||||
#
|
||||
|
||||
field :reserved_usernames, type: :array, default: %w[
|
||||
account accounts donations mail webmaster support
|
||||
]
|
||||
|
||||
#
|
||||
# XMPP
|
||||
#
|
||||
|
||||
field :xmpp_default_rooms, type: :array, default: []
|
||||
field :xmpp_autojoin_default_rooms, type: :boolean, default: false
|
||||
field :xmpp_notifications_from_address, type: :string, default: primary_domain
|
||||
|
||||
#
|
||||
# Sentry
|
||||
#
|
||||
|
||||
field :sentry_enabled, type: :boolean, readonly: true,
|
||||
default: ENV["SENTRY_DSN"].present?
|
||||
|
||||
#
|
||||
# BTCPay Server
|
||||
#
|
||||
|
||||
field :btcpay_api_url, type: :string,
|
||||
default: ENV["BTCPAY_API_URL"].presence
|
||||
|
||||
field :btcpay_enabled, type: :boolean,
|
||||
default: ENV["BTCPAY_API_URL"].present?
|
||||
|
||||
field :btcpay_public_url, type: :string,
|
||||
default: ENV["BTCPAY_PUBLIC_URL"].presence
|
||||
|
||||
field :btcpay_store_id, type: :string,
|
||||
default: ENV["BTCPAY_STORE_ID"].presence
|
||||
|
||||
field :btcpay_auth_token, type: :string,
|
||||
default: ENV["BTCPAY_AUTH_TOKEN"].presence
|
||||
|
||||
field :btcpay_publish_wallet_balances, type: :boolean, default: true
|
||||
|
||||
#
|
||||
# Discourse
|
||||
#
|
||||
|
||||
field :discourse_public_url, type: :string,
|
||||
default: ENV["DISCOURSE_PUBLIC_URL"].presence
|
||||
|
||||
field :discourse_enabled, type: :boolean,
|
||||
default: ENV["DISCOURSE_PUBLIC_URL"].present?
|
||||
|
||||
field :discourse_connect_secret, type: :string,
|
||||
default: ENV["DISCOURSE_CONNECT_SECRET"].presence
|
||||
|
||||
#
|
||||
# Drone CI
|
||||
#
|
||||
|
||||
field :droneci_public_url, type: :string,
|
||||
default: ENV["DRONECI_PUBLIC_URL"].presence
|
||||
|
||||
field :droneci_enabled, type: :boolean,
|
||||
default: ENV["DRONECI_PUBLIC_URL"].present?
|
||||
|
||||
#
|
||||
# ejabberd
|
||||
#
|
||||
|
||||
field :ejabberd_enabled, type: :boolean,
|
||||
default: ENV["EJABBERD_API_URL"].present?
|
||||
|
||||
field :ejabberd_api_url, type: :string,
|
||||
default: ENV["EJABBERD_API_URL"].presence
|
||||
|
||||
field :ejabberd_admin_url, type: :string,
|
||||
default: ENV["EJABBERD_ADMIN_URL"].presence
|
||||
|
||||
field :ejabberd_buddy_roster, type: :string,
|
||||
default: "Buddies"
|
||||
|
||||
#
|
||||
# Gitea
|
||||
#
|
||||
|
||||
field :gitea_public_url, type: :string,
|
||||
default: ENV["GITEA_PUBLIC_URL"].presence
|
||||
|
||||
field :gitea_enabled, type: :boolean,
|
||||
default: ENV["GITEA_PUBLIC_URL"].present?
|
||||
|
||||
#
|
||||
# Lightning Network
|
||||
#
|
||||
|
||||
field :lndhub_api_url, type: :string,
|
||||
default: ENV["LNDHUB_API_URL"].presence
|
||||
|
||||
field :lndhub_enabled, type: :boolean,
|
||||
default: ENV["LNDHUB_API_URL"].present?
|
||||
|
||||
field :lndhub_admin_token, type: :string,
|
||||
default: ENV["LNDHUB_ADMIN_TOKEN"].presence
|
||||
|
||||
field :lndhub_admin_enabled, type: :boolean,
|
||||
default: ENV["LNDHUB_ADMIN_UI"] || false
|
||||
|
||||
field :lndhub_public_key, type: :string,
|
||||
default: (ENV["LNDHUB_PUBLIC_KEY"] || "")
|
||||
|
||||
field :lndhub_keysend_enabled, type: :boolean,
|
||||
default: -> { self.lndhub_public_key.present? }
|
||||
|
||||
#
|
||||
# Mastodon
|
||||
#
|
||||
|
||||
field :mastodon_public_url, type: :string,
|
||||
default: ENV["MASTODON_PUBLIC_URL"].presence
|
||||
|
||||
field :mastodon_enabled, type: :boolean,
|
||||
default: ENV["MASTODON_PUBLIC_URL"].present?
|
||||
|
||||
field :mastodon_address_domain, type: :string,
|
||||
default: ENV["MASTODON_ADDRESS_DOMAIN"].presence || self.primary_domain
|
||||
|
||||
#
|
||||
# MediaWiki
|
||||
#
|
||||
|
||||
field :mediawiki_public_url, type: :string,
|
||||
default: ENV["MEDIAWIKI_PUBLIC_URL"].presence
|
||||
|
||||
field :mediawiki_enabled, type: :boolean,
|
||||
default: ENV["MEDIAWIKI_PUBLIC_URL"].present?
|
||||
|
||||
#
|
||||
# Nostr
|
||||
#
|
||||
|
||||
field :nostr_enabled, type: :boolean,
|
||||
default: ENV["NOSTR_PRIVATE_KEY"].present?
|
||||
|
||||
field :nostr_private_key, type: :string,
|
||||
default: ENV["NOSTR_PRIVATE_KEY"].presence
|
||||
|
||||
field :nostr_public_key, type: :string,
|
||||
default: ENV["NOSTR_PUBLIC_KEY"].presence
|
||||
|
||||
field :nostr_relay_url, type: :string,
|
||||
default: ENV["NOSTR_RELAY_URL"].presence
|
||||
|
||||
field :nostr_zaps_relay_limit, type: :integer,
|
||||
default: 12
|
||||
|
||||
#
|
||||
# OpenCollective
|
||||
#
|
||||
|
||||
field :opencollective_enabled, type: :boolean, default: true
|
||||
|
||||
#
|
||||
# RemoteStorage
|
||||
#
|
||||
|
||||
field :remotestorage_enabled, type: :boolean,
|
||||
default: ENV["RS_STORAGE_URL"].present?
|
||||
|
||||
field :rs_storage_url, type: :string,
|
||||
default: ENV["RS_STORAGE_URL"].presence
|
||||
|
||||
field :rs_redis_url, type: :string,
|
||||
default: ENV["RS_REDIS_URL"] || "redis://localhost:6379/1"
|
||||
|
||||
|
||||
#
|
||||
# E-Mail Service
|
||||
#
|
||||
|
||||
field :email_enabled, type: :boolean,
|
||||
default: ENV["EMAIL_SMTP_HOST"].present?
|
||||
|
||||
# field :email_smtp_host, type: :string,
|
||||
# default: ENV["EMAIL_SMTP_HOST"].presence
|
||||
#
|
||||
# field :email_smtp_port, type: :string,
|
||||
# default: ENV["EMAIL_SMTP_PORT"].presence || 587
|
||||
#
|
||||
# field :email_smtp_enable_starttls, type: :string,
|
||||
# default: ENV["EMAIL_SMTP_PORT"].presence || true
|
||||
#
|
||||
# field :email_auth_method, type: :string,
|
||||
# default: ENV["EMAIL_AUTH_METHOD"].presence || "plain"
|
||||
#
|
||||
# field :email_imap_host, type: :string,
|
||||
# default: ENV["EMAIL_IMAP_HOST"].presence
|
||||
#
|
||||
# field :email_imap_port, type: :string,
|
||||
# default: ENV["EMAIL_IMAP_PORT"].presence || 993
|
||||
|
||||
def self.default_services
|
||||
# TODO Make configurable from respective service settings page
|
||||
%w[ discourse gitea mastodon mediawiki remotestorage xmpp ]
|
||||
Dir[Rails.root.join('app', 'models', 'concerns', 'settings', '*.rb')].each do |file|
|
||||
require file
|
||||
end
|
||||
|
||||
include Settings::GeneralSettings
|
||||
include Settings::BtcpaySettings
|
||||
include Settings::DiscourseSettings
|
||||
include Settings::DroneCiSettings
|
||||
include Settings::EjabberdSettings
|
||||
include Settings::EmailSettings
|
||||
include Settings::GiteaSettings
|
||||
include Settings::LightningNetworkSettings
|
||||
include Settings::MastodonSettings
|
||||
include Settings::MediaWikiSettings
|
||||
include Settings::NostrSettings
|
||||
include Settings::OpenCollectiveSettings
|
||||
include Settings::RemoteStorageSettings
|
||||
include Settings::XmppSettings
|
||||
|
||||
def self.available_services
|
||||
known_services = SERVICES[:external].keys
|
||||
known_services.select {|s| Setting.send "#{s}_enabled?" }
|
||||
end
|
||||
|
||||
field :default_services, type: :array,
|
||||
default: self.available_services
|
||||
end
|
||||
|
@ -180,14 +180,14 @@ class User < ApplicationRecord
|
||||
def enable_service(service)
|
||||
current_services = services_enabled
|
||||
new_services = Array(service).map(&:to_s)
|
||||
services = (current_services + new_services).uniq
|
||||
services = (current_services + new_services).uniq.sort
|
||||
ldap.replace_attribute(dn, :serviceEnabled, services)
|
||||
end
|
||||
|
||||
def disable_service(service)
|
||||
current_services = services_enabled
|
||||
disabled_services = Array(service).map(&:to_s)
|
||||
services = (current_services - disabled_services).uniq
|
||||
services = (current_services - disabled_services).uniq.sort
|
||||
ldap.replace_attribute(dn, :serviceEnabled, services)
|
||||
end
|
||||
|
||||
|
@ -9,18 +9,36 @@
|
||||
<%= render partial: "admin/settings/errors", locals: { errors: @errors } %>
|
||||
<% end %>
|
||||
|
||||
<label class="block">
|
||||
<p class="font-bold mb-1">Reserved usernames</p>
|
||||
<p class="text-gray-500">
|
||||
These usernames cannot be registered as accounts:
|
||||
</p>
|
||||
<ul role="list">
|
||||
<%= render FormElements::FieldsetComponent.new(
|
||||
title: "Reserved usernames",
|
||||
description: "These usernames cannot be registered as accounts."
|
||||
) do %>
|
||||
<%= f.text_area :reserved_usernames,
|
||||
value: Setting.reserved_usernames.join("\n"),
|
||||
class: "h-44 mb-2" %>
|
||||
class: "h-44 w-60" %>
|
||||
<p class="text-sm text-gray-500">
|
||||
One username per line
|
||||
</p>
|
||||
</label>
|
||||
<% end %>
|
||||
<li>
|
||||
<p class="font-bold mb-1">Default services</p>
|
||||
<p class="text-gray-500">
|
||||
These services are enabled for new users by default after signup.
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-x-6 gap-y-2">
|
||||
<% Setting.available_services.each do |option| %>
|
||||
<div class="md:inline-block">
|
||||
<%= f.check_box :default_services,
|
||||
{ multiple: true, checked: Setting.default_services.include?(option),
|
||||
class: "h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-600 mr-0.5" },
|
||||
option, nil %>
|
||||
<%= f.label "default_services_#{option.parameterize}", service_human_name(option) %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
@ -19,6 +19,11 @@
|
||||
title: "Public key",
|
||||
description: "The corresponding public key of the accounts service"
|
||||
) %>
|
||||
<%= render FormElements::FieldsetResettableSettingComponent.new(
|
||||
key: :nostr_public_key_primary_domain,
|
||||
title: "Public key for primary domain (NIP-05)",
|
||||
description: "(optional) A different pubkey to announce for the _@#{Setting.primary_domain} Nostr address"
|
||||
) %>
|
||||
<%= render FormElements::FieldsetResettableSettingComponent.new(
|
||||
key: :nostr_relay_url,
|
||||
title: "Relay URL",
|
||||
|
@ -1,5 +1,4 @@
|
||||
<h3>RemoteStorage</h3>
|
||||
<p class="text-red-600 mb-8">Feature currently in development.</p>
|
||||
<ul role="list">
|
||||
<%= render FormElements::FieldsetToggleComponent.new(
|
||||
form: f,
|
||||
|
2
config/initializers/service_details.rb
Normal file
2
config/initializers/service_details.rb
Normal file
@ -0,0 +1,2 @@
|
||||
config_path = Rails.root.join('config', 'services.yml')
|
||||
SERVICES = YAML.load_file(config_path).deep_symbolize_keys.with_indifferent_access
|
30
config/services.yml
Normal file
30
config/services.yml
Normal file
@ -0,0 +1,30 @@
|
||||
internal:
|
||||
btcpay:
|
||||
name: BTCPay Server
|
||||
postgres:
|
||||
name: PostgreSQL
|
||||
sentry:
|
||||
name: Sentry
|
||||
external:
|
||||
discourse:
|
||||
name: Discourse
|
||||
droneci:
|
||||
name: Drone CI
|
||||
ejabberd:
|
||||
display_name: Chat
|
||||
email:
|
||||
name: E-Mail
|
||||
gitea:
|
||||
name: Gitea
|
||||
lndhub:
|
||||
name: LNDHub
|
||||
display_name: Lightning Network
|
||||
mastodon:
|
||||
name: Mastodon
|
||||
mediawiki:
|
||||
name: MediaWiki
|
||||
nostr:
|
||||
name: Nostr
|
||||
remotestorage:
|
||||
name: remoteStorage
|
||||
display_name: Storage
|
25
spec/helpers/services_helper_spec.rb
Normal file
25
spec/helpers/services_helper_spec.rb
Normal file
@ -0,0 +1,25 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe ServicesHelper do
|
||||
|
||||
describe "#service_human_name" do
|
||||
it "returns the human name when it's configured" do
|
||||
expect(service_human_name("mastodon")).to eq("Mastodon")
|
||||
end
|
||||
|
||||
it "returns the key when there is no human name" do
|
||||
expect(service_human_name("ejabberd")).to eq("ejabberd")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#service_display_name" do
|
||||
it "returns the display name when it's configured" do
|
||||
expect(service_display_name("lndhub")).to eq("Lightning Network")
|
||||
end
|
||||
|
||||
it "returns the human name when there is no display name" do
|
||||
expect(service_display_name("mastodon")).to eq("Mastodon")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -44,7 +44,7 @@ RSpec.describe CreateLdapUserJob, type: :job do
|
||||
|
||||
it "adds default services for pre-confirmed accounts" do
|
||||
allow(ldap_client_mock).to receive(:add) # spy on mock
|
||||
allow(Setting).to receive(:default_services).and_return(["xmpp", "discourse"])
|
||||
Setting.default_services = ["ejabberd", "discourse"]
|
||||
|
||||
perform_enqueued_jobs { job_for_preconfirmed_account }
|
||||
|
||||
@ -56,7 +56,7 @@ RSpec.describe CreateLdapUserJob, type: :job do
|
||||
sn: "halfinney",
|
||||
uid: "halfinney",
|
||||
mail: "halfinney@example.com",
|
||||
serviceEnabled: ["xmpp", "discourse"],
|
||||
serviceEnabled: ["ejabberd", "discourse"],
|
||||
userPassword: "remember-remember-the-5th-of-november"
|
||||
}
|
||||
)
|
||||
|
@ -13,7 +13,7 @@ RSpec.describe XmppExchangeContactsJob, type: :job do
|
||||
before do
|
||||
stub_request(:post, "http://xmpp.example.com/api/add_rosteritem")
|
||||
.to_return(status: 200, body: "", headers: {})
|
||||
allow_any_instance_of(User).to receive(:services_enabled).and_return(["xmpp"])
|
||||
allow_any_instance_of(User).to receive(:services_enabled).and_return(["ejabberd"])
|
||||
end
|
||||
|
||||
it "posts add_rosteritem commands to the ejabberd API" do
|
||||
|
25
spec/models/setting_spec.rb
Normal file
25
spec/models/setting_spec.rb
Normal file
@ -0,0 +1,25 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Setting, type: :model do
|
||||
|
||||
describe ".available_services" do
|
||||
before do
|
||||
Setting.discourse_enabled = true
|
||||
Setting.ejabberd_enabled = true
|
||||
Setting.email_enabled = false
|
||||
Setting.gitea_enabled = false
|
||||
Setting.lndhub_enabled = true
|
||||
Setting.mastodon_enabled = true
|
||||
Setting.mediawiki_enabled = false
|
||||
Setting.nostr_enabled = false
|
||||
Setting.remotestorage_enabled = true
|
||||
end
|
||||
|
||||
it "contains all enabled services" do
|
||||
expect(Setting.available_services).to eq(%w[
|
||||
discourse ejabberd lndhub mastodon remotestorage
|
||||
])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -78,9 +78,9 @@ RSpec.describe User, type: :model do
|
||||
it "returns the entries from the LDAP service attribute" do
|
||||
expect(user).to receive(:ldap_entry).and_return({
|
||||
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
||||
services_enabled: ["discourse", "email", "gitea", "wiki", "xmpp"]
|
||||
services_enabled: ["discourse", "ejabberd", "email", "gitea", "wiki"]
|
||||
})
|
||||
expect(user.services_enabled).to eq(["discourse", "email", "gitea", "wiki", "xmpp"])
|
||||
expect(user.services_enabled).to eq(["discourse", "ejabberd", "email", "gitea", "wiki"])
|
||||
end
|
||||
end
|
||||
|
||||
@ -88,7 +88,7 @@ RSpec.describe User, type: :model do
|
||||
before do
|
||||
allow(user).to receive(:ldap_entry).and_return({
|
||||
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
||||
services_enabled: ["gitea", "xmpp"]
|
||||
services_enabled: ["ejabberd", "gitea"]
|
||||
})
|
||||
end
|
||||
|
||||
@ -121,9 +121,9 @@ RSpec.describe User, type: :model do
|
||||
|
||||
it "adds multiple service to the LDAP entry" do
|
||||
expect_any_instance_of(LdapService).to receive(:replace_attribute)
|
||||
.with(dn, :serviceEnabled, ["discourse", "gitea", "wiki", "xmpp"]).and_return(true)
|
||||
.with(dn, :serviceEnabled, ["discourse", "ejabberd", "gitea", "wiki"]).and_return(true)
|
||||
|
||||
user.enable_service([:wiki, :xmpp])
|
||||
user.enable_service([:ejabberd, :wiki])
|
||||
end
|
||||
end
|
||||
|
||||
@ -131,7 +131,7 @@ RSpec.describe User, type: :model do
|
||||
before do
|
||||
allow(user).to receive(:ldap_entry).and_return({
|
||||
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
||||
services_enabled: ["discourse", "gitea", "xmpp"]
|
||||
services_enabled: ["discourse", "ejabberd", "gitea"]
|
||||
})
|
||||
allow(user).to receive(:dn).and_return(dn)
|
||||
end
|
||||
@ -140,14 +140,14 @@ RSpec.describe User, type: :model do
|
||||
expect_any_instance_of(LdapService).to receive(:replace_attribute)
|
||||
.with(dn, :serviceEnabled, ["discourse", "gitea"]).and_return(true)
|
||||
|
||||
user.disable_service(:xmpp)
|
||||
user.disable_service(:ejabberd)
|
||||
end
|
||||
|
||||
it "removes multiple services from the LDAP entry" do
|
||||
expect_any_instance_of(LdapService).to receive(:replace_attribute)
|
||||
.with(dn, :serviceEnabled, ["discourse"]).and_return(true)
|
||||
|
||||
user.disable_service([:xmpp, "gitea"])
|
||||
user.disable_service([:ejabberd, "gitea"])
|
||||
end
|
||||
end
|
||||
|
||||
@ -178,7 +178,7 @@ RSpec.describe User, type: :model do
|
||||
after { clear_enqueued_jobs }
|
||||
|
||||
it "enables default services" do
|
||||
expect(user).to receive(:enable_service).with(%w[ discourse gitea mastodon mediawiki remotestorage xmpp ])
|
||||
expect(user).to receive(:enable_service).with(Setting.default_services)
|
||||
user.send :devise_after_confirmation
|
||||
end
|
||||
|
||||
|
@ -44,7 +44,7 @@ RSpec.describe "WebFinger", type: :request do
|
||||
before do
|
||||
allow_any_instance_of(User).to receive(:ldap_entry).and_return({
|
||||
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
||||
services_enabled: ["xmpp"]
|
||||
services_enabled: ["ejabberd"]
|
||||
})
|
||||
end
|
||||
|
||||
@ -106,7 +106,7 @@ RSpec.describe "WebFinger", type: :request do
|
||||
before do
|
||||
allow_any_instance_of(User).to receive(:ldap_entry).and_return({
|
||||
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
||||
services_enabled: ["xmpp"]
|
||||
services_enabled: ["ejabberd"]
|
||||
})
|
||||
end
|
||||
|
||||
|
@ -79,10 +79,36 @@ RSpec.describe "Well-known URLs", type: :request do
|
||||
end
|
||||
|
||||
describe "placeholder username for domain's own pubkey" do
|
||||
it "returns the configured nostr pubkey" do
|
||||
describe "for primary domain" do
|
||||
context "no different pubkey configured for primary domain" do
|
||||
it "returns the akkounts nostr pubkey" do
|
||||
get "/.well-known/nostr.json?name=_"
|
||||
res = JSON.parse(response.body)
|
||||
expect(res["names"]["_"]).to eq(Setting.nostr_public_key)
|
||||
expect(res["names"]["_"]).to eq("bdd76ce2934b2f591f9fad2ebe9da18f20d2921de527494ba00eeaa0a0efadcf")
|
||||
end
|
||||
end
|
||||
|
||||
context "different pubkey configured for primary domain" do
|
||||
before do
|
||||
Setting.nostr_public_key_primary_domain = "b3e8f62fbe41217ffc0aa1e178d297339932d8ba4f46d9c7df3b61575e78fecc"
|
||||
end
|
||||
|
||||
it "returns the primary domain's nostr pubkey" do
|
||||
get "/.well-known/nostr.json?name=_"
|
||||
res = JSON.parse(response.body)
|
||||
expect(res["names"]["_"]).to eq("b3e8f62fbe41217ffc0aa1e178d297339932d8ba4f46d9c7df3b61575e78fecc")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "for akkounts domain" do
|
||||
it "returns the configured nostr pubkey" do
|
||||
headers = { "X-Forwarded-Host" => "accounts.kosmos.org" }
|
||||
get "/.well-known/nostr.json?name=_"
|
||||
|
||||
res = JSON.parse(response.body)
|
||||
expect(res["names"]["_"]).to eq("bdd76ce2934b2f591f9fad2ebe9da18f20d2921de527494ba00eeaa0a0efadcf")
|
||||
end
|
||||
end
|
||||
|
||||
context "with relay configured" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user