Skip to content

Conversation

@tintinthong
Copy link
Contributor

@tintinthong tintinthong commented Jan 21, 2026

Bot registration endpoint

Short summary of the bot registration updates in this PR, focused on the three endpoints:

Endpoints

POST /_bot-registration

  • Registers a bot for the authenticated user.
  • Once registered, the bot filters out events in rooms it is invited to.
  • Requires a realm server JWT.
  • matrixUserId must match the authenticated user.
  • Returns 201 with the created registration

GET /_bot-registrations

  • Lists bot registrations for the authenticated user only. Only gets his/her own bot registrations
  • Requires a realm server JWT.

DELETE /_bot-registration

  • Unregisters a bot by id for the authenticated user.
  • Requires a realm server JWT.
  • Returns 204 on success.

@tintinthong tintinthong changed the base branch from main to create-bot-runner-package January 21, 2026 15:02
@chatgpt-codex-connector
Copy link

💡 Codex Review

client.on(RoomEvent.Timeline, async (event, room, toStartOfTimeline) => {
if (!room || toStartOfTimeline) {
return;
}

P2 Badge Filter pre-start timeline events to avoid replay

The timeline handler only skips toStartOfTimeline, so historical events delivered during initial sync or after reconnect can still be processed even if they happened before this bot runner started. Matrix-js-sdk can append old events at the end of the timeline during initial sync, which means those events will pass the current guard and trigger logging/queue work. Without an origin_server_ts (or registration createdAt) check, a restart will reprocess old room history and can enqueue duplicate jobs once publishing is implemented.

ℹ️ 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".

@github-actions
Copy link

Preview deployments

@github-actions
Copy link

github-actions bot commented Jan 21, 2026

Host Test Results

    1 files  ±  0      1 suites  ±0   1h 25m 14s ⏱️ - 14m 59s
1 735 tests  - 155  1 712 ✅  - 161  15 💤  - 2  0 ❌ ±0  8 🔥 +8 
1 748 runs   - 157  1 717 ✅  - 171  15 💤  - 2  8 ❌ +8  8 🔥 +8 

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.

Copy link
Contributor

Copilot AI left a 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-registration endpoint for bot registration
  • Added GET /_bot-registrations endpoint to list all bot registrations
  • Added DELETE /_bot-registration endpoint for unregistering bots
  • Created database migration for bot_registrations table
  • 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.

@tintinthong tintinthong force-pushed the create-bot-registration branch from a16203f to 66e8375 Compare January 22, 2026 12:29
@tintinthong tintinthong requested a review from Copilot January 22, 2026 12:33
@tintinthong
Copy link
Contributor Author

@codex review

Copy link
Contributor

Copilot AI left a 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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Copy link
Contributor

Copilot AI commented Jan 22, 2026

@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.

Copy link
Contributor

Copilot AI left a 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.

Comment on lines +1 to +18
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',
},
});
};
Copy link
Contributor Author

@tintinthong tintinthong Jan 22, 2026

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

@lukemelia

@tintinthong tintinthong force-pushed the create-bot-runner-package branch from 2ad413f to 2654e2a Compare January 22, 2026 14:52
@tintinthong tintinthong force-pushed the create-bot-registration branch from 47ed4ae to 972e90d Compare January 22, 2026 14:54
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.

2 participants