ハッシュタグタイムラインを実装

This commit is contained in:
syuilo
2018-09-17 09:00:20 +09:00
parent 433dbe179d
commit 109738ccb9
19 changed files with 555 additions and 92 deletions

View File

@ -13,12 +13,18 @@ export const meta = {
},
params: {
tag: $.str.note({
tag: $.str.optional.note({
desc: {
'ja-JP': 'タグ'
}
}),
query: $.arr($.arr($.str)).optional.note({
desc: {
'ja-JP': 'クエリ'
}
}),
includeUserIds: $.arr($.type(ID)).optional.note({
default: []
}),
@ -59,11 +65,9 @@ export const meta = {
}
}),
withFiles: $.bool.optional.nullable.note({
default: null,
withFiles: $.bool.optional.note({
desc: {
'ja-JP': 'ファイルが添付された投稿に限定するか否か'
'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します'
}
}),
@ -126,8 +130,14 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
}
const q: any = {
$and: [{
$and: [ps.tag ? {
tagsLower: ps.tag.toLowerCase()
} : {
$or: ps.query.map(tags => ({
$and: tags.map(t => ({
tagsLower: t.toLowerCase()
}))
}))
}],
deletedAt: { $exists: false }
};
@ -281,25 +291,10 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
const withFiles = ps.withFiles != null ? ps.withFiles : ps.media;
if (withFiles != null) {
if (withFiles) {
push({
fileIds: {
$exists: true,
$ne: null
}
});
} else {
push({
$or: [{
fileIds: {
$exists: false
}
}, {
fileIds: null
}]
});
}
if (withFiles) {
push({
fileIds: { $exists: true, $ne: [] }
});
}
if (ps.poll != null) {