From 36077f2e0a399cedf59f5ed45a8db24d66760224 Mon Sep 17 00:00:00 2001
From: Bangwu <119404476+markbang@users.noreply.github.com>
Date: Tue, 30 Apr 2024 21:51:43 +0800
Subject: [PATCH] fix(route): fix crossbell character and the following output
(#15417)
* fix: following.ts
* fix: character.ts
* Update following.ts
* style: auto format
* for source and index route
* style: auto format
* remove change
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
---
lib/routes/crossbell/feeds/following.ts | 38 +++++++++++++------------
lib/routes/crossbell/notes/utils.ts | 32 ++++++++++-----------
2 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/lib/routes/crossbell/feeds/following.ts b/lib/routes/crossbell/feeds/following.ts
index b70284d14..b58028df9 100644
--- a/lib/routes/crossbell/feeds/following.ts
+++ b/lib/routes/crossbell/feeds/following.ts
@@ -25,24 +25,26 @@ async function handler(ctx) {
return {
title: 'Crossbell Feeds of ' + characterId,
link: 'https://crossbell.io/',
- item: response.data?.list?.map((item) => {
- let link = item.note ? item.note.metadata?.content?.external_urls?.[0] || `https://crossbell.io/notes/${item.note.characterId}-${item.note.noteId}` : 'https://xchar.app/' + item.character.handle;
- if (link.startsWith('https://xn--')) {
- link = `https://crossbell.io/notes/${item.note?.characterId}-${item.note?.noteId}`;
- }
+ item: response.data?.list
+ ?.filter((item) => item.type !== 'UPDATE_CHARACTER_METADATA')
+ .map((item) => {
+ let link = item.note ? item.note.metadata?.content?.external_urls?.[0] || `https://crossbell.io/notes/${item.note.characterId}-${item.note.noteId}` : 'https://xchar.app/' + item.character.handle;
+ if (link.startsWith('https://xn--')) {
+ link = `https://crossbell.io/notes/${item.note?.characterId}-${item.note?.noteId}`;
+ }
- return {
- title: `${item.type} ${item.character && item.character.metadata?.content?.name}@${item.character && item.character.handle}`,
- description: `${item.type} ${item.note && `
Note: ${item.note.metadata?.content?.title || item.note.metadata?.content?.content}`}${
- item.character && `
Character: ${item.character.metadata?.content?.name}@${item.character.handle}`
- }`,
- link,
- pubDate: item.createdAt,
- updated: item.updatedAt,
- author: item.note?.metadata?.content?.authors?.[0] || item.note?.character?.metadata?.content?.name || item.note?.character?.handle || item.owner,
- guid: item.transactionHash + item.logIndex + item.type,
- category: [...(item.note?.metadata?.content?.sources || []), ...(item.note?.metadata?.content?.tags || [])],
- };
- }),
+ return {
+ title: `${item.type} ${item.character && item.character.metadata?.content?.name}@${item.character && item.character.handle}`,
+ description: `${item.type} ${item.note && `
Note: ${item.note.metadata?.content?.title || item.note.metadata?.content?.content}`}${
+ item.character && `
Character: ${item.character.metadata?.content?.name}@${item.character.handle}`
+ }`,
+ link,
+ pubDate: item.createdAt,
+ updated: item.updatedAt,
+ author: item.note?.metadata?.content?.authors?.[0] || item.note?.character?.metadata?.content?.name || item.note?.character?.handle || item.owner,
+ guid: item.transactionHash + item.logIndex + item.type,
+ category: [...(item.note?.metadata?.content?.sources || []), ...(item.note?.metadata?.content?.tags || [])],
+ };
+ }),
};
}
diff --git a/lib/routes/crossbell/notes/utils.ts b/lib/routes/crossbell/notes/utils.ts
index 4d5295d19..452b7831d 100644
--- a/lib/routes/crossbell/notes/utils.ts
+++ b/lib/routes/crossbell/notes/utils.ts
@@ -1,18 +1,16 @@
-export default {
- getItem: (note) => {
- let link = note.metadata?.content?.external_urls?.[0] ?? `https://crossbell.io/notes/${note.characterId}-${note.noteId}`;
- if (link.startsWith('https://xn--')) {
- link = `https://crossbell.io/notes/${note.characterId}-${note.noteId}`;
- }
- return {
- title: note.metadata?.content?.title || '',
- description: note.metadata?.content?.content,
- link,
- pubDate: note.metadata?.content?.publishedAt,
- updated: note.metadata?.content?.updatedAt,
- author: note.metadata?.content?.authors?.[0] || note.character?.metadata?.content?.name || note.character?.handle,
- guid: `https://crossbell.io/notes/${note.characterId}-${note.noteId}`,
- category: [...(note.metadata?.content?.sources || []), ...(note.metadata?.content?.tags || [])],
- };
- },
+export const getItem = (note) => {
+ let link = note.metadata?.content?.external_urls?.[0] ?? `https://crossbell.io/notes/${note.characterId}-${note.noteId}`;
+ if (link.startsWith('https://xn--')) {
+ link = `https://crossbell.io/notes/${note.characterId}-${note.noteId}`;
+ }
+ return {
+ title: note.metadata?.content?.title || '',
+ description: note.metadata?.content?.content,
+ link,
+ pubDate: note.metadata?.content?.publishedAt,
+ updated: note.metadata?.content?.updatedAt,
+ author: note.metadata?.content?.authors?.[0] || note.character?.metadata?.content?.name || note.character?.handle,
+ guid: `https://crossbell.io/notes/${note.characterId}-${note.noteId}`,
+ category: [...(note.metadata?.content?.sources || []), ...(note.metadata?.content?.tags || [])],
+ };
};