fix: pass accountId to resolveAgentRoute for multi-account routing
The handler was calling resolveAgentRoute without accountId, causing all Matrix messages to route to the default agent regardless of which account received them. Changes: - Add accountId to MatrixMonitorHandlerParams type - Extract accountId in createMatrixRoomMessageHandler - Pass accountId to resolveAgentRoute call - Pass accountId from monitorMatrixProvider to handler
This commit is contained in:
parent
91f9010237
commit
2c653096eb
2 changed files with 5 additions and 0 deletions
|
|
@ -79,6 +79,8 @@ export type MatrixMonitorHandlerParams = {
|
||||||
};
|
};
|
||||||
getRoomInfo: (roomId: string) => Promise<{ name?: string; canonicalAlias?: string; altAliases: string[] }>;
|
getRoomInfo: (roomId: string) => Promise<{ name?: string; canonicalAlias?: string; altAliases: string[] }>;
|
||||||
getMemberDisplayName: (roomId: string, userId: string) => Promise<string>;
|
getMemberDisplayName: (roomId: string, userId: string) => Promise<string>;
|
||||||
|
/** Account ID for multi-account routing */
|
||||||
|
accountId?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParams) {
|
export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParams) {
|
||||||
|
|
@ -104,6 +106,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||||
directTracker,
|
directTracker,
|
||||||
getRoomInfo,
|
getRoomInfo,
|
||||||
getMemberDisplayName,
|
getMemberDisplayName,
|
||||||
|
accountId,
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
return async (roomId: string, event: MatrixRawEvent) => {
|
return async (roomId: string, event: MatrixRawEvent) => {
|
||||||
|
|
@ -442,6 +445,7 @@ export function createMatrixRoomMessageHandler(params: MatrixMonitorHandlerParam
|
||||||
const route = core.channel.routing.resolveAgentRoute({
|
const route = core.channel.routing.resolveAgentRoute({
|
||||||
cfg,
|
cfg,
|
||||||
channel: "matrix",
|
channel: "matrix",
|
||||||
|
accountId: accountId ?? undefined,
|
||||||
peer: {
|
peer: {
|
||||||
kind: isDirectMessage ? "dm" : "channel",
|
kind: isDirectMessage ? "dm" : "channel",
|
||||||
id: isDirectMessage ? senderId : roomId,
|
id: isDirectMessage ? senderId : roomId,
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,7 @@ export async function monitorMatrixProvider(opts: MonitorMatrixOpts = {}): Promi
|
||||||
directTracker,
|
directTracker,
|
||||||
getRoomInfo,
|
getRoomInfo,
|
||||||
getMemberDisplayName,
|
getMemberDisplayName,
|
||||||
|
accountId: opts.accountId,
|
||||||
});
|
});
|
||||||
|
|
||||||
registerMatrixMonitorEvents({
|
registerMatrixMonitorEvents({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue