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