added k tag for social kind 1 quote posts of workout events

This commit is contained in:
DocNR 2025-03-12 11:42:14 -04:00
parent 704fa27950
commit 43d6d7d12b
3 changed files with 1178 additions and 13 deletions

View File

@ -1,4 +1,4 @@
# POWR Social Features Design Document # POWR Social Architecture
## Problem Statement ## Problem Statement
POWR needs to integrate social features that leverage the Nostr protocol while maintaining a local-first architecture. The system must provide a seamless way for users to share workout content, receive feedback, and engage with the fitness community without compromising the standalone functionality of the application. Additionally, the implementation must support future integration with value-exchange mechanisms through Nostr Wallet Connect. POWR needs to integrate social features that leverage the Nostr protocol while maintaining a local-first architecture. The system must provide a seamless way for users to share workout content, receive feedback, and engage with the fitness community without compromising the standalone functionality of the application. Additionally, the implementation must support future integration with value-exchange mechanisms through Nostr Wallet Connect.
@ -167,10 +167,12 @@ interface SocialShare extends NostrEvent {
tags: [ tags: [
// Quote reference to the exercise, template or workout // Quote reference to the exercise, template or workout
["q", string, string, string], // event-id, relay-url, pubkey ["q", string, string, string], // event-id, relay-url, pubkey
// Kind tag to indicate what kind of event is being quoted
["k", string], // The kind number of the quoted event (e.g., "1301")
// Mention author's pubkey // Mention author's pubkey
["p", string], // pubkey of the event creator ["p", string] // pubkey of the event creator
// App handler registration (NIP-89)
["client", string, string, string] // Name, 31990 reference, relay-url
] ]
} }
@ -385,10 +387,29 @@ const commentsQuery = {
"#K": ["1301"] // Root kind filter "#K": ["1301"] // Root kind filter
}; };
// Find social posts (kind 1) that reference our workout events // Find all social posts specifically referencing workout records
const socialReferencesQuery = { const workoutPostsQuery = {
kinds: [1], kinds: [1],
"#q": [workoutEventId] "#k": ["1301"]
};
// Find all social posts referencing any POWR content types
const allPowrContentQuery = {
kinds: [1],
"#k": ["1301", "33401", "33402"]
};
// Find all social posts referencing POWR content from a specific user
const userPowrContentQuery = {
kinds: [1],
"#k": ["1301", "33401", "33402"],
authors: [userPubkey]
};
// Find posts with POWR hashtag
const powrHashtagQuery = {
kinds: [1],
"#t": ["powrapp"]
}; };
// Get reactions to a workout record // Get reactions to a workout record

File diff suppressed because it is too large Load Diff

View File

@ -27,15 +27,47 @@ export class NostrWorkoutService {
* Creates a social share event that quotes the workout record * Creates a social share event that quotes the workout record
*/ */
static createSocialShareEvent(workoutEventId: string, message: string): NostrEvent { static createSocialShareEvent(workoutEventId: string, message: string): NostrEvent {
return this.createShareEvent(workoutEventId, '1301', message);
}
/**
* Creates a social share event that quotes a POWR event
* @param eventId The ID of the event being quoted
* @param kind The kind number of the event being quoted (1301, 33401, 33402)
* @param message The message content for the social post
* @param additionalTags Optional additional tags to include
*/
static createShareEvent(
eventId: string,
kind: '1301' | '33401' | '33402',
message: string,
additionalTags: string[][] = []
): NostrEvent {
// Determine appropriate hashtags based on kind
const contentTypeTags: string[][] = [];
if (kind === '1301') {
contentTypeTags.push(['t', 'workout']);
} else if (kind === '33401') {
contentTypeTags.push(['t', 'exercise']);
} else if (kind === '33402') {
contentTypeTags.push(['t', 'workouttemplate']);
}
return { return {
kind: 1, // Standard note kind: 1,
content: message, content: message,
tags: [ tags: [
// Quote the workout event // Quote the event
['q', workoutEventId], ['q', eventId],
// Add hash tags for discovery // Add kind tag
['t', 'workout'], ['k', kind],
['t', 'fitness'] // Add standard fitness tag
['t', 'fitness'],
// Add content-specific tags
...contentTypeTags,
// Add any additional tags
...additionalTags
], ],
created_at: Math.floor(Date.now() / 1000) created_at: Math.floor(Date.now() / 1000)
}; };