The 1st decentralized social network for sharing when you're on the toilet. Post a "flush" today! Powered by the AT Protocol.

fix

+49 -88
+49 -88
app/src/app/profile/[handle]/page.tsx
··· 4 4 import Link from 'next/link'; 5 5 import { useParams } from 'next/navigation'; 6 6 import styles from './profile.module.css'; 7 - import { sanitizeText } from '@/lib/content-filter'; 7 + import { sanitizeText, containsBannedWords } from '@/lib/content-filter'; 8 8 import { formatRelativeTime } from '@/lib/time-utils'; 9 + 10 + // Define approved emojis list - keep in sync with API route 11 + const APPROVED_EMOJIS = [ 12 + '๐Ÿšฝ', '๐Ÿงป', '๐Ÿ’ฉ', '๐Ÿ’จ', '๐Ÿšพ', '๐Ÿงผ', '๐Ÿช ', '๐Ÿšป', '๐Ÿฉธ', '๐Ÿ’ง', '๐Ÿ’ฆ', '๐Ÿ˜Œ', 13 + '๐Ÿ˜ฃ', '๐Ÿคข', '๐Ÿคฎ', '๐Ÿฅด', '๐Ÿ˜ฎโ€๐Ÿ’จ', '๐Ÿ˜ณ', '๐Ÿ˜ต', '๐ŸŒพ', '๐Ÿฆ', '๐Ÿ“ฑ', '๐Ÿ“–', '๐Ÿ’ญ', 14 + '1๏ธโƒฃ', '2๏ธโƒฃ', '๐ŸŸก', '๐ŸŸค' 15 + ]; 9 16 10 17 // Types for feed entries 11 18 interface FlushingEntry { ··· 144 151 }); 145 152 146 153 if (!recordsResponse.ok) { 147 - // If first attempt fails, try alternative URL pattern 148 - const altUrl = `${serviceEndpoint}/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=im.flushing.right.now&limit=100`; 149 - console.log(`First attempt failed, trying alternative URL: ${altUrl}`); 150 - 151 - const altResponse = await fetch(altUrl, { 152 - headers: { 153 - 'Accept': 'application/json' 154 - } 155 - }); 156 - 157 - if (!altResponse.ok) { 158 - throw new Error(`Failed to fetch records: ${altResponse.statusText}`); 159 - } 160 - 161 - const recordsData = await altResponse.json(); 162 - console.log('Successfully fetched records with alternative URL'); 163 - 164 - // Process the records 165 - const userEntries = recordsData.records 166 - .map((record: any) => { 167 - const text = record.value.text || ''; 168 - if (containsBannedWords(text)) return null; 169 - 170 - return { 171 - id: record.uri, 172 - uri: record.uri, 173 - cid: record.cid, 174 - did: did, 175 - text: sanitizeText(text), 176 - emoji: record.value.emoji || '๐Ÿšฝ', 177 - created_at: record.value.createdAt 178 - }; 179 - }) 180 - .filter((entry: any): entry is FlushingEntry => entry !== null); 181 - 182 - setEntries(userEntries); 183 - setTotalCount(userEntries.length); 184 - 185 - // Calculate emoji stats 186 - const emojiCounts = new Map<string, number>(); 187 - userEntries.forEach((entry: FlushingEntry) => { 188 - const emoji = entry.emoji?.trim() || '๐Ÿšฝ'; 189 - emojiCounts.set(emoji, (emojiCounts.get(emoji) || 0) + 1); 190 - }); 191 - 192 - const emojiStats = Array.from(emojiCounts.entries()) 193 - .map(([emoji, count]): EmojiStat => ({ emoji, count })) 194 - .sort((a, b) => b.count - a.count); 195 - 196 - setEmojiStats(emojiStats); 197 - } else { 198 - const recordsData = await recordsResponse.json(); 199 - console.log('Successfully fetched records'); 200 - 201 - // Process the records 202 - const userEntries = recordsData.records 203 - .map((record: any) => { 204 - const text = record.value.text || ''; 205 - if (containsBannedWords(text)) return null; 206 - 207 - return { 208 - id: record.uri, 209 - uri: record.uri, 210 - cid: record.cid, 211 - did: did, 212 - text: sanitizeText(text), 213 - emoji: record.value.emoji || '๐Ÿšฝ', 214 - created_at: record.value.createdAt 215 - }; 216 - }) 217 - .filter((entry: any): entry is FlushingEntry => entry !== null); 218 - 219 - setEntries(userEntries); 220 - setTotalCount(userEntries.length); 221 - 222 - // Calculate emoji stats 223 - const emojiCounts = new Map<string, number>(); 224 - userEntries.forEach((entry: FlushingEntry) => { 225 - const emoji = entry.emoji?.trim() || '๐Ÿšฝ'; 226 - emojiCounts.set(emoji, (emojiCounts.get(emoji) || 0) + 1); 227 - }); 228 - 229 - const emojiStats = Array.from(emojiCounts.entries()) 230 - .map(([emoji, count]): EmojiStat => ({ emoji, count })) 231 - .sort((a, b) => b.count - a.count); 232 - 233 - setEmojiStats(emojiStats); 154 + throw new Error(`Failed to fetch records: ${recordsResponse.statusText}`); 234 155 } 156 + 157 + const recordsData = await recordsResponse.json(); 158 + console.log('Records data:', recordsData); 159 + 160 + // Transform the records into our format 161 + const userEntries = recordsData.records 162 + .map((record: any) => { 163 + const text = record.value.text || ''; 164 + if (containsBannedWords(text)) return null; 165 + 166 + return { 167 + id: record.uri, 168 + uri: record.uri, 169 + cid: record.cid, 170 + did: did, 171 + text: sanitizeText(text), 172 + emoji: record.value.emoji || '๐Ÿšฝ', 173 + created_at: record.value.createdAt 174 + }; 175 + }) 176 + .filter((entry: FlushingEntry | null): entry is FlushingEntry => entry !== null); 177 + 178 + // Calculate emoji statistics 179 + const emojiCounts = new Map<string, number>(); 180 + userEntries.forEach((entry: FlushingEntry) => { 181 + const emoji = entry.emoji?.trim() || '๐Ÿšฝ'; 182 + if (APPROVED_EMOJIS.includes(emoji)) { 183 + emojiCounts.set(emoji, (emojiCounts.get(emoji) || 0) + 1); 184 + } else { 185 + emojiCounts.set('๐Ÿšฝ', (emojiCounts.get('๐Ÿšฝ') || 0) + 1); 186 + } 187 + }); 188 + 189 + const emojiStats = Array.from(emojiCounts.entries()) 190 + .map(([emoji, count]): EmojiStat => ({ emoji, count })) 191 + .sort((a, b) => b.count - a.count); 192 + 193 + setEntries(userEntries); 194 + setTotalCount(userEntries.length); 195 + setEmojiStats(emojiStats); 235 196 236 197 // Calculate statistics and chart data 237 198 if (userEntries.length > 0) {