Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3333586
D13815.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
D13815.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D13815: [keyserver] check if viewer role is positive for updateThread
Attached
Detach File
Event Timeline
Log In to Comment