Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3705674
D13396.id44354.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D13396.id44354.diff
View Options
diff --git a/keyserver/src/fetchers/community-fetchers.js b/keyserver/src/fetchers/community-fetchers.js
--- a/keyserver/src/fetchers/community-fetchers.js
+++ b/keyserver/src/fetchers/community-fetchers.js
@@ -1,6 +1,9 @@
// @flow
-import type { ServerCommunityInfo } from 'lib/types/community-types.js';
+import type {
+ ServerCommunityInfo,
+ ServerCommunityInfoWithCommunityName,
+} from 'lib/types/community-types.js';
import { dbQuery, SQL } from '../database/database.js';
import { Viewer } from '../session/viewer.js';
@@ -65,4 +68,28 @@
return communityInfo?.farcasterChannelID;
}
-export { fetchCommunityInfos, fetchCommunityFarcasterChannelTag };
+async function fetchAllCommunityInfosWithNames(): Promise<
+ $ReadOnlyArray<ServerCommunityInfoWithCommunityName>,
+> {
+ const query = SQL`
+ SELECT c.id, t.name as communityName, c.farcaster_channel_id as farcasterChannelID
+ FROM communities c
+ INNER JOIN threads t ON c.id = t.id
+ `;
+
+ const [result] = await dbQuery(query);
+
+ const communityInfos = result.map(row => ({
+ id: row.id.toString(),
+ farcasterChannelID: row.farcasterChannelID,
+ communityName: row.communityName,
+ }));
+
+ return communityInfos;
+}
+
+export {
+ fetchCommunityInfos,
+ fetchCommunityFarcasterChannelTag,
+ fetchAllCommunityInfosWithNames,
+};
diff --git a/lib/types/community-types.js b/lib/types/community-types.js
--- a/lib/types/community-types.js
+++ b/lib/types/community-types.js
@@ -30,6 +30,11 @@
farcasterChannelID: t.maybe(t.String),
});
+export type ServerCommunityInfoWithCommunityName = $ReadOnly<{
+ ...ServerCommunityInfo,
+ +communityName: string,
+}>;
+
export type FetchCommunityInfosResponse = {
+communityInfos: $ReadOnlyArray<ServerCommunityInfo>,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 8, 11:36 PM (4 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2824165
Default Alt Text
D13396.id44354.diff (1 KB)
Attached To
Mode
D13396: [keyserver] new fetcher to get all communities
Attached
Detach File
Event Timeline
Log In to Comment