Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3527457
D14181.id46599.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D14181.id46599.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
@@ -6,6 +6,7 @@
} from 'lib/types/community-types.js';
import { fetchPrivilegedThreadInfos } from './thread-fetchers.js';
+import { viewerIsMemberOfThreads } from './thread-permission-fetchers.js';
import { dbQuery, SQL, mergeAndConditions } from '../database/database.js';
import { Viewer } from '../session/viewer.js';
@@ -93,13 +94,23 @@
const [result] = await dbQuery(query);
- const threadIDs = new Set(result.map(row => row.id.toString()));
+ const threadIDs = result.map(row => row.id.toString());
+
+ const membershipMap = await viewerIsMemberOfThreads(viewer, threadIDs);
+
+ const filteredResult = result.filter(
+ row => !!row.farcasterChannelID && !membershipMap.get(row.id.toString()),
+ );
+
+ const filteredThreadIDs = new Set(
+ filteredResult.map(row => row.id.toString()),
+ );
const threadInfosResult = await fetchPrivilegedThreadInfos(viewer, {
- threadIDs,
+ threadIDs: filteredThreadIDs,
});
- const communityInfos = result.map(
+ const communityInfos = filteredResult.map(
(row): ServerCommunityInfoWithCommunityName => ({
id: row.id.toString(),
farcasterChannelID: row.farcasterChannelID,
diff --git a/keyserver/src/fetchers/thread-permission-fetchers.js b/keyserver/src/fetchers/thread-permission-fetchers.js
--- a/keyserver/src/fetchers/thread-permission-fetchers.js
+++ b/keyserver/src/fetchers/thread-permission-fetchers.js
@@ -71,6 +71,19 @@
return checkThread(viewer, threadID, [{ check: 'is_member' }]);
}
+async function viewerIsMemberOfThreads(
+ viewer: Viewer,
+ threadIDs: $ReadOnlyArray<string>,
+): Promise<Map<string, boolean>> {
+ const validThreadIDs = await checkThreads(viewer, threadIDs, [
+ { check: 'is_member' },
+ ]);
+
+ return new Map(
+ threadIDs.map(threadID => [threadID, validThreadIDs.has(threadID)]),
+ );
+}
+
async function viewerHasPositiveRole(
viewer: Viewer,
threadID: string,
@@ -448,6 +461,7 @@
fetchThreadPermissionsBlob,
checkThreadPermission,
viewerIsMember,
+ viewerIsMemberOfThreads,
checkThreads,
getValidThreads,
checkThread,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 5:06 AM (5 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2701645
Default Alt Text
D14181.id46599.diff (2 KB)
Attached To
Mode
D14181: [keyserver] filter out communities that viewer is a member of or that aren't public
Attached
Detach File
Event Timeline
Log In to Comment