mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-26 06:43:33 +00:00
mattermost: fix DM media upload for unprefixed user IDs (#29925)
Merged via squash.
Prepared head SHA: 5cffcb072c
Co-authored-by: teconomix <6959299+teconomix@users.noreply.github.com>
Co-authored-by: mukhtharcm <56378562+mukhtharcm@users.noreply.github.com>
Reviewed-by: @mukhtharcm
This commit is contained in:
@@ -13,6 +13,10 @@ vi.mock("../../infra/outbound/channel-selection.js", () => ({
|
||||
.mockResolvedValue({ channel: "telegram", configured: ["telegram"] }),
|
||||
}));
|
||||
|
||||
vi.mock("../../infra/outbound/target-resolver.js", () => ({
|
||||
maybeResolveIdLikeTarget: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../../pairing/pairing-store.js", () => ({
|
||||
readChannelAllowFromStoreSync: vi.fn(() => []),
|
||||
}));
|
||||
@@ -23,6 +27,7 @@ vi.mock("../../web/accounts.js", () => ({
|
||||
|
||||
import { loadSessionStore } from "../../config/sessions.js";
|
||||
import { resolveMessageChannelSelection } from "../../infra/outbound/channel-selection.js";
|
||||
import { maybeResolveIdLikeTarget } from "../../infra/outbound/target-resolver.js";
|
||||
import { readChannelAllowFromStoreSync } from "../../pairing/pairing-store.js";
|
||||
import { resolveWhatsAppAccount } from "../../web/accounts.js";
|
||||
import { resolveDeliveryTarget } from "./delivery-target.js";
|
||||
@@ -152,6 +157,30 @@ describe("resolveDeliveryTarget", () => {
|
||||
expect(result.accountId).toBeUndefined();
|
||||
});
|
||||
|
||||
it("applies id-like target normalization before returning delivery targets", async () => {
|
||||
setMainSessionEntry(undefined);
|
||||
vi.mocked(maybeResolveIdLikeTarget).mockClear();
|
||||
vi.mocked(maybeResolveIdLikeTarget).mockResolvedValueOnce({
|
||||
to: "user:123456789",
|
||||
kind: "user",
|
||||
source: "directory",
|
||||
});
|
||||
|
||||
const result = await resolveDeliveryTarget(makeCfg({ bindings: [] }), AGENT_ID, {
|
||||
channel: "telegram",
|
||||
to: "123456789",
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.to).toBe("user:123456789");
|
||||
expect(maybeResolveIdLikeTarget).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
channel: "telegram",
|
||||
input: "123456789",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("selects correct binding when multiple agents have bindings", async () => {
|
||||
setMainSessionEntry(undefined);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
resolveStorePath,
|
||||
} from "../../config/sessions.js";
|
||||
import { resolveMessageChannelSelection } from "../../infra/outbound/channel-selection.js";
|
||||
import { maybeResolveIdLikeTarget } from "../../infra/outbound/target-resolver.js";
|
||||
import type { OutboundChannel } from "../../infra/outbound/targets.js";
|
||||
import {
|
||||
resolveOutboundTarget,
|
||||
@@ -190,10 +191,16 @@ export async function resolveDeliveryTarget(
|
||||
error: docked.error,
|
||||
};
|
||||
}
|
||||
const idLikeTarget = await maybeResolveIdLikeTarget({
|
||||
cfg,
|
||||
channel,
|
||||
input: docked.to,
|
||||
accountId,
|
||||
});
|
||||
return {
|
||||
ok: true,
|
||||
channel,
|
||||
to: docked.to,
|
||||
to: idLikeTarget?.to ?? docked.to,
|
||||
accountId,
|
||||
threadId,
|
||||
mode,
|
||||
|
||||
Reference in New Issue
Block a user