Add rideshare content filter and enhance FeedService filtering logic

- Introduced a new rideshare content filter in content-filters.ts, allowing for the categorization of rideshare requests and offers.
- Updated the FeedService to support filtering by tags and keywords, enhancing the ability to search and filter content based on user-defined criteria.
- Modified Home.vue to include the new rideshare filter preset, improving user access to rideshare-related content.

These changes enhance the content filtering capabilities and user experience within the NostrFeed module.
This commit is contained in:
padreug 2025-09-17 02:06:57 +02:00
parent 005b78bf0e
commit 667a7c2d89
3 changed files with 49 additions and 3 deletions

View file

@ -99,6 +99,16 @@ export const CONTENT_FILTERS: Record<string, ContentFilter> = {
label: 'Live Events',
kinds: [30311], // NIP-53: Live Events
description: 'Live streaming and real-time events'
},
// Rideshare content
rideshare: {
id: 'rideshare',
label: 'Rideshare',
kinds: [1, 31001], // Text notes + custom rideshare events
description: 'Rideshare requests, offers, and coordination',
tags: ['rideshare', 'uber', 'lyft', 'carpool', 'taxi', 'ride'], // NIP-12 tags
keywords: ['rideshare', 'ride share', 'carpool', 'uber', 'lyft', 'taxi', 'pickup', 'dropoff']
}
}
@ -148,6 +158,10 @@ export const FILTER_PRESETS: Record<string, ContentFilter[]> = {
content: [
CONTENT_FILTERS.longFormContent,
CONTENT_FILTERS.textNotes
],
rideshare: [
CONTENT_FILTERS.rideshare
]
}

View file

@ -23,6 +23,8 @@ export interface ContentFilter {
description: string
requiresAuth?: boolean
filterByAuthor?: 'admin' | 'exclude-admin' | 'none'
tags?: string[] // NIP-12 tags to filter by
keywords?: string[] // Content keywords to search for
}
export interface FeedConfig {
@ -147,6 +149,11 @@ export class FeedService extends BaseService {
// Will exclude admin in post-processing
}
// Apply tag filtering if specified (NIP-12)
if (contentFilter.tags && contentFilter.tags.length > 0) {
filter['#t'] = contentFilter.tags
}
filters.push(filter)
}
} else {
@ -294,10 +301,34 @@ export class FeedService extends BaseService {
// Apply author filtering
if (filter.filterByAuthor === 'admin') {
console.log('FeedService: Admin filter, isAdminPost:', isAdminPost)
return isAdminPost
if (!isAdminPost) return false
} else if (filter.filterByAuthor === 'exclude-admin') {
console.log('FeedService: Exclude admin filter, isAdminPost:', isAdminPost)
return !isAdminPost
if (isAdminPost) return false
}
// Apply keyword filtering if specified
if (filter.keywords && filter.keywords.length > 0) {
const content = event.content.toLowerCase()
const hasMatchingKeyword = filter.keywords.some(keyword =>
content.includes(keyword.toLowerCase())
)
if (!hasMatchingKeyword) {
console.log('FeedService: No matching keywords found')
return false
}
}
// Apply tag filtering if specified (check if event has any matching tags)
if (filter.tags && filter.tags.length > 0) {
const eventTags = event.tags?.filter(tag => tag[0] === 't').map(tag => tag[1]) || []
const hasMatchingTag = filter.tags.some(filterTag =>
eventTags.includes(filterTag)
)
if (!hasMatchingTag) {
console.log('FeedService: No matching tags found')
return false
}
}
console.log('FeedService: Filter passed all checks')

View file

@ -126,7 +126,8 @@ const quickFilterPresets = {
all: { label: 'All', filters: FILTER_PRESETS.all },
announcements: { label: 'News', filters: FILTER_PRESETS.announcements },
social: { label: 'Social', filters: FILTER_PRESETS.social },
events: { label: 'Events', filters: FILTER_PRESETS.events }
events: { label: 'Events', filters: FILTER_PRESETS.events },
rideshare: { label: 'Rideshare', filters: FILTER_PRESETS.rideshare }
}
// Computed properties