fix(protocol): keep image upload errors and PID send tests accurate
Roster warmup now talks on the first live sender, so ownership tests only count Test.* packets. Image upload still reports a missing body as an image failure.
This commit is contained in:
3 files changed
+39
-19
No files matched your search
@@ -215,6 +215,7 @@ async function runNtv2UploadOperation(
|
||||
extBizInfo: params.extBizInfo,
|
||||
tryFast,
|
||||
clientRandomId: makeClientRandomId(),
|
||||
label,
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof OidbError) setState('oidb_rejected');
|
||||
|
||||
@@ -30,6 +30,7 @@ export namespace Ntv2UploadRequest {
|
||||
extBizInfo: NTV2ExtBizInfo;
|
||||
tryFast: boolean;
|
||||
clientRandomId: bigint;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
@@ -61,17 +62,20 @@ export namespace Ntv2UploadRequest {
|
||||
},
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: NTV2UploadRichMediaResp): NTV2UploadRespBody => {
|
||||
if (!body) throw new Error('media upload response body missing');
|
||||
export const deserializeUpload = (body: NTV2UploadRichMediaResp, label = 'media'): NTV2UploadRespBody => {
|
||||
if (!body) throw new Error(`${label} upload response body missing`);
|
||||
if (body.respHead?.retCode && body.respHead.retCode !== 0) {
|
||||
throw new Error(body.respHead.message ?? 'media upload failed');
|
||||
throw new Error(body.respHead.message ?? `${label} upload failed`);
|
||||
}
|
||||
const upload = body.upload;
|
||||
if (!upload) throw new Error('media upload response body missing');
|
||||
if (!upload) throw new Error(`${label} upload response body missing`);
|
||||
if (!upload.msgInfo) throw new Error('upload response missing msgInfo');
|
||||
return upload;
|
||||
};
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: NTV2UploadRichMediaResp): NTV2UploadRespBody =>
|
||||
deserializeUpload(body);
|
||||
|
||||
export const encode = (env: OidbBase<NTV2UploadRichMediaReq>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<NTV2UploadRichMediaReq>>(env);
|
||||
|
||||
@@ -79,5 +83,8 @@ export namespace Ntv2UploadRequest {
|
||||
protobuf_decode<OidbBase<NTV2UploadRichMediaResp>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<NTV2UploadRespBody> =>
|
||||
invokeOidb(deps, Ntv2UploadRequest, params);
|
||||
invokeOidb(deps, {
|
||||
...Ntv2UploadRequest,
|
||||
deserialize: (_ctx, body) => deserializeUpload(body, params.label ?? 'media'),
|
||||
}, params);
|
||||
}
|
||||
Reference in new issue
Block a user