1
0
forked from mirror/misskey

NoteにisSensitive

This commit is contained in:
mei23 2019-08-25 22:05:41 +09:00
parent 1c4e1af7c3
commit 3d5bcfbaf0
No known key found for this signature in database
GPG Key ID: DD8628500D3E4B23
6 changed files with 29 additions and 17 deletions

View 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"`);
}
}

View File

@ -83,6 +83,12 @@ export class Note {
@JoinColumn()
public user: User | null;
@Column('boolean', {
default: false,
comment: 'Whether the Note is NSFW.'
})
public isSensitive: boolean;
@Column('boolean', {
default: false
})

View File

@ -158,7 +158,7 @@ export default async function renderNote(note: Note, dive = true): Promise<any>
cc,
inReplyTo,
attachment: files.map(renderDocument),
sensitive: files.some(file => file.isSensitive),
sensitive: note.isSensitive || files.some(file => file.isSensitive),
tag,
...asPoll
};

View File

@ -36,7 +36,7 @@ export const meta = {
validator: $.optional.bool,
default: false,
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 });
}
}));
}
if (ps.excludeNsfw) {
// v11 TODO
/*
query['_files.isSensitive'] = {
$ne: true
};
*/
}
if (ps.excludeNsfw) {
query.andWhere('note.isSensitive = FALSE');
}
//#endregion

View File

@ -113,7 +113,7 @@ export const meta = {
validator: $.optional.bool,
default: false,
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 });
}
}));
}
if (ps.excludeNsfw) {
// v11 TODO
/*query['_files.isSensitive'] = {
$ne: true
};*/
}
if (ps.excludeNsfw) {
query.andWhere('note.isSensitive = FALSE');
}
if (!ps.includeReplies) {

View File

@ -357,6 +357,7 @@ async function insertNote(user: User, data: Option, tags: string[], emojis: stri
tags: tags.map(tag => tag.toLowerCase()),
emojis,
userId: user.id,
isSensitive: data.cw != null || (data.files ? data.files.some(file => file.isSensitive) : false),
viaMobile: data.viaMobile!,
localOnly: data.localOnly!,
geo: data.geo || null,