mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-12 08:27:27 +02:00
refactor: move eventPointer to ZapConfig for NIP-53 adapter
- Add eventPointer field to ZapConfig interface for message e-tag - NIP-53 adapter now returns eventPointer from getZapConfig - ChatMessageContextMenu uses eventPointer from zapConfig directly - Remove goal logic from NIP-53 zap config (simplify for now) This gives the adapter full control over zap configuration, including which event to reference in the e-tag.
This commit is contained in:
@@ -153,9 +153,7 @@ export function ChatMessageContextMenu({
|
||||
|
||||
addWindow("zap", {
|
||||
recipientPubkey: zapConfig.recipientPubkey,
|
||||
// Include the message event as context for zap preview (e-tag)
|
||||
eventPointer: { id: event.id, author: event.pubkey },
|
||||
// Include addressable event context if provided (a-tag, e.g., live activity)
|
||||
eventPointer: zapConfig.eventPointer,
|
||||
addressPointer: zapConfig.addressPointer,
|
||||
customTags: zapConfig.customTags,
|
||||
relays: zapConfig.relays,
|
||||
|
||||
@@ -28,6 +28,12 @@ export interface ZapConfig {
|
||||
unsupportedReason?: string;
|
||||
/** Recipient pubkey (who receives the sats) */
|
||||
recipientPubkey: string;
|
||||
/** Event being zapped for e-tag (e.g., chat message) */
|
||||
eventPointer?: {
|
||||
id: string;
|
||||
author?: string;
|
||||
relays?: string[];
|
||||
};
|
||||
/** Addressable event context for a-tag (e.g., live activity) */
|
||||
addressPointer?: {
|
||||
kind: number;
|
||||
|
||||
@@ -558,16 +558,15 @@ export class Nip53Adapter extends ChatProtocolAdapter {
|
||||
* Get zap configuration for a message in a live activity
|
||||
*
|
||||
* NIP-53 zap tagging rules:
|
||||
* - Always include: p-tag (message author), a-tag (live activity)
|
||||
* - If zapping the host AND stream has a goal: also e-tag the goal
|
||||
* - p-tag: message author (recipient)
|
||||
* - e-tag: message event being zapped
|
||||
* - a-tag: live activity context
|
||||
*/
|
||||
getZapConfig(message: Message, conversation: Conversation): ZapConfig {
|
||||
const activityAddress = conversation.metadata?.activityAddress;
|
||||
const liveActivity = conversation.metadata?.liveActivity as
|
||||
| {
|
||||
relays?: string[];
|
||||
hostPubkey?: string;
|
||||
goal?: string;
|
||||
}
|
||||
| undefined;
|
||||
|
||||
@@ -580,8 +579,6 @@ export class Nip53Adapter extends ChatProtocolAdapter {
|
||||
}
|
||||
|
||||
const { pubkey: activityPubkey, identifier } = activityAddress;
|
||||
const hostPubkey = liveActivity?.hostPubkey;
|
||||
const goal = liveActivity?.goal;
|
||||
|
||||
// Get relays
|
||||
const relays =
|
||||
@@ -591,6 +588,13 @@ export class Nip53Adapter extends ChatProtocolAdapter {
|
||||
? [conversation.metadata.relayUrl]
|
||||
: [];
|
||||
|
||||
// Build eventPointer for the message being zapped (e-tag)
|
||||
const eventPointer = {
|
||||
id: message.id,
|
||||
author: message.author,
|
||||
relays,
|
||||
};
|
||||
|
||||
// Build addressPointer for the live activity (a-tag)
|
||||
const addressPointer = {
|
||||
kind: 30311,
|
||||
@@ -599,18 +603,11 @@ export class Nip53Adapter extends ChatProtocolAdapter {
|
||||
relays,
|
||||
};
|
||||
|
||||
// Build custom tags for special cases only
|
||||
// If zapping the host AND stream has a goal, e-tag the goal
|
||||
const customTags: string[][] = [];
|
||||
if (message.author === hostPubkey && goal) {
|
||||
customTags.push(["e", goal, relays[0] || ""]);
|
||||
}
|
||||
|
||||
return {
|
||||
supported: true,
|
||||
recipientPubkey: message.author,
|
||||
eventPointer,
|
||||
addressPointer,
|
||||
customTags: customTags.length > 0 ? customTags : undefined,
|
||||
relays,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user