mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-12 08:27:27 +02:00
feat: add zap support for NIP-10 thread chat messages
Implement getZapConfig method to enable zapping messages in NIP-10 threads: - Returns message author as recipient - Includes event pointer for the message being zapped - Uses conversation metadata relays for zap receipt publishing - Integrates with new zap infrastructure from main branch
This commit is contained in:
@@ -2,7 +2,11 @@ import { Observable, firstValueFrom, combineLatest } from "rxjs";
|
||||
import { map, first, toArray } from "rxjs/operators";
|
||||
import type { Filter } from "nostr-tools";
|
||||
import { nip19 } from "nostr-tools";
|
||||
import { ChatProtocolAdapter, type SendMessageOptions } from "./base-adapter";
|
||||
import {
|
||||
ChatProtocolAdapter,
|
||||
type SendMessageOptions,
|
||||
type ZapConfig,
|
||||
} from "./base-adapter";
|
||||
import type {
|
||||
Conversation,
|
||||
Message,
|
||||
@@ -530,6 +534,30 @@ export class Nip10Adapter extends ChatProtocolAdapter {
|
||||
await publishEventToRelays(event, relays);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get zap configuration for a message in a NIP-10 thread
|
||||
* Returns configuration for how zap requests should be constructed
|
||||
*/
|
||||
getZapConfig(message: Message, conversation: Conversation): ZapConfig {
|
||||
// Get relays from conversation metadata
|
||||
const relays = conversation.metadata?.relays || [];
|
||||
|
||||
// Build eventPointer for the message being zapped
|
||||
const eventPointer = {
|
||||
id: message.id,
|
||||
author: message.author,
|
||||
relays,
|
||||
};
|
||||
|
||||
// Recipient is the message author
|
||||
return {
|
||||
supported: true,
|
||||
recipientPubkey: message.author,
|
||||
eventPointer,
|
||||
relays,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a replied-to message by ID
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user