@ginstone/nga-api
Version:
43 lines (42 loc) • 1.57 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrepareBody = void 0;
const Attachment_1 = require("../field/attach/Attachment");
const Forum_1 = require("../field/Forum");
const ObjUtils_1 = require("../../utils/ObjUtils");
const StrUtils_1 = require("@ginstone/common-utils/dist/src/utils/StrUtils");
const StrUtils_2 = require("../../utils/StrUtils");
/**
* 准备请求响应
*/
class PrepareBody {
constructor(raw) {
this.action = raw.action;
if (raw.address)
this.address = raw.address;
this.attachUrl = raw.attach_url;
if (raw.attachs) {
this.attachments = (0, ObjUtils_1.values)(raw.attachs).map(i => new Attachment_1.Attachment(i));
}
this.auth = raw.auth;
if (raw.content)
this.content = (0, StrUtils_2.handleContent)(raw.content);
if (raw.content_org)
this.contentOriginal = (0, StrUtils_2.handleContent)(raw.content_org);
this.forumId = raw.fid;
this.moderator = !!raw.if_moderator;
this.modifyAppend = !!raw.modify_append;
this.hidden = !!raw.if_hidden;
this.replyId = raw.pid || 0;
if (raw.post_type)
this.replyType = raw.post_type;
if (raw.subject)
this.title = (0, StrUtils_1.unEscape)(raw.subject);
this.topicId = raw.tid;
if (raw.type)
this.topicType = raw.type;
this.currentUser = raw.__CU;
this.forum = new Forum_1.Forum(raw.__F);
}
}
exports.PrepareBody = PrepareBody;