mirror of
https://github.com/dergigi/boris.git
synced 2025-12-30 13:04:57 +01:00
fix: filter out blog posts with far-future publication dates
- Add filteredBlogPosts useMemo to exclude posts with unreasonable dates - Allow 1 day into future for clock skew tolerance - Prevents spam/error posts with dates like '53585 years from now' - Uses published_at tag or event.created_at as fallback
This commit is contained in:
@@ -243,16 +243,25 @@ const Explore: React.FC<ExploreProps> = ({ relayPool, activeTab: propActiveTab }
|
||||
return classifyHighlights(highlights, activeAccount?.pubkey, followedPubkeys)
|
||||
}, [highlights, activeAccount?.pubkey, followedPubkeys])
|
||||
|
||||
// Filter out blog posts with unreasonable future dates (allow 1 day for clock skew)
|
||||
const filteredBlogPosts = useMemo(() => {
|
||||
const maxFutureTime = Date.now() / 1000 + (24 * 60 * 60) // 1 day from now
|
||||
return blogPosts.filter(post => {
|
||||
const publishedTime = post.published || post.event.created_at
|
||||
return publishedTime <= maxFutureTime
|
||||
})
|
||||
}, [blogPosts])
|
||||
|
||||
const renderTabContent = () => {
|
||||
switch (activeTab) {
|
||||
case 'writings':
|
||||
return blogPosts.length === 0 ? (
|
||||
return filteredBlogPosts.length === 0 ? (
|
||||
<div className="explore-empty" style={{ gridColumn: '1/-1', textAlign: 'center', color: 'var(--text-secondary)' }}>
|
||||
<p>No blog posts found yet.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="explore-grid">
|
||||
{blogPosts.map((post) => (
|
||||
{filteredBlogPosts.map((post) => (
|
||||
<BlogPostCard
|
||||
key={`${post.author}:${post.event.tags.find(t => t[0] === 'd')?.[1]}`}
|
||||
post={post}
|
||||
|
||||
Reference in New Issue
Block a user