411 lines
10 KiB
JavaScript
411 lines
10 KiB
JavaScript
function _ts_decorate(decorators, target, key, desc) {
|
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
}
|
|
function _ts_metadata(k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
}
|
|
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from "typeorm";
|
|
import { User } from "./user.js";
|
|
import { UserGroup } from "./user-group.js";
|
|
import { id } from "../id.js";
|
|
import { noteVisibilities } from "../../types.js";
|
|
import { Channel } from "./channel.js";
|
|
export let Note = class Note {
|
|
id;
|
|
createdAt;
|
|
replyId;
|
|
reply;
|
|
renoteId;
|
|
renote;
|
|
threadId;
|
|
text;
|
|
name;
|
|
cw;
|
|
userId;
|
|
user;
|
|
groupId;
|
|
group;
|
|
localOnly;
|
|
renoteCount;
|
|
repliesCount;
|
|
viewCount;
|
|
reactions;
|
|
/**
|
|
* public ... 公開
|
|
* home ... ホームタイムライン(ユーザーページのタイムライン含む)のみに流す
|
|
* hidden ... only visible on profile (doesnt federate, like local only, but can be fetched via AP like home) <- for now only used for post imports
|
|
* followers ... フォロワーのみ
|
|
* specified ... visibleUserIds で指定したユーザーのみ
|
|
*/ visibility;
|
|
uri;
|
|
url;
|
|
score;
|
|
fileIds;
|
|
attachedFileTypes;
|
|
visibleUserIds;
|
|
mentions;
|
|
mentionedRemoteUsers;
|
|
emojis;
|
|
tags;
|
|
hasPoll;
|
|
channelId;
|
|
channel;
|
|
quoteAuthorization;
|
|
canQuote;
|
|
//#region Denormalized fields
|
|
userHost;
|
|
replyUserId;
|
|
replyUserHost;
|
|
renoteUserId;
|
|
renoteUserHost;
|
|
updatedAt;
|
|
//#endregion
|
|
constructor(data){
|
|
if (data == null) return;
|
|
for (const [k, v] of Object.entries(data)){
|
|
this[k] = v;
|
|
}
|
|
}
|
|
};
|
|
_ts_decorate([
|
|
PrimaryColumn(id()),
|
|
_ts_metadata("design:type", String)
|
|
], Note.prototype, "id", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column("timestamp with time zone", {
|
|
comment: "The created date of the Note."
|
|
}),
|
|
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
], Note.prototype, "createdAt", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: "The ID of reply target."
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "replyId", void 0);
|
|
_ts_decorate([
|
|
ManyToOne((type)=>Note, {
|
|
onDelete: "CASCADE"
|
|
}),
|
|
JoinColumn(),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "reply", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: "The ID of renote target."
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "renoteId", void 0);
|
|
_ts_decorate([
|
|
ManyToOne((type)=>Note, {
|
|
onDelete: "CASCADE"
|
|
}),
|
|
JoinColumn(),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "renote", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column("varchar", {
|
|
length: 256,
|
|
nullable: true
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "threadId", void 0);
|
|
_ts_decorate([
|
|
Index('note_text_fts_idx', {
|
|
synchronize: false
|
|
}),
|
|
Column("text", {
|
|
nullable: true
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "text", void 0);
|
|
_ts_decorate([
|
|
Column("varchar", {
|
|
length: 256,
|
|
nullable: true
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "name", void 0);
|
|
_ts_decorate([
|
|
Column("varchar", {
|
|
length: 512,
|
|
nullable: true
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "cw", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column({
|
|
...id(),
|
|
comment: "The ID of author."
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "userId", void 0);
|
|
_ts_decorate([
|
|
ManyToOne((type)=>User, {
|
|
onDelete: "CASCADE"
|
|
}),
|
|
JoinColumn(),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "user", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: "The ID of acting group."
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "groupId", void 0);
|
|
_ts_decorate([
|
|
ManyToOne((type)=>UserGroup, {
|
|
onDelete: "SET NULL"
|
|
}),
|
|
JoinColumn(),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "group", void 0);
|
|
_ts_decorate([
|
|
Column("boolean", {
|
|
default: false
|
|
}),
|
|
_ts_metadata("design:type", Boolean)
|
|
], Note.prototype, "localOnly", void 0);
|
|
_ts_decorate([
|
|
Column("smallint", {
|
|
default: 0
|
|
}),
|
|
_ts_metadata("design:type", Number)
|
|
], Note.prototype, "renoteCount", void 0);
|
|
_ts_decorate([
|
|
Column("smallint", {
|
|
default: 0
|
|
}),
|
|
_ts_metadata("design:type", Number)
|
|
], Note.prototype, "repliesCount", void 0);
|
|
_ts_decorate([
|
|
Column("integer", {
|
|
default: 0
|
|
}),
|
|
_ts_metadata("design:type", Number)
|
|
], Note.prototype, "viewCount", void 0);
|
|
_ts_decorate([
|
|
Column("jsonb", {
|
|
default: {}
|
|
}),
|
|
_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
], Note.prototype, "reactions", void 0);
|
|
_ts_decorate([
|
|
Column("enum", {
|
|
enum: noteVisibilities
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "visibility", void 0);
|
|
_ts_decorate([
|
|
Index({
|
|
unique: true
|
|
}),
|
|
Column("varchar", {
|
|
length: 512,
|
|
nullable: true,
|
|
comment: "The URI of a note. it will be null when the note is local."
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "uri", void 0);
|
|
_ts_decorate([
|
|
Index("IDX_note_url"),
|
|
Column("varchar", {
|
|
length: 512,
|
|
nullable: true,
|
|
comment: "The human readable url of a note. it will be null when the note is local."
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "url", void 0);
|
|
_ts_decorate([
|
|
Column("integer", {
|
|
default: 0,
|
|
select: false
|
|
}),
|
|
_ts_metadata("design:type", Number)
|
|
], Note.prototype, "score", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column({
|
|
...id(),
|
|
array: true,
|
|
default: "{}"
|
|
}),
|
|
_ts_metadata("design:type", Array)
|
|
], Note.prototype, "fileIds", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column("varchar", {
|
|
length: 256,
|
|
array: true,
|
|
default: "{}"
|
|
}),
|
|
_ts_metadata("design:type", Array)
|
|
], Note.prototype, "attachedFileTypes", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column({
|
|
...id(),
|
|
array: true,
|
|
default: "{}"
|
|
}),
|
|
_ts_metadata("design:type", Array)
|
|
], Note.prototype, "visibleUserIds", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column({
|
|
...id(),
|
|
array: true,
|
|
default: "{}"
|
|
}),
|
|
_ts_metadata("design:type", Array)
|
|
], Note.prototype, "mentions", void 0);
|
|
_ts_decorate([
|
|
Column("text", {
|
|
default: "[]"
|
|
}),
|
|
_ts_metadata("design:type", String)
|
|
], Note.prototype, "mentionedRemoteUsers", void 0);
|
|
_ts_decorate([
|
|
Column("varchar", {
|
|
length: 128,
|
|
array: true,
|
|
default: "{}"
|
|
}),
|
|
_ts_metadata("design:type", Array)
|
|
], Note.prototype, "emojis", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column("varchar", {
|
|
length: 128,
|
|
array: true,
|
|
default: "{}"
|
|
}),
|
|
_ts_metadata("design:type", Array)
|
|
], Note.prototype, "tags", void 0);
|
|
_ts_decorate([
|
|
Column("boolean", {
|
|
default: false
|
|
}),
|
|
_ts_metadata("design:type", Boolean)
|
|
], Note.prototype, "hasPoll", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: "The ID of source channel."
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "channelId", void 0);
|
|
_ts_decorate([
|
|
ManyToOne((type)=>Channel, {
|
|
onDelete: "CASCADE"
|
|
}),
|
|
JoinColumn(),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "channel", void 0);
|
|
_ts_decorate([
|
|
Column("varchar", {
|
|
length: 512,
|
|
nullable: true
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "quoteAuthorization", void 0);
|
|
_ts_decorate([
|
|
Column("boolean", {
|
|
default: false
|
|
}),
|
|
_ts_metadata("design:type", Boolean)
|
|
], Note.prototype, "canQuote", void 0);
|
|
_ts_decorate([
|
|
Index(),
|
|
Column("varchar", {
|
|
length: 512,
|
|
nullable: true,
|
|
comment: "[Denormalized]"
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "userHost", void 0);
|
|
_ts_decorate([
|
|
Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: "[Denormalized]"
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "replyUserId", void 0);
|
|
_ts_decorate([
|
|
Column("varchar", {
|
|
length: 512,
|
|
nullable: true,
|
|
comment: "[Denormalized]"
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "replyUserHost", void 0);
|
|
_ts_decorate([
|
|
Column({
|
|
...id(),
|
|
nullable: true,
|
|
comment: "[Denormalized]"
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "renoteUserId", void 0);
|
|
_ts_decorate([
|
|
Column("varchar", {
|
|
length: 512,
|
|
nullable: true,
|
|
comment: "[Denormalized]"
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "renoteUserHost", void 0);
|
|
_ts_decorate([
|
|
Column("timestamp with time zone", {
|
|
nullable: true,
|
|
comment: "The updated date of the Note."
|
|
}),
|
|
_ts_metadata("design:type", Object)
|
|
], Note.prototype, "updatedAt", void 0);
|
|
Note = _ts_decorate([
|
|
Entity(),
|
|
Index("IDX_NOTE_TAGS", {
|
|
synchronize: false
|
|
}),
|
|
Index("IDX_NOTE_MENTIONS", {
|
|
synchronize: false
|
|
}),
|
|
Index("IDX_NOTE_VISIBLE_USER_IDS", {
|
|
synchronize: false
|
|
}),
|
|
Index("IDX_note_userId_id", [
|
|
"userId",
|
|
"id"
|
|
]),
|
|
Index("IDX_note_id_userHost", [
|
|
"id",
|
|
"userHost"
|
|
]),
|
|
Index("IDX_note_createdAt_userId", [
|
|
"createdAt",
|
|
"userId"
|
|
]),
|
|
_ts_metadata("design:type", Function),
|
|
_ts_metadata("design:paramtypes", [
|
|
typeof Partial === "undefined" ? Object : Partial
|
|
])
|
|
], Note);
|