mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 14:17:40 +00:00
fix(telegram): inject tenant_id into command handler context
All Telegram bot commands (/writers, /addwriter, /removewriter, /reset, /tasks, /task_detail) and callback queries were missing tenant_id in context, causing "tenant_id required" errors from scopeClause() or silent fallback to MasterTenantID breaking multi-tenant isolation.
This commit is contained in:
1 parent
0b3be862c9
commit
5f5b0c45bd
2 files changed
+6
No files matched your search
@@ -58,6 +58,9 @@ func (c *Channel) handleBotCommand(ctx context.Context, message *telego.Message,
|
||||
|
||||
cmd = strings.SplitN(cmd, "@", 2)[0]
|
||||
|
||||
// Inject tenant scope so all command handlers have tenant_id in context.
|
||||
ctx = store.WithTenantID(ctx, c.TenantID())
|
||||
|
||||
chatIDObj := tu.ID(chatID)
|
||||
|
||||
// Helper: set MessageThreadID on outgoing messages for forum topics.
|
||||
|
||||
@@ -196,6 +196,9 @@ func (c *Channel) handleTaskDetail(ctx context.Context, chatID int64, text strin
|
||||
// handleCallbackQuery handles inline keyboard button presses.
|
||||
func (c *Channel) handleCallbackQuery(ctx context.Context, query *telego.CallbackQuery) {
|
||||
// Always answer to dismiss the loading indicator.
|
||||
// Inject tenant scope (callback queries bypass handleBotCommand).
|
||||
ctx = store.WithTenantID(ctx, c.TenantID())
|
||||
|
||||
c.bot.AnswerCallbackQuery(ctx, &telego.AnswerCallbackQueryParams{
|
||||
CallbackQueryID: query.ID,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user