fix: resolve creator lightning address via two-step API lookup
The /filmmakers/project/:id/owner endpoint returns a FilmmakerDTO which doesn't include lightningAddress. Now correctly fetches the owner's filmmaker ID first, then calls /filmmakers/:id/lightning-address to get their actual lightning address for zap invoice generation. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -238,28 +238,35 @@ watch(() => props.isOpen, async (open) => {
|
|||||||
/**
|
/**
|
||||||
* Resolve the content creator's lightning address via the backend,
|
* Resolve the content creator's lightning address via the backend,
|
||||||
* then fetch the LNURL-pay endpoint for invoice generation.
|
* then fetch the LNURL-pay endpoint for invoice generation.
|
||||||
|
*
|
||||||
|
* Two-step lookup:
|
||||||
|
* 1. GET /filmmakers/project/:id/owner → { id, professionalName }
|
||||||
|
* 2. GET /filmmakers/:id/lightning-address → { lightningAddress }
|
||||||
*/
|
*/
|
||||||
async function resolveLightningAddress() {
|
async function resolveLightningAddress() {
|
||||||
if (!props.content) return
|
if (!props.content) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get the project owner's lightning address from the backend
|
// Step 1: Get the project owner's filmmaker profile
|
||||||
const projectId = props.content.id
|
const projectId = props.content.id
|
||||||
const ownerData = await indeehubApiService.get<{
|
const ownerData = await indeehubApiService.get<{
|
||||||
id: string
|
id: string
|
||||||
professionalName?: string
|
professionalName?: string
|
||||||
lightningAddress?: string
|
|
||||||
}>(`/filmmakers/project/${projectId}/owner`)
|
}>(`/filmmakers/project/${projectId}/owner`)
|
||||||
|
|
||||||
if (ownerData?.professionalName) {
|
if (!ownerData?.id) return
|
||||||
|
|
||||||
|
if (ownerData.professionalName) {
|
||||||
creatorName.value = ownerData.professionalName
|
creatorName.value = ownerData.professionalName
|
||||||
}
|
}
|
||||||
|
|
||||||
const lightningAddress = ownerData?.lightningAddress
|
// Step 2: Fetch the filmmaker's lightning address
|
||||||
if (!lightningAddress) {
|
const addressData = await indeehubApiService.get<{
|
||||||
// No lightning address on the owner, try fetching from payment methods
|
lightningAddress: string
|
||||||
return
|
}>(`/filmmakers/${ownerData.id}/lightning-address`)
|
||||||
}
|
|
||||||
|
const lightningAddress = addressData?.lightningAddress
|
||||||
|
if (!lightningAddress) return
|
||||||
|
|
||||||
// Parse lightning address: user@domain → https://domain/.well-known/lnurlp/user
|
// Parse lightning address: user@domain → https://domain/.well-known/lnurlp/user
|
||||||
const [username, domain] = lightningAddress.split('@')
|
const [username, domain] = lightningAddress.split('@')
|
||||||
|
|||||||
Reference in New Issue
Block a user