Add excludeNsfw option
This commit is contained in:
parent
5da18ba535
commit
afdacf14b7
@ -187,6 +187,7 @@ export default Vue.extend({
|
|||||||
|
|
||||||
(this as any).api('notes/local-timeline', {
|
(this as any).api('notes/local-timeline', {
|
||||||
fileType: image,
|
fileType: image,
|
||||||
|
excludeNsfw: true,
|
||||||
limit: 6
|
limit: 6
|
||||||
}).then((notes: any[]) => {
|
}).then((notes: any[]) => {
|
||||||
const files = concat(notes.map((n: any): any[] => n.files));
|
const files = concat(notes.map((n: any): any[] => n.files));
|
||||||
|
@ -111,6 +111,7 @@ export default Vue.extend({
|
|||||||
|
|
||||||
(this as any).api('notes/local-timeline', {
|
(this as any).api('notes/local-timeline', {
|
||||||
fileType: image,
|
fileType: image,
|
||||||
|
excludeNsfw: true,
|
||||||
limit: 6
|
limit: 6
|
||||||
}).then((notes: any[]) => {
|
}).then((notes: any[]) => {
|
||||||
const files = concat(notes.map((n: any): any[] => n.files));
|
const files = concat(notes.map((n: any): any[] => n.files));
|
||||||
|
@ -20,6 +20,7 @@ Note.createIndex('userId');
|
|||||||
Note.createIndex('mentions');
|
Note.createIndex('mentions');
|
||||||
Note.createIndex('visibleUserIds');
|
Note.createIndex('visibleUserIds');
|
||||||
Note.createIndex('tagsLower');
|
Note.createIndex('tagsLower');
|
||||||
|
Note.createIndex('_files._id');
|
||||||
Note.createIndex('_files.contentType');
|
Note.createIndex('_files.contentType');
|
||||||
Note.createIndex({
|
Note.createIndex({
|
||||||
createdAt: -1
|
createdAt: -1
|
||||||
|
@ -4,6 +4,7 @@ import DriveFile, { validateFileName, pack } from '../../../../../models/drive-f
|
|||||||
import { publishDriveStream } from '../../../../../stream';
|
import { publishDriveStream } from '../../../../../stream';
|
||||||
import { ILocalUser } from '../../../../../models/user';
|
import { ILocalUser } from '../../../../../models/user';
|
||||||
import getParams from '../../../get-params';
|
import getParams from '../../../get-params';
|
||||||
|
import Note from '../../../../../models/note';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
@ -93,6 +94,18 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ドライブのファイルが非正規化されているドキュメントも更新
|
||||||
|
Note.find({
|
||||||
|
'_files._id': file._id
|
||||||
|
}).then(notes => {
|
||||||
|
notes.forEach(note => {
|
||||||
|
note._files[note._files.findIndex(f => f._id.equals(file._id))] = file;
|
||||||
|
Note.findOneAndUpdate({ _id: note._id }, {
|
||||||
|
_files: note._files
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const fileObj = await pack(file);
|
const fileObj = await pack(file);
|
||||||
|
|
||||||
|
@ -30,6 +30,13 @@ export const meta = {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
excludeNsfw: $.bool.optional.note({
|
||||||
|
default: false,
|
||||||
|
desc: {
|
||||||
|
'ja-JP': 'true にすると、NSFW指定されたファイルを除外します(fileTypeが指定されている場合のみ有効)'
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
limit: $.num.optional.range(1, 100).note({
|
limit: $.num.optional.range(1, 100).note({
|
||||||
default: 10
|
default: 10
|
||||||
}),
|
}),
|
||||||
@ -97,6 +104,12 @@ export default async (params: any, user: ILocalUser) => {
|
|||||||
query['_files.contentType'] = {
|
query['_files.contentType'] = {
|
||||||
$in: ps.fileType
|
$in: ps.fileType
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ps.excludeNsfw) {
|
||||||
|
query['_files.metadata.isSensitive'] = {
|
||||||
|
$ne: true
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.sinceId) {
|
if (ps.sinceId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user