rcs-data
Version:
RCS消息数据结构
56 lines • 2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RcsMsgBase = void 0;
class RcsMsgBase {
constructor(mime) {
this._mime = mime;
}
get mime() {
return this._mime;
}
header(name, value) {
return this.mime.header(name, value);
}
get contentType() {
return this.mime.contentType;
}
headerLines({ includeDeliveryInfo } = { includeDeliveryInfo: true }) {
const lines = [];
if (includeDeliveryInfo) {
if (this.from)
lines.push(`From: ${this.from.value}`);
if (this.to)
lines.push(`To: ${this.to.value}`);
if (this.conversationId)
lines.push(`Conversation-ID: ${this.conversationId}`);
if (this.contributionId)
lines.push(`Contribution-ID: ${this.contributionId}`);
}
Object.entries(this.mime._headers)
.filter(([name]) => name !== 'Content-Type')
.forEach(([name, header]) => lines.push(`${name}: ${header.value}`));
return lines;
}
output({ includeDeliveryInfo } = { includeDeliveryInfo: true }) {
let bodyString = this.mime.toString({ noHeaders: true });
let headerLines = this.headerLines({ includeDeliveryInfo });
return { headerLines, bodyString };
}
outputPlainObject() {
let output = {
conversationId: this.conversationId,
contributionId: this.contributionId,
messageId: this.messageId,
dateTime: this.dateTime.value,
senderAddress: this.from.toString(),
destinationAddress: [this.to.toString()],
};
if (Array.isArray(this.messagePlainObject))
output['messageList'] = this.messagePlainObject;
else
output['messageList'] = [this.messagePlainObject];
return output;
}
}
exports.RcsMsgBase = RcsMsgBase;
//# sourceMappingURL=RcsMsgBase.js.map