NoteにisSensitive
This commit is contained in:
parent
1c4e1af7c3
commit
3d5bcfbaf0
13
migration/1566733587544-NoteSensitive.ts
Normal file
13
migration/1566733587544-NoteSensitive.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import {MigrationInterface, QueryRunner} from "typeorm";
|
||||||
|
|
||||||
|
export class NoteSensitive1566733587544 implements MigrationInterface {
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<any> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "note" ADD "isSensitive" boolean NOT NULL DEFAULT false`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<any> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "isSensitive"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -83,6 +83,12 @@ export class Note {
|
||||||
@JoinColumn()
|
@JoinColumn()
|
||||||
public user: User | null;
|
public user: User | null;
|
||||||
|
|
||||||
|
@Column('boolean', {
|
||||||
|
default: false,
|
||||||
|
comment: 'Whether the Note is NSFW.'
|
||||||
|
})
|
||||||
|
public isSensitive: boolean;
|
||||||
|
|
||||||
@Column('boolean', {
|
@Column('boolean', {
|
||||||
default: false
|
default: false
|
||||||
})
|
})
|
||||||
|
|
|
@ -158,7 +158,7 @@ export default async function renderNote(note: Note, dive = true): Promise<any>
|
||||||
cc,
|
cc,
|
||||||
inReplyTo,
|
inReplyTo,
|
||||||
attachment: files.map(renderDocument),
|
attachment: files.map(renderDocument),
|
||||||
sensitive: files.some(file => file.isSensitive),
|
sensitive: note.isSensitive || files.some(file => file.isSensitive),
|
||||||
tag,
|
tag,
|
||||||
...asPoll
|
...asPoll
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,7 +36,7 @@ export const meta = {
|
||||||
validator: $.optional.bool,
|
validator: $.optional.bool,
|
||||||
default: false,
|
default: false,
|
||||||
desc: {
|
desc: {
|
||||||
'ja-JP': 'true にすると、NSFW指定されたファイルを除外します(fileTypeが指定されている場合のみ有効)'
|
'ja-JP': 'true にすると、NSFW指定されたコンテンツを除外します'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -110,15 +110,10 @@ export default define(meta, async (ps, user) => {
|
||||||
qb.orWhere(`:type${i} = ANY(note.attachedFileTypes)`, { [`type${i}`]: type });
|
qb.orWhere(`:type${i} = ANY(note.attachedFileTypes)`, { [`type${i}`]: type });
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
if (ps.excludeNsfw) {
|
if (ps.excludeNsfw) {
|
||||||
// v11 TODO
|
query.andWhere('note.isSensitive = FALSE');
|
||||||
/*
|
|
||||||
query['_files.isSensitive'] = {
|
|
||||||
$ne: true
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ export const meta = {
|
||||||
validator: $.optional.bool,
|
validator: $.optional.bool,
|
||||||
default: false,
|
default: false,
|
||||||
desc: {
|
desc: {
|
||||||
'ja-JP': 'true にすると、NSFW指定されたファイルを除外します(fileTypeが指定されている場合のみ有効)'
|
'ja-JP': 'true にすると、NSFW指定されたコンテンツを除外します'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -164,13 +164,10 @@ export default define(meta, async (ps, me) => {
|
||||||
qb.orWhere(`:type${i} = ANY(note.attachedFileTypes)`, { [`type${i}`]: type });
|
qb.orWhere(`:type${i} = ANY(note.attachedFileTypes)`, { [`type${i}`]: type });
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
if (ps.excludeNsfw) {
|
if (ps.excludeNsfw) {
|
||||||
// v11 TODO
|
query.andWhere('note.isSensitive = FALSE');
|
||||||
/*query['_files.isSensitive'] = {
|
|
||||||
$ne: true
|
|
||||||
};*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ps.includeReplies) {
|
if (!ps.includeReplies) {
|
||||||
|
|
|
@ -357,6 +357,7 @@ async function insertNote(user: User, data: Option, tags: string[], emojis: stri
|
||||||
tags: tags.map(tag => tag.toLowerCase()),
|
tags: tags.map(tag => tag.toLowerCase()),
|
||||||
emojis,
|
emojis,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
isSensitive: data.cw != null || (data.files ? data.files.some(file => file.isSensitive) : false),
|
||||||
viaMobile: data.viaMobile!,
|
viaMobile: data.viaMobile!,
|
||||||
localOnly: data.localOnly!,
|
localOnly: data.localOnly!,
|
||||||
geo: data.geo || null,
|
geo: data.geo || null,
|
||||||
|
|
Loading…
Reference in a new issue