summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-09-17 09:00:20 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-09-17 09:00:20 +0900
commit109738ccb9ef8c203685e6f4bc31986ac2a17046 (patch)
treef91e8bb9c9ec445a10b018a934c88ebbdfeb8db1 /src/server/api/endpoints
parent8.44.1 (diff)
downloadsharkey-109738ccb9ef8c203685e6f4bc31986ac2a17046.tar.gz
sharkey-109738ccb9ef8c203685e6f4bc31986ac2a17046.tar.bz2
sharkey-109738ccb9ef8c203685e6f4bc31986ac2a17046.zip
ハッシュタグタイムラインを実装
Diffstat (limited to 'src/server/api/endpoints')
-rw-r--r--src/server/api/endpoints/notes/search_by_tag.ts45
1 files changed, 20 insertions, 25 deletions
diff --git a/src/server/api/endpoints/notes/search_by_tag.ts b/src/server/api/endpoints/notes/search_by_tag.ts
index 11bfe34724..7beb97aec6 100644
--- a/src/server/api/endpoints/notes/search_by_tag.ts
+++ b/src/server/api/endpoints/notes/search_by_tag.ts
@@ -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) {