-
Notifications
You must be signed in to change notification settings - Fork 12
Create bot registration endpoint #3881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: create-bot-runner-package
Are you sure you want to change the base?
Conversation
💡 Codex Reviewboxel/packages/bot-runner/main.ts Lines 67 to 70 in 7d0f6ff
The timeline handler only skips ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Preview deployments |
Host Test Results 1 files ± 0 1 suites ±0 1h 25m 14s ⏱️ - 14m 59s For more details on these errors, see this check. Results for commit 47ed4ae. ± Comparison against base commit 2ad413f. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR creates a bot registration endpoint system that allows users to register Matrix bot runners with the realm server. The system tracks which users have registered bots and provides endpoints to create, list, and delete bot registrations.
Changes:
- Added POST
/_bot-registrationendpoint for bot registration - Added GET
/_bot-registrationsendpoint to list all bot registrations - Added DELETE
/_bot-registrationendpoint for unregistering bots - Created database migration for
bot_registrationstable - Added comprehensive test coverage with 8 test cases
- Included shell script for easy bot registration
- Added documentation for the generic bot runner system
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
packages/realm-server/handlers/handle-bot-registration.ts |
Implements three handler functions for bot registration, listing, and unregistration with JWT authentication |
packages/realm-server/routes.ts |
Registers three new routes with JWT middleware for bot registration operations |
packages/realm-server/tests/server-endpoints/bot-registration-test.ts |
Comprehensive test suite covering authentication, registration, updates, authorization, and listing scenarios |
packages/realm-server/tests/index.ts |
Imports the new test file into the test suite |
packages/postgres/migrations/1769200000000_create-bot-registrations.js |
Creates bot_registrations table with id, user_id, and created_at columns plus unique constraint |
packages/realm-server/scripts/register-bot.sh |
Shell script for registering bots via curl with configurable environment variables |
docs/generic-bot-runner.md |
Documentation covering bot registration process, endpoints, and bot runner configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/realm-server/tests/server-endpoints/bot-registration-test.ts
Outdated
Show resolved
Hide resolved
a16203f to
66e8375
Compare
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 66e83752aa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@tintinthong I've opened a new pull request, #3888, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/realm-server/tests/server-endpoints/bot-registration-test.ts
Outdated
Show resolved
Hide resolved
| exports.up = (pgm) => { | ||
| pgm.createTable('bot_registrations', { | ||
| id: { type: 'uuid', primaryKey: true, notNull: true }, | ||
| user_id: { type: 'uuid', notNull: true }, | ||
| name: { type: 'text' }, | ||
| created_at: { type: 'timestamp', notNull: true }, | ||
| }); | ||
| pgm.addConstraint('bot_registrations', 'bot_registrations_user_name_unique', { | ||
| unique: ['user_id', 'name'], | ||
| }); | ||
| pgm.addConstraint('bot_registrations', 'bot_registrations_user_id_fkey', { | ||
| foreignKeys: { | ||
| columns: 'user_id', | ||
| references: 'users(id)', | ||
| onDelete: 'CASCADE', | ||
| }, | ||
| }); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the schema. Im not sure if we want matrix_user_id here but given the users table already has it maybe I don't need redundancy? Or we can just keep this table be simple and only have matrix_user_id without the user_id?
Also, I added name that shud be unique per user so ppl can name their bots registrations -- this is optional
2ad413f to
2654e2a
Compare
47ed4ae to
972e90d
Compare
Bot registration endpoint
Short summary of the bot registration updates in this PR, focused on the three endpoints:
Endpoints
POST /_bot-registrationmatrixUserIdmust match the authenticated user.201with the created registrationGET /_bot-registrationsDELETE /_bot-registration204on success.