Compare commits
33 Commits
docs/integ
...
6e95fa99df
| Author | SHA1 | Date | |
|---|---|---|---|
|
6e95fa99df
|
|||
|
5283f6fce7
|
|||
|
a08a4746f7
|
|||
|
9e3652479b
|
|||
|
011386fb8d
|
|||
|
4d77f5d38c
|
|||
|
64de4deddd
|
|||
|
8f7994d82e
|
|||
|
a7d0e71ab6
|
|||
|
27d9f73c61
|
|||
|
ed3de8b16f
|
|||
|
d7b4c67953
|
|||
| 7489d4a32f | |||
|
ac77e5b7c1
|
|||
|
e544c28105
|
|||
|
4909dac5c2
|
|||
| 3cf4348695 | |||
|
af3da0a26c
|
|||
|
2d32320c7d
|
|||
|
fc2bec6246
|
|||
|
5addd25186
|
|||
|
215d178e69
|
|||
|
5474bf66e7
|
|||
|
ef2a37e2bf
|
|||
|
0e3180602c
|
|||
|
15e2f9b962
|
|||
|
4ae10c9b53
|
|||
| 45137e0cfe | |||
|
717fe93104
|
|||
|
fdac789ccb
|
|||
|
9355dab6b6
|
|||
|
e08ea64f47
|
|||
|
8cc2c9554f
|
13
Dockerfile
13
Dockerfile
@@ -1,18 +1,11 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
FROM debian:bullseye-slim as base
|
FROM ruby:3.3.4
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
# TODO Remove when upstream Ruby works properly on Apple silicon
|
RUN apt-get update -qq && apt-get install -y --no-install-recommends curl \
|
||||||
RUN apt update && apt install -y build-essential wget autoconf libpq-dev pkg-config
|
ldap-utils tini libvips
|
||||||
RUN wget https://github.com/postmodern/ruby-install/releases/download/v0.9.3/ruby-install-0.9.3.tar.gz \
|
|
||||||
&& tar -xzvf ruby-install-0.9.3.tar.gz \
|
|
||||||
&& cd ruby-install-0.9.3/ \
|
|
||||||
&& make install
|
|
||||||
RUN ruby-install -p https://github.com/ruby/ruby/pull/9371.diff ruby 3.3.0
|
|
||||||
ENV PATH="/opt/rubies/ruby-3.3.0/bin:${PATH}"
|
|
||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends curl ldap-utils tini libvips
|
|
||||||
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
|
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
|
||||||
RUN apt-get update && apt-get install -y nodejs
|
RUN apt-get update && apt-get install -y nodejs
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<% @statuses.each do |status| %>
|
||||||
|
<%= render StatusTextComponent.new(
|
||||||
|
text: status[:text],
|
||||||
|
icon_name: status[:icon_name],
|
||||||
|
icon_color: status[:icon_color]
|
||||||
|
) %>
|
||||||
|
<% end %>
|
||||||
46
app/components/settings/nostr_profile_status_component.rb
Normal file
46
app/components/settings/nostr_profile_status_component.rb
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Settings
|
||||||
|
class NostrProfileStatusComponent < ViewComponent::Base
|
||||||
|
def initialize(profile_event:, user_address:)
|
||||||
|
if profile_event.present?
|
||||||
|
profile = JSON.parse(profile_event["content"])
|
||||||
|
@statuses = []
|
||||||
|
|
||||||
|
if profile["nip05"].present? && profile["nip05"] == user_address
|
||||||
|
@statuses.push({
|
||||||
|
text: "Your profile's Nostr address is set to <strong>#{ user_address }</strong>",
|
||||||
|
icon_name: "check-circle",
|
||||||
|
icon_color: "emerald-500"
|
||||||
|
})
|
||||||
|
else
|
||||||
|
@statuses.push({
|
||||||
|
text: "Your profile's Nostr address is not set to <strong>#{ user_address }</strong> yet",
|
||||||
|
icon_name: "alert-octagon",
|
||||||
|
icon_color: "amber-500"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
if profile["lud16"].present? && profile["lud16"] == user_address
|
||||||
|
@statuses.push({
|
||||||
|
text: "Your profile's Lightning address is set to <strong>#{ user_address }</strong>",
|
||||||
|
icon_name: "check-circle",
|
||||||
|
icon_color: "emerald-500"
|
||||||
|
})
|
||||||
|
else
|
||||||
|
@statuses.push({
|
||||||
|
text: "Your profile's Lightning address is not set to <strong>#{ user_address }</strong> yet",
|
||||||
|
icon_name: "alert-octagon",
|
||||||
|
icon_color: "amber-500"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@statuses.push({
|
||||||
|
text: "We could not find a profile for your public key",
|
||||||
|
icon_name: "alert-octagon",
|
||||||
|
icon_color: "amber-500"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<%= render StatusTextComponent.new(
|
||||||
|
text: @text,
|
||||||
|
icon_name: @icon_name,
|
||||||
|
icon_color: @icon_color) %>
|
||||||
23
app/components/settings/nostr_relay_status_component.rb
Normal file
23
app/components/settings/nostr_relay_status_component.rb
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Settings
|
||||||
|
class NostrRelayStatusComponent < ViewComponent::Base
|
||||||
|
def initialize(relay_urls:)
|
||||||
|
if relay_urls.present?
|
||||||
|
if relay_urls.any? { |r| r.include?("wss://nostr.kosmos.org") }
|
||||||
|
@text = "You have a relay list, and the Kosmos relay is part of it"
|
||||||
|
@icon_name = "check-circle"
|
||||||
|
@icon_color = "emerald-500"
|
||||||
|
else
|
||||||
|
@text = "The Kosmos relay is missing from your relay list"
|
||||||
|
@icon_name = "alert-octagon"
|
||||||
|
@icon_color = "amber-500"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@text = "We could not find a relay list for your public key"
|
||||||
|
@icon_name = "alert-octagon"
|
||||||
|
@icon_color = "amber-500"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
8
app/components/status_text_component.html.erb
Normal file
8
app/components/status_text_component.html.erb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<p class="flex gap-x-4 items-center">
|
||||||
|
<span class="inline-block h-6 w-6 grow-0 text-<%= @icon_color %>">
|
||||||
|
<%= render "icons/#{@icon_name}" %>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<%= raw @text %>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
7
app/components/status_text_component.rb
Normal file
7
app/components/status_text_component.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class StatusTextComponent < ViewComponent::Base
|
||||||
|
def initialize(text:, icon_name:, icon_color:)
|
||||||
|
@text = text
|
||||||
|
@icon_name = icon_name
|
||||||
|
@icon_color = icon_color
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -9,4 +9,12 @@ class Admin::Settings::RegistrationsController < Admin::SettingsController
|
|||||||
success: "Settings saved"
|
success: "Settings saved"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def setting_params
|
||||||
|
params.require(:setting).permit([
|
||||||
|
:reserved_usernames, default_services: []
|
||||||
|
])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ class Admin::SettingsController < Admin::BaseController
|
|||||||
changed_keys = []
|
changed_keys = []
|
||||||
|
|
||||||
setting_params.keys.each do |key|
|
setting_params.keys.each do |key|
|
||||||
next if setting_params[key].nil? ||
|
next if clean_param(key).nil? ||
|
||||||
(Setting.send(key).to_s == setting_params[key].strip)
|
(Setting.send(key).to_s == clean_param(key))
|
||||||
|
|
||||||
changed_keys.push(key)
|
changed_keys.push(key)
|
||||||
setting = Setting.new(var: key)
|
setting = Setting.new(var: key)
|
||||||
setting.value = setting_params[key].strip
|
setting.value = clean_param(key)
|
||||||
unless setting.valid?
|
unless setting.valid?
|
||||||
@errors.merge!(setting.errors)
|
@errors.merge!(setting.errors)
|
||||||
end
|
end
|
||||||
@@ -24,7 +25,7 @@ class Admin::SettingsController < Admin::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
changed_keys.each do |key|
|
changed_keys.each do |key|
|
||||||
Setting.send("#{key}=", setting_params[key].strip)
|
Setting.send("#{key}=", clean_param(key))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -37,4 +38,12 @@ class Admin::SettingsController < Admin::BaseController
|
|||||||
def setting_params
|
def setting_params
|
||||||
params.require(:setting).permit(Setting.editable_keys.map(&:to_sym))
|
params.require(:setting).permit(Setting.editable_keys.map(&:to_sym))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clean_param(key)
|
||||||
|
if Setting.get_field(key)[:type] == :string
|
||||||
|
setting_params[key].strip
|
||||||
|
else
|
||||||
|
setting_params[key]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class LnurlpayController < ApplicationController
|
class LnurlpayController < ApplicationController
|
||||||
before_action :check_service_available
|
before_action :check_service_available
|
||||||
before_action :find_user
|
before_action :find_user
|
||||||
before_action :set_cors_access_control_headers, only: [:invoice]
|
before_action :set_cors_access_control_headers
|
||||||
|
|
||||||
MIN_SATS = 10
|
MIN_SATS = 10
|
||||||
MAX_SATS = 1_000_000
|
MAX_SATS = 1_000_000
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class Services::ChatController < Services::BaseController
|
|||||||
before_action :require_service_available
|
before_action :require_service_available
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@service_enabled = current_user.service_enabled?(:xmpp)
|
@service_enabled = current_user.service_enabled?(:ejabberd)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -4,8 +4,13 @@ require "bcrypt"
|
|||||||
class SettingsController < ApplicationController
|
class SettingsController < ApplicationController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :set_main_nav_section
|
before_action :set_main_nav_section
|
||||||
before_action :set_settings_section, only: [:show, :update, :update_email, :reset_email_password]
|
before_action :set_settings_section, only: [
|
||||||
before_action :set_user, only: [:show, :update, :update_email, :reset_email_password]
|
:show, :update, :update_email, :reset_email_password
|
||||||
|
]
|
||||||
|
before_action :set_user, only: [
|
||||||
|
:show, :update, :update_email, :reset_email_password,
|
||||||
|
:fetch_nostr_user_metadata
|
||||||
|
]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
redirect_to setting_path(:profile)
|
redirect_to setting_path(:profile)
|
||||||
@@ -128,6 +133,20 @@ class SettingsController < ApplicationController
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fetch_nostr_user_metadata
|
||||||
|
if @user.nostr_pubkey.present?
|
||||||
|
if @nip65_event = NostrManager::DiscoverUserRelays.call(pubkey: @user.nostr_pubkey)
|
||||||
|
@relay_urls = @nip65_event["tags"].select{ |t| t[0] == "r" }&.map{ |t| t[1] }
|
||||||
|
end
|
||||||
|
|
||||||
|
@profile = NostrManager::DiscoverUserProfile.call(pubkey: @user.nostr_pubkey, relays: @relay_urls)
|
||||||
|
else
|
||||||
|
@relays, @profile = [nil, nil]
|
||||||
|
end
|
||||||
|
|
||||||
|
render partial: 'nostr_user_relays'
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_main_nav_section
|
def set_main_nav_section
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
class WebfingerController < ApplicationController
|
class WebfingerController < WellKnownController
|
||||||
before_action :allow_cross_origin_requests, only: [:show]
|
before_action :allow_cross_origin_requests, only: [:show]
|
||||||
|
|
||||||
layout false
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
resource = params[:resource]
|
resource = params[:resource]
|
||||||
|
|
||||||
@@ -76,7 +74,7 @@ class WebfingerController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def remotestorage_link
|
def remotestorage_link
|
||||||
auth_url = new_rs_oauth_url(@username)
|
auth_url = new_rs_oauth_url(@username, host: Setting.accounts_domain)
|
||||||
storage_url = "#{Setting.rs_storage_url}/#{@username}"
|
storage_url = "#{Setting.rs_storage_url}/#{@username}"
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -91,10 +89,4 @@ class WebfingerController < ApplicationController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def allow_cross_origin_requests
|
|
||||||
return unless Rails.env.development?
|
|
||||||
headers['Access-Control-Allow-Origin'] = "*"
|
|
||||||
headers['Access-Control-Allow-Methods'] = "GET"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
class WellKnownController < ApplicationController
|
class WellKnownController < ApplicationController
|
||||||
before_action :require_nostr_enabled, only: [ :nostr ]
|
before_action :require_nostr_enabled, only: [ :nostr ]
|
||||||
|
before_action :allow_cross_origin_requests, only: [ :nostr ]
|
||||||
|
|
||||||
|
layout false
|
||||||
|
|
||||||
def nostr
|
def nostr
|
||||||
http_status :unprocessable_entity and return if params[:name].blank?
|
http_status :unprocessable_entity and return if params[:name].blank?
|
||||||
@@ -7,8 +10,14 @@ class WellKnownController < ApplicationController
|
|||||||
relay_url = Setting.nostr_relay_url.presence
|
relay_url = Setting.nostr_relay_url.presence
|
||||||
|
|
||||||
if params[:name] == "_"
|
if params[:name] == "_"
|
||||||
# pubkey for the primary domain without a username (e.g. kosmos.org)
|
if domain == Setting.primary_domain
|
||||||
res = { names: { "_": Setting.nostr_public_key } }
|
# pubkey for the primary domain without a username (e.g. kosmos.org)
|
||||||
|
res = { names: { "_": Setting.nostr_public_key_primary_domain.presence || 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
|
res[:relays] = { "_" => [ relay_url ] } if relay_url
|
||||||
else
|
else
|
||||||
@user = User.where(cn: params[:name], ou: domain).first
|
@user = User.where(cn: params[:name], ou: domain).first
|
||||||
@@ -30,4 +39,9 @@ class WellKnownController < ApplicationController
|
|||||||
def require_nostr_enabled
|
def require_nostr_enabled
|
||||||
http_status :not_found unless Setting.nostr_enabled?
|
http_status :not_found unless Setting.nostr_enabled?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def allow_cross_origin_requests
|
||||||
|
headers['Access-Control-Allow-Origin'] = "*"
|
||||||
|
headers['Access-Control-Allow-Methods'] = "GET"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -1,8 +1,14 @@
|
|||||||
import { Controller } from "@hotwired/stimulus"
|
import { Controller } from "@hotwired/stimulus"
|
||||||
|
import { Nostrify } from "nostrify"
|
||||||
|
|
||||||
// Connects to data-controller="settings--nostr-pubkey"
|
// Connects to data-controller="settings--nostr-pubkey"
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
static targets = [ "noExtension", "setPubkey", "pubkeyBech32Input" ]
|
static targets = [
|
||||||
|
"noExtension",
|
||||||
|
"setPubkey", "pubkeyBech32Input",
|
||||||
|
"relayList", "relayListStatus",
|
||||||
|
"profileStatusNip05", "profileStatusLud16"
|
||||||
|
]
|
||||||
static values = {
|
static values = {
|
||||||
userAddress: String,
|
userAddress: String,
|
||||||
pubkeyHex: String,
|
pubkeyHex: String,
|
||||||
@@ -15,6 +21,14 @@ export default class extends Controller {
|
|||||||
if (this.hasSetPubkeyTarget) {
|
if (this.hasSetPubkeyTarget) {
|
||||||
this.setPubkeyTarget.disabled = false
|
this.setPubkeyTarget.disabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.pubkeyHexValue) {
|
||||||
|
// this.discoverUserOnNostr().then(() => {
|
||||||
|
// this.renderRelayStatus()
|
||||||
|
// this.renderProfileNip05Status()
|
||||||
|
// this.renderProfileLud16Status()
|
||||||
|
// })
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.noExtensionTarget.classList.remove("hidden")
|
this.noExtensionTarget.classList.remove("hidden")
|
||||||
}
|
}
|
||||||
@@ -49,8 +63,172 @@ export default class extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async discoverUserOnNostr () {
|
||||||
|
this.nip65Relays = await this.findUserRelays()
|
||||||
|
this.profile = await this.findUserProfile()
|
||||||
|
}
|
||||||
|
|
||||||
|
async findUserRelays () {
|
||||||
|
const controller = new AbortController();
|
||||||
|
const signal = controller.signal;
|
||||||
|
const filters = [{ kinds: [10002], authors: [this.pubkeyHexValue], limit: 1 }]
|
||||||
|
const messages = []
|
||||||
|
|
||||||
|
for await (const msg of this.discoveryPool.req(filters, { signal })) {
|
||||||
|
if (msg[0] === 'EVENT') {
|
||||||
|
if (!messages.find(m => m.id === msg[2].id)) {
|
||||||
|
messages.push(msg[2])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (msg[0] === 'EOSE') { break }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the relay subscription
|
||||||
|
controller.abort()
|
||||||
|
if (messages.length === 0) { return messages }
|
||||||
|
|
||||||
|
const sortedMessages = messages.sort((a, b) => a.createdAt - b.createdAt)
|
||||||
|
const newestMessage = messages[messages.length - 1]
|
||||||
|
|
||||||
|
return newestMessage.tags.filter(t => t[0] === 'r')
|
||||||
|
.map(t => { return { url: t[1], marker: t[2] } })
|
||||||
|
}
|
||||||
|
|
||||||
|
async findUserProfile () {
|
||||||
|
const controller = new AbortController();
|
||||||
|
const signal = controller.signal;
|
||||||
|
const filters = [{ kinds: [0], authors: [this.pubkeyHexValue], limit: 1 }]
|
||||||
|
const messages = []
|
||||||
|
|
||||||
|
for await (const msg of this.discoveryPool.req(filters, { signal })) {
|
||||||
|
if (msg[0] === 'EVENT') {
|
||||||
|
if (!messages.find(m => m.id === msg[2].id)) {
|
||||||
|
messages.push(msg[2])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (msg[0] === 'EOSE') { break }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the relay subscription
|
||||||
|
controller.abort()
|
||||||
|
if (messages.length === 0) { return null }
|
||||||
|
|
||||||
|
const sortedMessages = messages.sort((a, b) => a.createdAt - b.createdAt)
|
||||||
|
const newestMessage = messages[messages.length - 1]
|
||||||
|
|
||||||
|
return JSON.parse(newestMessage.content)
|
||||||
|
}
|
||||||
|
|
||||||
|
renderRelayStatus () {
|
||||||
|
let showStatus
|
||||||
|
|
||||||
|
if (this.nip65Relays.length > 0) {
|
||||||
|
if (this.relaysContainAccountsRelay) {
|
||||||
|
showStatus = 'green'
|
||||||
|
} else {
|
||||||
|
showStatus = 'orange'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showStatus = 'red'
|
||||||
|
}
|
||||||
|
// showStatus = 'red'
|
||||||
|
|
||||||
|
this.relayListStatusTarget
|
||||||
|
.querySelector(`.status-${showStatus}`)
|
||||||
|
.classList.remove("hidden")
|
||||||
|
}
|
||||||
|
|
||||||
|
renderProfileNip05Status () {
|
||||||
|
let showStatus
|
||||||
|
|
||||||
|
if (this.profile?.nip05) {
|
||||||
|
if (this.profile.nip05 === this.userAddressValue) {
|
||||||
|
showStatus = 'green'
|
||||||
|
} else {
|
||||||
|
showStatus = 'red'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showStatus = 'orange'
|
||||||
|
}
|
||||||
|
|
||||||
|
this.profileStatusNip05Target
|
||||||
|
.querySelector(`.status-${showStatus}`)
|
||||||
|
.classList.remove("hidden")
|
||||||
|
}
|
||||||
|
|
||||||
|
renderProfileLud16Status () {
|
||||||
|
let showStatus
|
||||||
|
|
||||||
|
if (this.profile?.lud16) {
|
||||||
|
if (this.profile.lud16 === this.userAddressValue) {
|
||||||
|
showStatus = 'green'
|
||||||
|
} else {
|
||||||
|
showStatus = 'red'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showStatus = 'orange'
|
||||||
|
}
|
||||||
|
|
||||||
|
this.profileStatusLud16Target
|
||||||
|
.querySelector(`.status-${showStatus}`)
|
||||||
|
.classList.remove("hidden")
|
||||||
|
}
|
||||||
|
|
||||||
|
// renderRelayList (relays) {
|
||||||
|
// const html = relays.map(relay => `
|
||||||
|
// <li class="flex items-center justify-between p-2 border-b">
|
||||||
|
// <span>${relay.url}</span>
|
||||||
|
// <button
|
||||||
|
// data-action="click->list#handleItemClick"
|
||||||
|
// data-item="${relay.url}"
|
||||||
|
// class="bg-blue-500 text-white px-3 py-1 rounded">
|
||||||
|
// Action
|
||||||
|
// </button>
|
||||||
|
// </li>
|
||||||
|
// `).join("")
|
||||||
|
//
|
||||||
|
// this.relayListTarget.innerHTML = html
|
||||||
|
// }
|
||||||
|
|
||||||
get csrfToken () {
|
get csrfToken () {
|
||||||
const element = document.head.querySelector('meta[name="csrf-token"]')
|
const element = document.head.querySelector('meta[name="csrf-token"]')
|
||||||
return element.getAttribute("content")
|
return element.getAttribute("content")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used to find a user's profile and relays
|
||||||
|
get discoveryRelays () {
|
||||||
|
return [
|
||||||
|
'ws://localhost:4777',
|
||||||
|
'wss://nostr.kosmos.org',
|
||||||
|
'wss://purplepag.es',
|
||||||
|
// 'wss://relay.nostr.band',
|
||||||
|
// 'wss://njump.me',
|
||||||
|
// 'wss://relay.damus.io',
|
||||||
|
// 'wss://nos.lol',
|
||||||
|
// 'wss://eden.nostr.land',
|
||||||
|
// 'wss://relay.snort.social',
|
||||||
|
// 'wss://nostr.wine',
|
||||||
|
// 'wss://relay.primal.net',
|
||||||
|
// 'wss://nostr.bitcoiner.social',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
get discoveryPool () {
|
||||||
|
if (!this._discoveryPool) {
|
||||||
|
this._discoveryPool = new Nostrify.NPool({
|
||||||
|
open: (url) => new Nostrify.NRelay1(url),
|
||||||
|
reqRouter: async (filters) => new Map(
|
||||||
|
this.discoveryRelays.map(relayUrl => [ relayUrl, filters ])
|
||||||
|
),
|
||||||
|
eventRouter: async (event) => [],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._discoveryPool
|
||||||
|
}
|
||||||
|
|
||||||
|
get relaysContainAccountsRelay () {
|
||||||
|
// TODO use URL from view/settings
|
||||||
|
return !!this.nip65Relays.find(r => r.url.match('wss://nostr.kosmos.org'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ class XmppExchangeContactsJob < ApplicationJob
|
|||||||
queue_as :default
|
queue_as :default
|
||||||
|
|
||||||
def perform(inviter, invitee)
|
def perform(inviter, invitee)
|
||||||
return unless inviter.service_enabled?(:xmpp) &&
|
return unless inviter.service_enabled?(:ejabberd) &&
|
||||||
invitee.service_enabled?(:xmpp) &&
|
invitee.service_enabled?(:ejabberd) &&
|
||||||
inviter.preferences[:xmpp_exchange_contacts_with_invitees]
|
inviter.preferences[:xmpp_exchange_contacts_with_invitees]
|
||||||
|
|
||||||
ejabberd = EjabberdApiClient.new
|
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
|
||||||
38
app/models/concerns/settings/nostr_settings.rb
Normal file
38
app/models/concerns/settings/nostr_settings.rb
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
field :nostr_discovery_relays, type: :array, default: %w[
|
||||||
|
wss://nostr.kosmos.org
|
||||||
|
wss://purplepag.es
|
||||||
|
wss://relay.nostr.band
|
||||||
|
wss://njump.me
|
||||||
|
wss://relay.damus.io
|
||||||
|
]
|
||||||
|
|
||||||
|
def self.nostr_relay_url_http
|
||||||
|
self.nostr_relay_url.gsub(/^ws:/, "http:")
|
||||||
|
.gsub(/^wss:/, "https:")
|
||||||
|
end
|
||||||
|
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
|
class Setting < RailsSettings::Base
|
||||||
cache_prefix { "v1" }
|
cache_prefix { "v1" }
|
||||||
|
|
||||||
field :primary_domain, type: :string,
|
Dir[Rails.root.join('app', 'models', 'concerns', 'settings', '*.rb')].each do |file|
|
||||||
default: ENV["PRIMARY_DOMAIN"].presence
|
require file
|
||||||
|
|
||||||
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 xmpp ]
|
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -180,14 +180,14 @@ class User < ApplicationRecord
|
|||||||
def enable_service(service)
|
def enable_service(service)
|
||||||
current_services = services_enabled
|
current_services = services_enabled
|
||||||
new_services = Array(service).map(&:to_s)
|
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)
|
ldap.replace_attribute(dn, :serviceEnabled, services)
|
||||||
end
|
end
|
||||||
|
|
||||||
def disable_service(service)
|
def disable_service(service)
|
||||||
current_services = services_enabled
|
current_services = services_enabled
|
||||||
disabled_services = Array(service).map(&:to_s)
|
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)
|
ldap.replace_attribute(dn, :serviceEnabled, services)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
36
app/services/nostr_manager/discover_user_profile.rb
Normal file
36
app/services/nostr_manager/discover_user_profile.rb
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
module NostrManager
|
||||||
|
class DiscoverUserProfile < NostrManagerService
|
||||||
|
MAX_EVENTS = 2
|
||||||
|
|
||||||
|
def initialize(pubkey:, relays: nil)
|
||||||
|
@pubkey = pubkey
|
||||||
|
@relays = relays.present? ? relays : Setting.nostr_discovery_relays
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
received_events = 0
|
||||||
|
profile_events = []
|
||||||
|
filter = Nostr::Filter.new(
|
||||||
|
authors: [@pubkey],
|
||||||
|
kinds: [0],
|
||||||
|
limit: 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
@relays.each do |url|
|
||||||
|
event = NostrManager::FetchLatestEvent.call(filter: filter, relay_url: url)
|
||||||
|
|
||||||
|
if event.present?
|
||||||
|
profile_events << event if profile_events.none? { |e| e["id"] == event["id"] }
|
||||||
|
received_events += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if received_events >= MAX_EVENTS
|
||||||
|
puts "Found #{MAX_EVENTS} events, ending the search"
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
profile_events.min_by { |e| e["created_at"] }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
37
app/services/nostr_manager/discover_user_relays.rb
Normal file
37
app/services/nostr_manager/discover_user_relays.rb
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
module NostrManager
|
||||||
|
class DiscoverUserRelays < NostrManagerService
|
||||||
|
MAX_EVENTS = 2
|
||||||
|
|
||||||
|
def initialize(pubkey:)
|
||||||
|
@pubkey = pubkey
|
||||||
|
@relays = Setting.nostr_discovery_relays
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
received_events = 0
|
||||||
|
nip65_events = []
|
||||||
|
user_relays = []
|
||||||
|
filter = Nostr::Filter.new(
|
||||||
|
authors: [@pubkey],
|
||||||
|
kinds: [10002],
|
||||||
|
limit: 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
@relays.each do |url|
|
||||||
|
event = NostrManager::FetchLatestEvent.call(filter: filter, relay_url: url)
|
||||||
|
|
||||||
|
if event.present?
|
||||||
|
nip65_events << event if nip65_events.none? { |e| e["id"] == event["id"] }
|
||||||
|
received_events += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if received_events >= MAX_EVENTS
|
||||||
|
puts "Found #{MAX_EVENTS} events, ending the search"
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
nip65_events.min_by { |e| e["created_at"] }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
59
app/services/nostr_manager/fetch_latest_event.rb
Normal file
59
app/services/nostr_manager/fetch_latest_event.rb
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
module NostrManager
|
||||||
|
class FetchLatestEvent < NostrManagerService
|
||||||
|
TIMEOUT = 1
|
||||||
|
|
||||||
|
def initialize(filter:, relay_url:)
|
||||||
|
@filter = filter
|
||||||
|
@relay = new_relay(relay_url)
|
||||||
|
@client = Nostr::Client.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
filter, client, relay = @filter, @client, @relay
|
||||||
|
latest_event = nil
|
||||||
|
mutex = Mutex.new
|
||||||
|
received_event = ConditionVariable.new
|
||||||
|
log_prefix = "[nostr][#{@relay.name}]"
|
||||||
|
|
||||||
|
thread = Thread.new do
|
||||||
|
client.on :connect do
|
||||||
|
client.subscribe(filter: filter)
|
||||||
|
end
|
||||||
|
|
||||||
|
client.on :error do |e|
|
||||||
|
Rails.logger.info "#{log_prefix} Error: #{e}"
|
||||||
|
Thread.current.exit
|
||||||
|
end
|
||||||
|
|
||||||
|
client.on :message do |m|
|
||||||
|
msg = JSON.parse(m) rescue nil
|
||||||
|
if msg && msg[0] == "EVENT" && msg[2]
|
||||||
|
puts "#{log_prefix} Event received: #{msg[2]["id"]}"
|
||||||
|
mutex.synchronize do
|
||||||
|
latest_event = msg[2]
|
||||||
|
received_event.signal
|
||||||
|
end
|
||||||
|
elsif msg && msg[0] == "EOSE"
|
||||||
|
Thread.current.exit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
client.connect relay
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
Timeout.timeout(TIMEOUT) do
|
||||||
|
mutex.synchronize do
|
||||||
|
received_event.wait(mutex) if latest_event.nil?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue Timeout::Error
|
||||||
|
puts "#{log_prefix} Timeout: No event received within #{TIMEOUT} seconds"
|
||||||
|
ensure
|
||||||
|
thread.exit
|
||||||
|
end
|
||||||
|
|
||||||
|
latest_event
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -3,6 +3,7 @@ require "nostr"
|
|||||||
class NostrManagerService < ApplicationService
|
class NostrManagerService < ApplicationService
|
||||||
def parse_tags(tags)
|
def parse_tags(tags)
|
||||||
out = {}
|
out = {}
|
||||||
|
# TODO support more than 1 item for each tag type
|
||||||
tags.each do |tag|
|
tags.each do |tag|
|
||||||
out[tag[0].to_sym] = tag[1, tag.length]
|
out[tag[0].to_sym] = tag[1, tag.length]
|
||||||
end
|
end
|
||||||
@@ -19,4 +20,8 @@ class NostrManagerService < ApplicationService
|
|||||||
def site_user
|
def site_user
|
||||||
Nostr::User.new(keypair: site_keypair)
|
Nostr::User.new(keypair: site_keypair)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def new_relay(url)
|
||||||
|
Nostr::Relay.new(url: url, name: URI.parse(url).host)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,18 +9,36 @@
|
|||||||
<%= render partial: "admin/settings/errors", locals: { errors: @errors } %>
|
<%= render partial: "admin/settings/errors", locals: { errors: @errors } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<label class="block">
|
<ul role="list">
|
||||||
<p class="font-bold mb-1">Reserved usernames</p>
|
<%= render FormElements::FieldsetComponent.new(
|
||||||
<p class="text-gray-500">
|
title: "Reserved usernames",
|
||||||
These usernames cannot be registered as accounts:
|
description: "These usernames cannot be registered as accounts."
|
||||||
</p>
|
) do %>
|
||||||
<%= f.text_area :reserved_usernames,
|
<%= f.text_area :reserved_usernames,
|
||||||
value: Setting.reserved_usernames.join("\n"),
|
value: Setting.reserved_usernames.join("\n"),
|
||||||
class: "h-44 mb-2" %>
|
class: "h-44 w-60" %>
|
||||||
<p class="text-sm text-gray-500">
|
<p class="text-sm text-gray-500">
|
||||||
One username per line
|
One username per line
|
||||||
</p>
|
</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>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
|||||||
@@ -19,6 +19,11 @@
|
|||||||
title: "Public key",
|
title: "Public key",
|
||||||
description: "The corresponding public key of the accounts service"
|
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(
|
<%= render FormElements::FieldsetResettableSettingComponent.new(
|
||||||
key: :nostr_relay_url,
|
key: :nostr_relay_url,
|
||||||
title: "Relay URL",
|
title: "Relay URL",
|
||||||
@@ -26,13 +31,28 @@
|
|||||||
) %>
|
) %>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h3>Zaps</h3>
|
<h3>Zaps</h3>
|
||||||
<ul role="list">
|
<ul role="list">
|
||||||
<%= render FormElements::FieldsetResettableSettingComponent.new(
|
<%= render FormElements::FieldsetResettableSettingComponent.new(
|
||||||
key: :nostr_zaps_relay_limit,
|
key: :nostr_zaps_relay_limit,
|
||||||
title: "Relay limit",
|
title: "Relay limit",
|
||||||
description: "The maximum number of relays to publish zap receipts to"
|
description: "The maximum number of sender-defined relays to try to publish zap receipts to"
|
||||||
) %>
|
) %>
|
||||||
</ul>
|
</ul>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h3>Onboarding</h3>
|
||||||
|
<ul role="list">
|
||||||
|
<%= render FormElements::FieldsetComponent.new(
|
||||||
|
title: "Discovery relays",
|
||||||
|
description: "Used to discover a user's published relay list and/or profile"
|
||||||
|
) do %>
|
||||||
|
<%= f.text_area :nostr_discovery_relays,
|
||||||
|
value: Setting.nostr_discovery_relays.join("\n"),
|
||||||
|
class: "h-44 w-80" %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<h3>RemoteStorage</h3>
|
<h3>RemoteStorage</h3>
|
||||||
<p class="text-red-600 mb-8">Feature currently in development.</p>
|
|
||||||
<ul role="list">
|
<ul role="list">
|
||||||
<%= render FormElements::FieldsetToggleComponent.new(
|
<%= render FormElements::FieldsetToggleComponent.new(
|
||||||
form: f,
|
form: f,
|
||||||
|
|||||||
@@ -184,7 +184,7 @@
|
|||||||
<td>XMPP (ejabberd)</td>
|
<td>XMPP (ejabberd)</td>
|
||||||
<td>
|
<td>
|
||||||
<%= render FormElements::ToggleComponent.new(
|
<%= render FormElements::ToggleComponent.new(
|
||||||
enabled: @services_enabled.include?("xmpp"),
|
enabled: @services_enabled.include?("ejabberd"),
|
||||||
input_enabled: false
|
input_enabled: false
|
||||||
) %>
|
) %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
<p class="mb-6">
|
<p class="mb-6">
|
||||||
In order to connect an app to your storage account, give it your address:
|
In order to connect an app to your storage account, give it your address:
|
||||||
</p>
|
</p>
|
||||||
<p data-controller="clipboard" class="flex gap-1 sm:w-2/5">
|
<p data-controller="clipboard" class="flex items-center gap-1 sm:w-2/5">
|
||||||
|
<img src="/img/logos/icon_remotestorage.svg" class="inline-block h-6 w-6 mr-1">
|
||||||
<input type="text" id="user_address" class="grow"
|
<input type="text" id="user_address" class="grow"
|
||||||
value=<%= current_user.address %> disabled="disabled"
|
value=<%= current_user.address %> disabled="disabled"
|
||||||
data-clipboard-target="source" />
|
data-clipboard-target="source" />
|
||||||
@@ -31,6 +32,24 @@
|
|||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h3>Compatible Apps</h3>
|
||||||
|
<p>
|
||||||
|
Your Storage account is based on a new open standard called
|
||||||
|
<a href="https://remotestorage.io" target="_blank">
|
||||||
|
<img src="/img/logos/icon_remotestorage.svg" class="h-4 w-4 inline">
|
||||||
|
<strong>remoteStorage</strong>
|
||||||
|
</a>, which is not yet widely supported. Look
|
||||||
|
for the remoteStorage icon, or check the Sync settings in apps.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
If you want your favorite apps to support syncing data with your own
|
||||||
|
Storage account, let the developers know! All relevant information is
|
||||||
|
available on the <a href="https://remotestorage.io"
|
||||||
|
target="_blank" class="ks-text-link">remoteStorage website</a>.
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<h3>Recommended Apps</h3>
|
<h3>Recommended Apps</h3>
|
||||||
<div data-controller="tabs"
|
<div data-controller="tabs"
|
||||||
|
|||||||
@@ -1,47 +1,41 @@
|
|||||||
<section>
|
<div data-controller="settings--nostr-pubkey"
|
||||||
<h3>Nostr</h3>
|
data-settings--nostr-pubkey-user-address-value="<%= current_user.address %>"
|
||||||
<h4 class="mb-0">Public Key</h4>
|
data-settings--nostr-pubkey-site-value="<%= Setting.accounts_domain %>"
|
||||||
<div data-controller="settings--nostr-pubkey"
|
data-settings--nostr-pubkey-shared-secret-value="<%= session[:shared_secret] %>"
|
||||||
data-settings--nostr-pubkey-user-address-value="<%= current_user.address %>"
|
data-settings--nostr-pubkey-pubkey-hex-value="<%= current_user.nostr_pubkey %>">
|
||||||
data-settings--nostr-pubkey-site-value="<%= Setting.accounts_domain %>"
|
<section class="mb-8 sm:mb-12">
|
||||||
data-settings--nostr-pubkey-shared-secret-value="<%= session[:shared_secret] %>"
|
<h3>Nostr</h3>
|
||||||
data-settings--nostr-pubkey-pubkey-hex-value="<%= current_user.nostr_pubkey %>">
|
<h4 class="mb-0">
|
||||||
|
Public Key
|
||||||
<p class="<%= current_user.nostr_pubkey.present? ? '' : 'hidden' %> mt-2 flex gap-1">
|
</h4>
|
||||||
|
<p class="<%= current_user.nostr_pubkey.present? ? '' : 'hidden' %> mt-2 flex gap-x-1">
|
||||||
<input type="text" value="<%= current_user.nostr_pubkey_bech32 %>" disabled
|
<input type="text" value="<%= current_user.nostr_pubkey_bech32 %>" disabled
|
||||||
data-settings--nostr-pubkey-target="pubkeyBech32Input"
|
data-settings--nostr-pubkey-target="pubkeyBech32Input"
|
||||||
name="nostr_public_key" class="relative grow" />
|
name="nostr_public_key" class="w-full" />
|
||||||
<%= link_to nostr_pubkey_settings_path,
|
<%= link_to nostr_pubkey_settings_path,
|
||||||
class: 'btn-md btn-outline text-red-700 relative shrink-0',
|
class: 'btn-md btn-outline relative grow-0 shrink-0 text-red-700',
|
||||||
data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' } do %>
|
data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' } do %>
|
||||||
Remove
|
Remove
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<% if current_user.nostr_pubkey.present? %>
|
<% if current_user.nostr_pubkey.present? %>
|
||||||
<div class="rounded-md bg-blue-50 p-4">
|
<!-- <div> -->
|
||||||
<div class="flex">
|
<!-- Pubkey present -->
|
||||||
<div class="flex-shrink-0">
|
<!-- </div> -->
|
||||||
<svg class="h-5 w-5 text-blue-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
|
||||||
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z" clip-rule="evenodd" />
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div class="ml-3 flex-1">
|
|
||||||
<p class="text-sm text-blue-800">
|
|
||||||
Your user address <strong><%= current_user.address %></strong> is
|
|
||||||
also a Nostr address now. Use your favorite Nostr app, or for
|
|
||||||
example <a href="http://metadata.nostr.com" target="_blank"
|
|
||||||
class="underline">metadata.nostr.com</a>, to add this
|
|
||||||
<strong>NIP-05</strong> address to your public profile.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<p class="my-4">
|
<p class="my-4">
|
||||||
If you use any apps on the Nostr network, you can verify your public key
|
Verify your Nostr public key with us in order to enable Nostr-specific
|
||||||
with us in order to enable Nostr-specific features for your account.
|
features for your account:
|
||||||
</p>
|
</p>
|
||||||
|
<ul class="list-disc list-inside">
|
||||||
|
<li>Log in with Nostr (no password needed)</li>
|
||||||
|
<li>Verified Nostr address</li>
|
||||||
|
<li>Receive zaps in your Lightning account</li>
|
||||||
|
<% if Setting.nostr_relay_url.present? %>
|
||||||
|
<li>Publish notes on <%= link_to "our relay", Setting.nostr_relay_url_http, class: "ks-text-link", target: "_blank" %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div data-settings--nostr-pubkey-target="noExtension"
|
<div data-settings--nostr-pubkey-target="noExtension"
|
||||||
@@ -58,8 +52,8 @@
|
|||||||
</h3>
|
</h3>
|
||||||
<div class="mt-2 mb-0 text-sm text-blue-800">
|
<div class="mt-2 mb-0 text-sm text-blue-800">
|
||||||
<p>
|
<p>
|
||||||
We recommend Alby, which you can also use for your Lightning
|
We recommend Alby, which you can also use a wallet for your
|
||||||
Wallet.
|
Lightning account.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
@@ -86,5 +80,11 @@
|
|||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</section>
|
||||||
</section>
|
|
||||||
|
<% if current_user.nostr_pubkey.present? %>
|
||||||
|
<%= turbo_frame_tag "nostr_user_metadata", src: nostr_user_metadata_settings_path do %>
|
||||||
|
<p>Loading...</p>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|||||||
15
app/views/settings/_nostr_user_relays.html.erb
Normal file
15
app/views/settings/_nostr_user_relays.html.erb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<%= turbo_frame_tag "nostr_user_metadata" do %>
|
||||||
|
<section>
|
||||||
|
<h3>Profile</h3>
|
||||||
|
<%= render Settings::NostrProfileStatusComponent.new(
|
||||||
|
profile_event: @profile,
|
||||||
|
user_address: current_user.address
|
||||||
|
) %>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h3>Relays</h3>
|
||||||
|
<%= render Settings::NostrRelayStatusComponent.new(
|
||||||
|
relay_urls: @relay_urls
|
||||||
|
) %>
|
||||||
|
</section>
|
||||||
|
<% end %>
|
||||||
@@ -6,3 +6,4 @@ pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
|
|||||||
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
|
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
|
||||||
pin_all_from "app/javascript/controllers", under: "controllers"
|
pin_all_from "app/javascript/controllers", under: "controllers"
|
||||||
pin "tailwindcss-stimulus-components" # @4.0.3
|
pin "tailwindcss-stimulus-components" # @4.0.3
|
||||||
|
pin "nostrify"
|
||||||
|
|||||||
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
|
||||||
@@ -65,6 +65,7 @@ Rails.application.routes.draw do
|
|||||||
post 'reset_email_password'
|
post 'reset_email_password'
|
||||||
post 'set_nostr_pubkey'
|
post 'set_nostr_pubkey'
|
||||||
delete 'nostr_pubkey', to: 'settings#remove_nostr_pubkey'
|
delete 'nostr_pubkey', to: 'settings#remove_nostr_pubkey'
|
||||||
|
get 'fetch_nostr_user_metadata', as: 'nostr_user_metadata'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
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
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# strfry (nostr relay)
|
|
||||||
|
|
||||||
## LDAP policy
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
## Useful scripts
|
|
||||||
|
|
||||||
### Syncing events for all local nostr users from a remote relay
|
|
||||||
|
|
||||||
You can sync all events of all local users with a pubkey stored in LDAP from a
|
|
||||||
specified remote relay to the local relay with the `strfry-sync.ts` script:
|
|
||||||
|
|
||||||
deno run -A /opt/strfry-sync.ts wss://relay.example.com
|
|
||||||
|
|
||||||
Doing the same with Docker Compose (great for seeding data to your local relay
|
|
||||||
in development):
|
|
||||||
|
|
||||||
docker compose run strfry deno run -A /opt/strfry-sync.ts wss://relay.example.com
|
|
||||||
|
|
||||||
## Docker image
|
|
||||||
|
|
||||||
In order to use the LDAP policy with Docker, you will need
|
|
||||||
[Deno](https://deno.com/) installed in your strfry container. We provide a
|
|
||||||
custom Docker image for strfry with Deno included (which we use in
|
|
||||||
development):
|
|
||||||
|
|
||||||
* Registry: https://gitea.kosmos.org/kosmos/-/packages/container/strfry-deno/1.1.1
|
|
||||||
* Source: https://github.com/raucao/strfry/blob/docker_deno/ubuntu.Dockerfile
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
"postcss-preset-env": "^7.8.3",
|
"postcss-preset-env": "^7.8.3",
|
||||||
"tailwindcss": "^3.2.4"
|
"tailwindcss": "^3.2.4"
|
||||||
},
|
},
|
||||||
"version": "0.9.0",
|
"version": "0.10.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:css:tailwind": "tailwindcss --postcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css",
|
"build:css:tailwind": "tailwindcss --postcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/application.css",
|
||||||
"build:css": "yarn run build:css:tailwind"
|
"build:css": "yarn run build:css:tailwind"
|
||||||
|
|||||||
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
|
it "adds default services for pre-confirmed accounts" do
|
||||||
allow(ldap_client_mock).to receive(:add) # spy on mock
|
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 }
|
perform_enqueued_jobs { job_for_preconfirmed_account }
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ RSpec.describe CreateLdapUserJob, type: :job do
|
|||||||
sn: "halfinney",
|
sn: "halfinney",
|
||||||
uid: "halfinney",
|
uid: "halfinney",
|
||||||
mail: "halfinney@example.com",
|
mail: "halfinney@example.com",
|
||||||
serviceEnabled: ["xmpp", "discourse"],
|
serviceEnabled: ["ejabberd", "discourse"],
|
||||||
userPassword: "remember-remember-the-5th-of-november"
|
userPassword: "remember-remember-the-5th-of-november"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ RSpec.describe XmppExchangeContactsJob, type: :job do
|
|||||||
before do
|
before do
|
||||||
stub_request(:post, "http://xmpp.example.com/api/add_rosteritem")
|
stub_request(:post, "http://xmpp.example.com/api/add_rosteritem")
|
||||||
.to_return(status: 200, body: "", headers: {})
|
.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
|
end
|
||||||
|
|
||||||
it "posts add_rosteritem commands to the ejabberd API" do
|
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
|
it "returns the entries from the LDAP service attribute" do
|
||||||
expect(user).to receive(:ldap_entry).and_return({
|
expect(user).to receive(:ldap_entry).and_return({
|
||||||
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ RSpec.describe User, type: :model do
|
|||||||
before do
|
before do
|
||||||
allow(user).to receive(:ldap_entry).and_return({
|
allow(user).to receive(:ldap_entry).and_return({
|
||||||
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
||||||
services_enabled: ["gitea", "xmpp"]
|
services_enabled: ["ejabberd", "gitea"]
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -121,9 +121,9 @@ RSpec.describe User, type: :model do
|
|||||||
|
|
||||||
it "adds multiple service to the LDAP entry" do
|
it "adds multiple service to the LDAP entry" do
|
||||||
expect_any_instance_of(LdapService).to receive(:replace_attribute)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ RSpec.describe User, type: :model do
|
|||||||
before do
|
before do
|
||||||
allow(user).to receive(:ldap_entry).and_return({
|
allow(user).to receive(:ldap_entry).and_return({
|
||||||
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
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)
|
allow(user).to receive(:dn).and_return(dn)
|
||||||
end
|
end
|
||||||
@@ -140,14 +140,14 @@ RSpec.describe User, type: :model do
|
|||||||
expect_any_instance_of(LdapService).to receive(:replace_attribute)
|
expect_any_instance_of(LdapService).to receive(:replace_attribute)
|
||||||
.with(dn, :serviceEnabled, ["discourse", "gitea"]).and_return(true)
|
.with(dn, :serviceEnabled, ["discourse", "gitea"]).and_return(true)
|
||||||
|
|
||||||
user.disable_service(:xmpp)
|
user.disable_service(:ejabberd)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "removes multiple services from the LDAP entry" do
|
it "removes multiple services from the LDAP entry" do
|
||||||
expect_any_instance_of(LdapService).to receive(:replace_attribute)
|
expect_any_instance_of(LdapService).to receive(:replace_attribute)
|
||||||
.with(dn, :serviceEnabled, ["discourse"]).and_return(true)
|
.with(dn, :serviceEnabled, ["discourse"]).and_return(true)
|
||||||
|
|
||||||
user.disable_service([:xmpp, "gitea"])
|
user.disable_service([:ejabberd, "gitea"])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ RSpec.describe User, type: :model do
|
|||||||
after { clear_enqueued_jobs }
|
after { clear_enqueued_jobs }
|
||||||
|
|
||||||
it "enables default services" do
|
it "enables default services" do
|
||||||
expect(user).to receive(:enable_service).with(%w[ discourse gitea mastodon mediawiki xmpp ])
|
expect(user).to receive(:enable_service).with(Setting.default_services)
|
||||||
user.send :devise_after_confirmation
|
user.send :devise_after_confirmation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ RSpec.describe "WebFinger", type: :request do
|
|||||||
before do
|
before do
|
||||||
allow_any_instance_of(User).to receive(:ldap_entry).and_return({
|
allow_any_instance_of(User).to receive(:ldap_entry).and_return({
|
||||||
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
||||||
services_enabled: ["xmpp"]
|
services_enabled: ["ejabberd"]
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -92,7 +92,13 @@ RSpec.describe "WebFinger", type: :request do
|
|||||||
expect(rs_link["href"]).to eql("#{Setting.rs_storage_url}/tony")
|
expect(rs_link["href"]).to eql("#{Setting.rs_storage_url}/tony")
|
||||||
|
|
||||||
oauth_url = rs_link["properties"]["http://tools.ietf.org/html/rfc6749#section-4.2"]
|
oauth_url = rs_link["properties"]["http://tools.ietf.org/html/rfc6749#section-4.2"]
|
||||||
expect(oauth_url).to eql("http://www.example.com/rs/oauth/tony")
|
expect(oauth_url).to eql("http://accounts.kosmos.org/rs/oauth/tony")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns CORS headers" do
|
||||||
|
get "/.well-known/nostr.json?name=bobdylan"
|
||||||
|
expect(response.headers['Access-Control-Allow-Origin']).to eq("*")
|
||||||
|
expect(response.headers['Access-Control-Allow-Methods']).to eq('GET')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -100,7 +106,7 @@ RSpec.describe "WebFinger", type: :request do
|
|||||||
before do
|
before do
|
||||||
allow_any_instance_of(User).to receive(:ldap_entry).and_return({
|
allow_any_instance_of(User).to receive(:ldap_entry).and_return({
|
||||||
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
uid: user.cn, ou: user.ou, mail: user.email, admin: nil,
|
||||||
services_enabled: ["xmpp"]
|
services_enabled: ["ejabberd"]
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ RSpec.describe "Well-known URLs", type: :request do
|
|||||||
expect(res["names"]["bobdylan"]).to eq(user.nostr_pubkey)
|
expect(res["names"]["bobdylan"]).to eq(user.nostr_pubkey)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns CORS headers" do
|
||||||
|
get "/.well-known/nostr.json?name=bobdylan"
|
||||||
|
expect(response.headers['Access-Control-Allow-Origin']).to eq("*")
|
||||||
|
expect(response.headers['Access-Control-Allow-Methods']).to eq('GET')
|
||||||
|
end
|
||||||
|
|
||||||
context "without relay configured" do
|
context "without relay configured" do
|
||||||
before do
|
before do
|
||||||
Setting.nostr_relay_url = ""
|
Setting.nostr_relay_url = ""
|
||||||
@@ -73,10 +79,36 @@ RSpec.describe "Well-known URLs", type: :request do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "placeholder username for domain's own pubkey" do
|
describe "placeholder username for domain's own pubkey" do
|
||||||
it "returns the configured nostr pubkey" do
|
describe "for primary domain" do
|
||||||
get "/.well-known/nostr.json?name=_"
|
context "no different pubkey configured for primary domain" do
|
||||||
res = JSON.parse(response.body)
|
it "returns the akkounts nostr pubkey" do
|
||||||
expect(res["names"]["_"]).to eq(Setting.nostr_public_key)
|
get "/.well-known/nostr.json?name=_"
|
||||||
|
res = JSON.parse(response.body)
|
||||||
|
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
|
end
|
||||||
|
|
||||||
context "with relay configured" do
|
context "with relay configured" do
|
||||||
|
|||||||
1
vendor/gems/nostr
vendored
Submodule
1
vendor/gems/nostr
vendored
Submodule
Submodule vendor/gems/nostr added at 44e7454990
11690
vendor/javascript/nostrify.js
vendored
Normal file
11690
vendor/javascript/nostrify.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
vendor/javascript/nostrify.js.map
vendored
Normal file
1
vendor/javascript/nostrify.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user