From 8533663b26b8310065daba99b9c01614de19bd3f Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 19 Oct 2018 09:20:11 +0900 Subject: [PATCH] :v: --- .../views/pages/deck/deck.user-column.vue | 12 ++++++++++-- src/server/api/endpoints/users/notes.ts | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/client/app/desktop/views/pages/deck/deck.user-column.vue b/src/client/app/desktop/views/pages/deck/deck.user-column.vue index 7621ac5edb..6804dd97f1 100644 --- a/src/client/app/desktop/views/pages/deck/deck.user-column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.user-column.vue @@ -41,6 +41,7 @@ import parseAcct from '../../../../../../misc/acct/parse'; import XColumn from './deck.column.vue'; import XNotes from './deck.notes.vue'; import XNote from '../../components/note.vue'; +import { concat } from '../../../../../../prelude/array'; const fetchLimit = 10; @@ -93,17 +94,24 @@ export default Vue.extend({ (this.$refs.timeline as any).init(() => this.initTl()); }); + const image = [ + 'image/jpeg', + 'image/png', + 'image/gif' + ]; + (this as any).api('users/notes', { userId: this.user.id, - withFiles: true, + fileType: image, limit: 9 }).then(notes => { notes.forEach(note => { note.files.forEach(file => { file._note = note; - if (this.images.length < 9) this.images.push(file); }); }); + const files = concat(notes.map((n: any): any[] => n.files)); + this.images = files.filter(f => image.includes(f.type)).slice(0, 6); }); }); }, diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts index 002ddf23e5..0b2fc06b04 100644 --- a/src/server/api/endpoints/users/notes.ts +++ b/src/server/api/endpoints/users/notes.ts @@ -99,6 +99,12 @@ export const meta = { 'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します (このパラメータは廃止予定です。代わりに withFiles を使ってください。)' } }), + + fileType: $.arr($.str).optional.note({ + desc: { + 'ja-JP': '指定された種類のファイルが添付された投稿のみを取得します' + } + }), } }; @@ -137,7 +143,8 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => const query = { deletedAt: null, - userId: user._id + userId: user._id, + visibility: { $in: ['public', 'home'] } } as any; if (ps.sinceId) { @@ -172,6 +179,14 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => $ne: [] }; } + + if (ps.fileType) { + query.fileIds = { $exists: true, $ne: [] }; + + query['_files.contentType'] = { + $in: ps.fileType + }; + } //#endregion // Issue query