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,
|
||||
* 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() {
|
||||
if (!props.content) return
|
||||
|
||||
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 ownerData = await indeehubApiService.get<{
|
||||
id: string
|
||||
professionalName?: string
|
||||
lightningAddress?: string
|
||||
}>(`/filmmakers/project/${projectId}/owner`)
|
||||
|
||||
if (ownerData?.professionalName) {
|
||||
if (!ownerData?.id) return
|
||||
|
||||
if (ownerData.professionalName) {
|
||||
creatorName.value = ownerData.professionalName
|
||||
}
|
||||
|
||||
const lightningAddress = ownerData?.lightningAddress
|
||||
if (!lightningAddress) {
|
||||
// No lightning address on the owner, try fetching from payment methods
|
||||
return
|
||||
}
|
||||
// Step 2: Fetch the filmmaker's lightning address
|
||||
const addressData = await indeehubApiService.get<{
|
||||
lightningAddress: string
|
||||
}>(`/filmmakers/${ownerData.id}/lightning-address`)
|
||||
|
||||
const lightningAddress = addressData?.lightningAddress
|
||||
if (!lightningAddress) return
|
||||
|
||||
// Parse lightning address: user@domain → https://domain/.well-known/lnurlp/user
|
||||
const [username, domain] = lightningAddress.split('@')
|
||||
|
||||
Reference in New Issue
Block a user