fix(protocol): support image replies in existing temp sessions
Allow image replies in existing group temporary conversations while preserving passive-only restrictions. Missing, expired, or mismatched sessions remain rejected before media processing, and sending never creates or refreshes a session. Fixes #471
This commit is contained in:
11 files changed
+210
-30
No files matched your search
@@ -116,6 +116,7 @@ export async function uploadImageMsgInfo(
|
||||
isGroup: boolean,
|
||||
targetIdOrUid: string | number,
|
||||
element: MessageElement,
|
||||
tempGroupId?: number,
|
||||
): Promise<Uint8Array> {
|
||||
const log = loggerFor(bridge);
|
||||
const image = await loadImage(element);
|
||||
@@ -128,11 +129,12 @@ export async function uploadImageMsgInfo(
|
||||
subType: image.subType, summary: image.summary,
|
||||
}) }),
|
||||
};
|
||||
log.debug('uploading %d bytes md5=%s... → %s %s',
|
||||
log.debug('uploading %d bytes md5=%s... → %s %s%s',
|
||||
image.fileSize,
|
||||
image.md5Hex.slice(0, 8),
|
||||
isGroup ? 'group' : 'c2c',
|
||||
String(targetIdOrUid));
|
||||
isGroup ? 'group' : tempGroupId !== undefined ? 'group-temp' : 'c2c',
|
||||
String(targetIdOrUid),
|
||||
tempGroupId !== undefined ? ` sourceGroup=${tempGroupId}` : '');
|
||||
|
||||
const uploads: MediaSubFileUpload[] = [{
|
||||
source: 'top',
|
||||
@@ -147,6 +149,7 @@ export async function uploadImageMsgInfo(
|
||||
bridge,
|
||||
isGroup,
|
||||
targetIdOrUid,
|
||||
tempGroupId,
|
||||
oidbCmd: isGroup ? 0x11C4 : 0x11C5,
|
||||
serviceCmd: isGroup ? 'OidbSvcTrpcTcp.0x11c4_100' : 'OidbSvcTrpcTcp.0x11c5_100',
|
||||
requestId: 1,
|
||||
|
||||
@@ -66,6 +66,8 @@ export interface NtV2UploadParams {
|
||||
isGroup: boolean;
|
||||
/** Group uin when isGroup, otherwise the recipient's uid string. */
|
||||
targetIdOrUid: string | number;
|
||||
/** Existing passive group temp session; never creates or refreshes a session. */
|
||||
tempGroupId?: number;
|
||||
/** OIDB command id (e.g. 0x11C4 / 0x11C5 / 0x126E / 0x126D / 0x11EA / 0x11E9). */
|
||||
oidbCmd: number;
|
||||
/** Service cmd (e.g. 'OidbSvcTrpcTcp.0x11c4_100'). */
|
||||
@@ -147,10 +149,11 @@ export function runNtv2Upload(params: NtV2UploadParams): Promise<NTV2UploadRespB
|
||||
let didPut = false;
|
||||
return runWithTraceRequest(async () => {
|
||||
moduleLog.trace(() => [
|
||||
'highway_media_start label=%j scope=%s target=%j oidbCmd=%d serviceCmd=%j requestId=%d businessType=%d uploads=%s',
|
||||
'highway_media_start label=%j scope=%s target=%j sourceGroup=%s oidbCmd=%d serviceCmd=%j requestId=%d businessType=%d uploads=%s',
|
||||
label,
|
||||
params.isGroup ? 'group' : 'private',
|
||||
params.isGroup ? 'group' : params.tempGroupId !== undefined ? 'group-temp' : 'private',
|
||||
String(params.targetIdOrUid),
|
||||
params.tempGroupId === undefined ? '-' : String(params.tempGroupId),
|
||||
params.oidbCmd,
|
||||
params.serviceCmd,
|
||||
params.requestId,
|
||||
@@ -209,6 +212,7 @@ async function runNtv2UploadOperation(
|
||||
oidbCmd,
|
||||
isGroup,
|
||||
targetIdOrUid,
|
||||
tempGroupId: params.tempGroupId,
|
||||
requestId: params.requestId,
|
||||
businessType: params.businessType,
|
||||
uploadInfo: params.uploadInfo,
|
||||
|
||||
Reference in new issue
Block a user