Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3284280
D11955.id40040.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
D11955.id40040.diff
View Options
diff --git a/keyserver/src/fetchers/community-fetchers.js b/keyserver/src/fetchers/community-fetchers.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/fetchers/community-fetchers.js
@@ -0,0 +1,41 @@
+// @flow
+
+import type { CommunityInfo } from 'lib/types/community-types.js';
+
+import { dbQuery, SQL } from '../database/database.js';
+import { Viewer } from '../session/viewer.js';
+
+type ServerCommunityInfoWithHolder = $ReadOnly<{
+ ...CommunityInfo,
+ +id: string,
+ +blobHolder: ?string,
+}>;
+
+async function fetchCommunityInfos(
+ viewer: Viewer,
+): Promise<$ReadOnlyArray<ServerCommunityInfoWithHolder>> {
+ if (!viewer) {
+ return [];
+ }
+
+ const query = SQL`
+ SELECT c.id, c.farcaster_channel_id as farcasterChannelID,
+ c.blob_holder as blobHolder
+ FROM communities c
+ INNER JOIN memberships m
+ ON c.id = m.thread AND m.user = ${viewer.userID}
+ WHERE m.role > 0
+ `;
+
+ const [result] = await dbQuery(query);
+
+ const communityInfos = result.map(row => ({
+ id: row.id.toString(),
+ farcasterChannelID: row.farcasterChannelID,
+ blobHolder: row.blobHolder,
+ }));
+
+ return communityInfos;
+}
+
+export { fetchCommunityInfos };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 12:03 PM (21 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2524032
Default Alt Text
D11955.id40040.diff (1 KB)
Attached To
Mode
D11955: [keyserver] introduce fetchCommunityInfos
Attached
Detach File
Event Timeline
Log In to Comment