Skip to content

Added Masqurade feature and the coresponding permision - #42

Open
Spyro24 wants to merge 4 commits into
Nerimity:mainfrom
Spyro24:main
Open

Added Masqurade feature and the coresponding permision#42
Spyro24 wants to merge 4 commits into
Nerimity:mainfrom
Spyro24:main

Conversation

@Spyro24

@Spyro24 Spyro24 commented Jul 7, 2026

Copy link
Copy Markdown

Pull Request Template

What does this PR do?

  • This little PR adds support for the Masquerade feature to the backend

Changes Made

  • src/common/Bitwise.ts, Added the role permision (its bit 9)
  • src/routes/channels/channelMessageCreate.ts, added the check if the user has the permision and added the coresponding things to the interfaces
  • src/services/Message/Message.ts, added the creator override content to make sure that the frontend gets the masquerade data

Checklist

  • Code is clear, concise & easy to understand
  • Code has been tested and works as intended
  • Documentation or README has been updated if relevant
  • Security and error handling considerations have been addressed
  • Has the change been previously discussed with backend maintainer(s)

Testing

  • I spined up a local instance of Nerimity with the imgproxy, client (that from the PR in Additional Notes), proxy, cdn and server
  • I used Bruno to test if the endpoints corectly reponds if a avatar_url_override or username_override exists in the request body of the route
  • I checked with the client if the messages are corectly displayed and if nothing is broken (i hope that i dont broke stuff)

Additional Notes

Summary by CodeRabbit

  • New Features
    • Added a new Masquerade permission that enables per-message identity overrides for permitted users (custom name and avatar).
    • Messages can now accept optional username and avatar overrides (with validation) during message creation.
  • Bug Fixes
    • Improved message identity handling so webhook-created messages use webhook identity data without applying masquerade overrides.
  • Chores
    • Added safeguards to require the Masquerade permission for impersonation overrides and to block masquerading in direct messages.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new MASQUERADE role permission bit with display metadata. The message creation route accepts optional avatar_url_override/username_override fields, validates them, enforces MASQUERADE permission and DM channel restrictions, and forwards overrides to message creation. Message transformation now handles creator override data differently for webhook and non-webhook messages.

Changes

Masquerade Permission and Message Override Flow

Layer / File(s) Summary
MASQUERADE permission definition
src/common/Bitwise.ts
Adds a new MASQUERADE entry to ROLE_PERMISSIONS with name, description, icon, and bit flag 1 << 9.
Message creation route validation and enforcement
src/routes/channels/channelMessageCreate.ts
Validates optional avatar_url_override and username_override fields, extends Body with those properties, enforces MASQUERADE permission and disallows masquerading in DM_TEXT channels, and passes overrides into createMessage.
Message transform applies creator override
src/services/Message/Message.ts
transformMessage keeps webhook createdBy limited to webhook-derived fields plus creatorOverrideId, and overlays creator override username and avatar data on non-webhook messages.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: adding the Masquerade feature and its permission.
Description check ✅ Passed The description matches the required template and includes purpose, changes, testing, checklist, and notes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/routes/channels/channelMessageCreate.ts`:
- Around line 41-42: The validators in channelMessageCreate are attached to the
wrong request fields, so the masquerade inputs bypass validation. Update the
body() checks in the validation chain to target the actual override keys used by
this route, specifically the avatar and username override fields read by
channelMessageCreate, so the existing string/length/character rules apply to the
correct inputs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 801864d9-b122-4818-8627-bd83000315b7

📥 Commits

Reviewing files that changed from the base of the PR and between 4fa513b and dd0e6cc.

📒 Files selected for processing (3)
  • src/common/Bitwise.ts
  • src/routes/channels/channelMessageCreate.ts
  • src/services/Message/Message.ts

Comment thread src/routes/channels/channelMessageCreate.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant