54 lines
1.7 KiB
Ruby
54 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Settings
|
|
class NostrProfileStatusComponent < ViewComponent::Base
|
|
def initialize(profile_event:, user_address:)
|
|
@statuses = []
|
|
|
|
if profile_event.present?
|
|
profile = JSON.parse(profile_event["content"])
|
|
|
|
@statuses.push({
|
|
text: "You have a public Nostr profile",
|
|
icon_name: "check-circle",
|
|
icon_color: "emerald-500"
|
|
})
|
|
|
|
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
|