diff --git a/src/common/forward-msg-builder.ts b/src/common/forward-msg-builder.ts index bcd521b0..2771156b 100644 --- a/src/common/forward-msg-builder.ts +++ b/src/common/forward-msg-builder.ts @@ -99,7 +99,7 @@ export class ForwardMsgBuilder { senderName: msg.senderName, isGroupMsg: msg.groupId !== undefined, msg: msg.msg.map(m => ({ - preview: m.toPreview(), + preview: m.valid? m.toPreview() : "[该消息类型暂不支持查看]", })) }))); } diff --git a/src/core/packet/msg/element.ts b/src/core/packet/msg/element.ts index 80205ec0..fc602734 100644 --- a/src/core/packet/msg/element.ts +++ b/src/core/packet/msg/element.ts @@ -36,6 +36,10 @@ export abstract class IPacketMsgElement { protected constructor(rawElement: T) { } + get valid(): boolean { + return true; + } + buildContent(): Uint8Array | undefined { return undefined; } @@ -265,6 +269,10 @@ export class PacketMsgPicElement extends IPacketMsgElement { this.picType = element.picElement.picType; } + get valid(): boolean { + return !!this.msgInfo; + } + buildElement(): NapProtoEncodeStructType[] { if (!this.msgInfo) return []; return [{ @@ -306,6 +314,10 @@ export class PacketMsgVideoElement extends IPacketMsgElement { this.thumbHeight = element.videoElement.thumbHeight; } + get valid(): boolean { + return !!this.msgInfo; + } + buildElement(): NapProtoEncodeStructType[] { if (!this.msgInfo) return []; return [{ @@ -338,15 +350,20 @@ export class PacketMsgPttElement extends IPacketMsgElement { this.fileDuration = Math.round(element.pttElement.duration); // TODO: cc } + get valid(): boolean { + return !!this.msgInfo; + } + buildElement(): NapProtoEncodeStructType[] { - if (!this.msgInfo) return []; - return [{ - commonElem: { - serviceType: 48, - pbElem: new NapProtoMsg(MsgInfo).encode(this.msgInfo), - businessType: 22, - } - }]; + return [] + // if (!this.msgInfo) return []; + // return [{ + // commonElem: { + // serviceType: 48, + // pbElem: new NapProtoMsg(MsgInfo).encode(this.msgInfo), + // businessType: 22, + // } + // }]; } toPreview(): string { @@ -374,6 +391,10 @@ export class PacketMsgFileElement extends IPacketMsgElement { this.fileSize = +element.fileElement.fileSize; } + get valid(): boolean { + return this.isGroupFile || Boolean(this._e37_800_rsp); + } + buildContent(): Uint8Array | undefined { if (this.isGroupFile || !this._e37_800_rsp) return undefined; return new NapProtoMsg(FileExtra).encode({