Add NIP-05 well-known endpoint

This commit is contained in:
Râu Cao
2023-03-18 13:35:02 +07:00
parent c48538a1c6
commit 34e4cec503
3 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
class WellKnownController < ApplicationController
def nostr
http_status :unprocessable_entity and return if params[:name].blank?
domain = request.headers["X-Forwarded-Host"].presence || Setting.primary_domain
@user = User.where(cn: params[:name], ou: domain).first
http_status :not_found and return if @user.nil? || @user.nostr_pubkey.blank?
respond_to do |format|
format.json do
render json: {
names: { "#{@user.cn}": @user.nostr_pubkey }
}.to_json
end
end
end
end