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:
Teconomix
2026-03-10 09:52:24 +01:00
committed by GitHub
parent 568b0a22bb
commit 6d0547dc2e
15 changed files with 495 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ import {
} from "../../infra/outbound/outbound-session.js";
import { normalizeReplyPayloadsForDelivery } from "../../infra/outbound/payloads.js";
import { buildOutboundSessionContext } from "../../infra/outbound/session-context.js";
import { maybeResolveIdLikeTarget } from "../../infra/outbound/target-resolver.js";
import { resolveOutboundTarget } from "../../infra/outbound/targets.js";
import { normalizePollInput } from "../../polls.js";
import {
@@ -194,6 +195,13 @@ export const sendHandlers: GatewayRequestHandlers = {
meta: { channel },
};
}
const idLikeTarget = await maybeResolveIdLikeTarget({
cfg,
channel,
input: resolved.to,
accountId,
});
const deliveryTarget = idLikeTarget?.to ?? resolved.to;
const outboundDeps = context.deps ? createOutboundSendDeps(context.deps) : undefined;
const mirrorPayloads = normalizeReplyPayloadsForDelivery([
{ text: message, mediaUrl, mediaUrls },
@@ -225,7 +233,8 @@ export const sendHandlers: GatewayRequestHandlers = {
channel,
agentId: effectiveAgentId,
accountId,
target: resolved.to,
target: deliveryTarget,
resolvedTarget: idLikeTarget,
threadId,
})
: null;
@@ -246,7 +255,7 @@ export const sendHandlers: GatewayRequestHandlers = {
const results = await deliverOutboundPayloads({
cfg,
channel: outboundChannel,
to: resolved.to,
to: deliveryTarget,
accountId,
payloads: [{ text: message, mediaUrl, mediaUrls }],
session: outboundSession,