fix(core): support file sources in forwarded messages (#144)
Pre-upload file/url/base64 segments for forwarded message nodes into the target scope, re-upload cached file_ids when crossing private/group scope, and suppress standalone file-message publishing during forward preparation.
This commit is contained in:
1 parent
3eba2a677c
commit
02de2acea4
4 files changed
+401
-22
No files matched your search
@@ -241,6 +241,7 @@ export class GroupFileApi {
|
||||
name = '',
|
||||
folderId = '/',
|
||||
uploadFile = true,
|
||||
publishFile = uploadFile,
|
||||
): Promise<UploadFileResult> {
|
||||
const bridge = asBridge(this.ctx);
|
||||
// Group/private files may legitimately be up to 4 GiB on QQ's wire,
|
||||
@@ -316,11 +317,11 @@ export class GroupFileApi {
|
||||
// the chat shows nothing. The publish step goes via a dedicated OIDB
|
||||
// call (0x6D9_4), NOT via `MessageSvc.PbSendMsg` with a transElem(24)
|
||||
// payload — the QQ-NT server rejects that with `result=79`. Mirrors
|
||||
// Lagrange.Core V2's `GroupSendFileService.cs`. Suppressed when the
|
||||
// caller opts out via `uploadFile=false` (treat that as "I only
|
||||
// wanted the slot allocated, hold the chat post"). Routes through
|
||||
// `this.publish` so tests can mock at the same Api boundary.
|
||||
if (uploadFile) {
|
||||
// Lagrange.Core V2's `GroupSendFileService.cs`. Suppressed when a
|
||||
// caller only needs a valid file_id embedded elsewhere, e.g. a
|
||||
// forward-message long-msg payload. Routes through `this.publish` so
|
||||
// tests can mock at the same Api boundary.
|
||||
if (publishFile) {
|
||||
try {
|
||||
await this.publish(groupId, fileId);
|
||||
} catch (err) {
|
||||
@@ -341,6 +342,7 @@ export class GroupFileApi {
|
||||
source: string,
|
||||
name = '',
|
||||
uploadFile = true,
|
||||
publishFile = uploadFile,
|
||||
): Promise<UploadFileResult> {
|
||||
const bridge = asBridge(this.ctx);
|
||||
const loaded = await loadBinarySource(source, 'file', FILE_UPLOAD_MAX_BYTES);
|
||||
@@ -482,7 +484,7 @@ export class GroupFileApi {
|
||||
// which only knows about elems[]. NapCat does the same atomic
|
||||
// upload+send dance — without it the file sits on the server and
|
||||
// the recipient sees nothing.
|
||||
if (uploadFile) {
|
||||
if (publishFile) {
|
||||
try {
|
||||
await this.ctx.apis.message.sendC2cFile(userId, targetUid, {
|
||||
fileId,
|
||||
|
||||
Reference in new issue
Block a user