Page MenuHomePhabricator

D13815.id45451.diff
No OneTemporary

D13815.id45451.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 as fetchViewerHasPositiveRole,
checkThread,
validateCandidateMembers,
} from '../fetchers/thread-permission-fetchers.js';
@@ -858,7 +858,7 @@
const [isMember, hasPermission, communityFarcasterChannelTag] =
await Promise.all([
- fetchViewerIsMember(viewer, request.threadID),
+ fetchViewerHasPositiveRole(viewer, request.threadID),
permissionPromise,
communityFarcasterChannelTagPromise,
]);

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 31, 2:27 PM (21 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2393149
Default Alt Text
D13815.id45451.diff (1 KB)

Event Timeline