WIP Render nostr profile and relay status with Ruby
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-10-18 15:01:08 +02:00
parent 5283f6fce7
commit 6e95fa99df
14 changed files with 161 additions and 126 deletions

View File

@@ -4,8 +4,13 @@ require "bcrypt"
class SettingsController < ApplicationController
before_action :authenticate_user!
before_action :set_main_nav_section
before_action :set_settings_section, only: [:show, :update, :update_email, :reset_email_password]
before_action :set_user, only: [:show, :update, :update_email, :reset_email_password]
before_action :set_settings_section, only: [
: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
redirect_to setting_path(:profile)
@@ -128,6 +133,20 @@ class SettingsController < ApplicationController
}
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
def set_main_nav_section