Page MenuHomePhabricator

D13832.diff
No OneTemporary

D13832.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
@@ -5,7 +5,7 @@
ServerCommunityInfoWithCommunityName,
} from 'lib/types/community-types.js';
-import { dbQuery, SQL } from '../database/database.js';
+import { dbQuery, SQL, mergeAndConditions } from '../database/database.js';
import { Viewer } from '../session/viewer.js';
type ServerCommunityInfoWithHolder = $ReadOnly<{
@@ -25,16 +25,28 @@
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
`;
+ if (!viewer.isScriptViewer) {
+ query.append(SQL`
+ INNER JOIN memberships m
+ ON c.id = m.thread AND m.user = ${viewer.userID}
+ `);
+ }
+ const conditions = [];
+ if (!viewer.isScriptViewer) {
+ conditions.push(SQL`m.role > 0`);
+ }
if (communityIDs && communityIDs.length > 0) {
- query.append(SQL`
- AND c.id IN (${communityIDs})
+ conditions.push(SQL`
+ c.id IN (${communityIDs})
`);
}
+ if (conditions.length > 0) {
+ const clause = mergeAndConditions(conditions);
+ query.append(SQL`WHERE `);
+ query.append(clause);
+ }
const [result] = await dbQuery(query);

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 31, 5:16 PM (20 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2393463
Default Alt Text
D13832.diff (1 KB)

Event Timeline