Repository navigation
feat: add role preview to permission calculation - #202
Open
GalaxyAkiii wants to merge 1 commit into
Open
GalaxyAkiii wants to merge 1 commit into
GalaxyAkiii wants to merge 1 commit into
Conversation
Signed-off-by: Aki <aki@akiworks.xyz>
10 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds role preview capabilities to
stoat.js, allowing client applications to calculate permissions, channel visibility, and mention counts from the perspective of specific server roles without altering actual authenticated session state.Changes
Client:viewAssignal andsetViewAs(server?: string, roles?: string[])to set or clear the active preview.#guardAPI) that blocks non-GET mutation requests targeted at the previewed server (including/servers/,/channels/,/custom/emoji/,/webhooks/, andDELETE /invites/), rejecting with{ type: "ViewingAsRole" }. Requests whose server cannot be resolved (such as invite deletions, or uncached emojis/webhooks) are also blocked while previewing. Read receipts (/ack) and/searchremain permitted. The guard is re-applied in#updateHeaders()to persist across session updates.Server:previewRolesgetter returning the active preview roles in priority order.defaultChannel,unread, andmentionsfilter out channels that the previewed roles cannot view.defaultChannelflattens ordered categories to check preview visibility, preserving existing behaviour when not previewing.ServerMember:realRanking(original hierarchy ranking).rankingreturns the previewed role rank for the authenticated member during an active preview.calculatePermission:How was this PR tested?
{ type: "ViewingAsRole" }, permits acks, and allows normal writes again once the preview is stopped (setViewAs()).for-webPR (src/interface/navigation/channels/viewAs.test.ts).tsc --noEmit) passes cleanly.Checklist:
Please declare, if any, LLM usage involved in creating this PR
None