Page MenuHomePhabricator

D13815.diff
No OneTemporary

D13815.diff

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,21 @@
return checkThread(viewer, threadID, [{ check: 'is_member' }]);
}
+async function viewerHasPositiveRole(
+ viewer: Viewer,
+ threadID: string,
+): Promise<boolean> {
+ const query = SQL`
+ SELECT role
+ FROM memberships
+ WHERE thread = ${threadID} AND user = ${viewer.userID}
+ `;
+
+ const [queryResult] = await dbQuery(query);
+ const positiveRoles = queryResult.filter(row => Number(row.role) > 0);
+ return positiveRoles.length > 0;
+}
+
type Check =
| { +check: 'is_member' }
| { +check: 'permission', +permission: ThreadPermission };
@@ -438,4 +453,5 @@
checkThread,
checkIfThreadIsBlocked,
validateCandidateMembers,
+ viewerHasPositiveRole,
};
diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js
--- a/keyserver/src/updaters/thread-updaters.js
+++ b/keyserver/src/updaters/thread-updaters.js
@@ -58,7 +58,7 @@
} from '../fetchers/thread-fetchers.js';
import {
checkThreadPermission,
- viewerIsMember as fetchViewerIsMember,
+ viewerHasPositiveRole,
checkThread,
validateCandidateMembers,
} from '../fetchers/thread-permission-fetchers.js';
@@ -858,7 +858,7 @@
const [isMember, hasPermission, communityFarcasterChannelTag] =
await Promise.all([
- fetchViewerIsMember(viewer, request.threadID),
+ viewerHasPositiveRole(viewer, request.threadID),
permissionPromise,
communityFarcasterChannelTagPromise,
]);

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 4:34 AM (19 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2559943
Default Alt Text
D13815.diff (1 KB)

Event Timeline