Page MenuHomePhabricator

D13396.diff
No OneTemporary

D13396.diff

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

Mime Type
text/plain
Expires
Sat, Sep 21, 10:06 AM (7 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2160965
Default Alt Text
D13396.diff (1 KB)

Event Timeline