feat(talkbot): move TalkBot bookkeeping to dedicated ex_apps_talk_bots table#866
Conversation
📝 WalkthroughWalkthroughThis PR moves Talk bot registration data from legacy appconfig_ex to a new ex_apps_talk_bots table. It adds a TalkBot entity and TalkBotMapper, refactors TalkBotsService to use encrypted secrets via ICrypto and mapper CRUD, implements a migration that validates, decrypts when needed, re-encrypts, and removes legacy rows with per-bot transactions, and adds tests and Psalm stubs for Talk bot events. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@lib/Service/TalkBotsService.php`:
- Around line 122-124: The loop that calls unregisterExAppBot($exApp,
$bot->getRoute()) should isolate failures so one failing bot doesn't stop
cleanup; wrap the call inside the foreach in its own try/catch (catch
Throwable/Exception), log the error including the $bot->getRoute() and exception
message/trace, and continue to the next bot so remaining bots still get
unregistered.
In `@tests/php/Migration/Version034000Date20260428144801Test.php`:
- Around line 47-51: The test constructs Version034000Date20260428144801 with
three arguments but the migration's constructor only accepts two; update the
test setup in Version034000Date20260428144801Test so the new
Version034000Date20260428144801(...) call matches the migration constructor
signature (pass only the expected parameters, e.g., $this->db and $this->crypto)
or, if the migration was intentionally changed, adjust the migration constructor
to accept the third dependency (IURLGenerator) and update usages accordingly;
locate the creation in the test and ensure the parameter list aligns with the
class constructor for Version034000Date20260428144801.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 11e2eed2-dfdc-4424-ab83-f033383f15fa
📒 Files selected for processing (8)
lib/Db/TalkBot.phplib/Db/TalkBotMapper.phplib/Migration/Version034000Date20260428144801.phplib/Service/TalkBotsService.phppsalm.xmltests/php/Controller/TalkBotControllerTest.phptests/php/Migration/Version034000Date20260428144801Test.phptests/stubs/oca_talk_events.php
…s table Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
5fface8 to
413b396
Compare
edward-ly
left a comment
There was a problem hiding this comment.
Nice! Works with talk_bot_ai
Summary
oc_ex_apps_talk_bots(id,appid,route,secret,created_time) replaces the two-row-per-bot K/V pattern inappconfig_ex. Unique index on(appid, route)is the natural key for register/unregister/proxy lookups;appidindex supports per-ExApp fan-out.TalkBotsServicerewritten on top ofTalkBotMapper/TalkBotentity. Bot secrets are encrypted at rest viaICrypto. Re-register is a no-op on AppAPI's side - Talk owns the human-readable metadata viaBotInstallEventand reconciles its own row on every register.appconfig_ex. Handles both plaintext (the legacy default, since the old service never passed$sensitive=true) andsensitive=1encrypted secret rows. Re-encrypts on insert into the new table. Each bot runs in its own transaction with per-bot rollback, and the migration is safe to re-run (skips bots already present in the new table).POST/DELETE /ex-app/talk_botkeep the same params and the same{id, secret}response shape.bot_id = sha1(\$appid . '_' . \$route)is preserved, so existing community bots (including nc_py_api callers) continue to work post-upgrade without re-registration. The proxy URL and HMAC verification path are byte-identical.ExAppService::unregisterExAppcallsTalkBotsService::unregisterExAppTalkBots, which dispatchesBotUninstallEventper bot so Talk'stalk_bots_serverstays aligned with our table.mapper->insertfails after Talk has already persisted its row from the install event, the service firesBotUninstallEventto avoid leaving Talk with an orphan pointing at a secret AppAPI never stored.Test plan
psalmclean (stub added for spreedBot{Install,Uninstall}Event)appconfig_exstate with the same secret bytes -> run migration -> real HMAC-SHA256-signed POST throughproxyTalkMessageis accepted (HMAC verification succeeds against the migrated secret)occ app_api:app:unregister: bothoc_ex_apps_talk_botsandoc_talk_bots_serverrows for the ExApp are cleanedSummary by CodeRabbit
Infrastructure
Bug Fixes
Behavior
Tests