weverse
Version:
Wrapper for weverse private API
41 lines (40 loc) • 1.42 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WeversePost = void 0;
const client_1 = require("../client");
const axios_1 = __importDefault(require("axios"));
class WeversePost extends (0, client_1.AssignType)() {
constructor(props, community, artist) {
super(props);
this.comments = [];
this.artist = artist;
this.community = community;
}
async getVideoUrls(headers) {
if (this.attachedVideos) {
const { data } = await axios_1.default.post(client_1.WeverseUrl.postDetails(this.id, this.community.id), {}, { headers });
if (typeof data.attachedVideos[0].videoUrl === 'string') {
this.attachedVideos[0].videoUrl = new URL(data.attachedVideos[0].videoUrl);
}
}
else {
return;
}
}
addComments(comments) {
const added = comments.filter(c => !this.comments.some(c2 => c2.id === c.id));
this.comments = added.concat(this.comments);
return added;
}
toJSON() {
const partial = Object.assign({}, this);
delete partial.artist;
delete partial.community;
delete partial.comments;
return partial;
}
}
exports.WeversePost = WeversePost;