summaryrefslogtreecommitdiff
path: root/src/server/api
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2019-01-08 21:02:00 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-01-08 21:02:00 +0900
commit04e1e48f1746533609372311becdd6800b005f50 (patch)
tree7b81396e0907227c8af34688ad0262a2b20a472a /src/server/api
parent:art: (diff)
downloadsharkey-04e1e48f1746533609372311becdd6800b005f50.tar.gz
sharkey-04e1e48f1746533609372311becdd6800b005f50.tar.bz2
sharkey-04e1e48f1746533609372311becdd6800b005f50.zip
Hide invisible notes from timeline (#3852)
Diffstat (limited to 'src/server/api')
-rw-r--r--src/server/api/endpoints/notes/hybrid-timeline.ts21
-rw-r--r--src/server/api/endpoints/notes/search_by_tag.ts15
-rw-r--r--src/server/api/endpoints/notes/timeline.ts21
-rw-r--r--src/server/api/endpoints/notes/user-list-timeline.ts21
-rw-r--r--src/server/api/endpoints/users/notes.ts15
5 files changed, 85 insertions, 8 deletions
diff --git a/src/server/api/endpoints/notes/hybrid-timeline.ts b/src/server/api/endpoints/notes/hybrid-timeline.ts
index 4af182cb5c..7cf05cb9a8 100644
--- a/src/server/api/endpoints/notes/hybrid-timeline.ts
+++ b/src/server/api/endpoints/notes/hybrid-timeline.ts
@@ -135,13 +135,30 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
}]
});
+ const visibleQuery = user == null ? [{
+ visibility: { $in: [ 'public', 'home' ] }
+ }] : [{
+ visibility: { $in: [ 'public', 'home' ] }
+ }, {
+ // myself (for specified/private)
+ userId: user._id
+ }, {
+ // to me (for specified)
+ visibleUserIds: { $in: [ user._id ] }
+ }];
+
const query = {
$and: [{
deletedAt: null,
$or: [{
- // フォローしている人の投稿
- $or: followQuery
+ $and: [{
+ // フォローしている人の投稿
+ $or: followQuery
+ }, {
+ // visible for me
+ $or: visibleQuery
+ }]
}, {
// public only
visibility: 'public',
diff --git a/src/server/api/endpoints/notes/search_by_tag.ts b/src/server/api/endpoints/notes/search_by_tag.ts
index fcc33d14f3..db2f716497 100644
--- a/src/server/api/endpoints/notes/search_by_tag.ts
+++ b/src/server/api/endpoints/notes/search_by_tag.ts
@@ -103,6 +103,18 @@ export const meta = {
};
export default define(meta, (ps, me) => new Promise(async (res, rej) => {
+ const visibleQuery = me == null ? [{
+ visibility: { $in: [ 'public', 'home' ] }
+ }] : [{
+ visibility: { $in: [ 'public', 'home' ] }
+ }, {
+ // myself (for specified/private)
+ userId: me._id
+ }, {
+ // to me (for specified)
+ visibleUserIds: { $in: [ me._id ] }
+ }];
+
const q: any = {
$and: [ps.tag ? {
tagsLower: ps.tag.toLowerCase()
@@ -113,7 +125,8 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
}))
}))
}],
- deletedAt: { $exists: false }
+ deletedAt: { $exists: false },
+ $or: visibleQuery
};
const push = (x: any) => q.$and.push(x);
diff --git a/src/server/api/endpoints/notes/timeline.ts b/src/server/api/endpoints/notes/timeline.ts
index 3c970c03a1..5604cf291b 100644
--- a/src/server/api/endpoints/notes/timeline.ts
+++ b/src/server/api/endpoints/notes/timeline.ts
@@ -139,12 +139,29 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
}]
});
+ const visibleQuery = user == null ? [{
+ visibility: { $in: [ 'public', 'home' ] }
+ }] : [{
+ visibility: { $in: [ 'public', 'home' ] }
+ }, {
+ // myself (for specified/private)
+ userId: user._id
+ }, {
+ // to me (for specified)
+ visibleUserIds: { $in: [ user._id ] }
+ }];
+
const query = {
$and: [{
deletedAt: null,
- // フォローしている人の投稿
- $or: followQuery,
+ $and: [{
+ // フォローしている人の投稿
+ $or: followQuery
+ }, {
+ // visible for me
+ $or: visibleQuery
+ }],
// mute
userId: {
diff --git a/src/server/api/endpoints/notes/user-list-timeline.ts b/src/server/api/endpoints/notes/user-list-timeline.ts
index 156ffbbc32..eab3b9788a 100644
--- a/src/server/api/endpoints/notes/user-list-timeline.ts
+++ b/src/server/api/endpoints/notes/user-list-timeline.ts
@@ -146,12 +146,29 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
}]
}));
+ const visibleQuery = user == null ? [{
+ visibility: { $in: [ 'public', 'home' ] }
+ }] : [{
+ visibility: { $in: [ 'public', 'home' ] }
+ }, {
+ // myself (for specified/private)
+ userId: user._id
+ }, {
+ // to me (for specified)
+ visibleUserIds: { $in: [ user._id ] }
+ }];
+
const query = {
$and: [{
deletedAt: null,
- // リストに入っている人のタイムラインへの投稿
- $or: listQuery,
+ $and: [{
+ // リストに入っている人のタイムラインへの投稿
+ $or: listQuery
+ }, {
+ // visible for me
+ $or: visibleQuery
+ }],
// mute
userId: {
diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts
index ec2dab1290..6c336683ab 100644
--- a/src/server/api/endpoints/users/notes.ts
+++ b/src/server/api/endpoints/users/notes.ts
@@ -155,10 +155,23 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
//#region Construct query
const sort = { } as any;
+ const visibleQuery = me == null ? [{
+ visibility: { $in: [ 'public', 'home' ] }
+ }] : [{
+ visibility: { $in: [ 'public', 'home' ] }
+ }, {
+ // myself (for specified/private)
+ userId: me._id
+ }, {
+ // to me (for specified)
+ visibleUserIds: { $in: [ me._id ] }
+ }];
+
const query = {
$and: [ {} ],
deletedAt: null,
- userId: user._id
+ userId: user._id,
+ $or: visibleQuery
} as any;
if (ps.sinceId) {