mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 14:23:09 +02:00
Hide suspended users (#4075)
This commit is contained in:
parent
9bf9519b8f
commit
c7ebf6f990
12 changed files with 94 additions and 98 deletions
20
src/server/api/common/get-hide-users.ts
Normal file
20
src/server/api/common/get-hide-users.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import * as mongo from 'mongodb';
|
||||||
|
import Mute from '../../../models/mute';
|
||||||
|
import User, { IUser } from '../../../models/user';
|
||||||
|
import { unique } from '../../../prelude/array';
|
||||||
|
|
||||||
|
export async function getHideUserIds(me: IUser) {
|
||||||
|
return me ? await getHideUserIdsById(me._id) : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getHideUserIdsById(meId: mongo.ObjectID) {
|
||||||
|
const suspended = (await User.find({
|
||||||
|
isSuspended: true
|
||||||
|
})).map(user => user._id);
|
||||||
|
|
||||||
|
const muted = meId ? (await Mute.find({
|
||||||
|
muterId: meId
|
||||||
|
})).map(mute => mute.muteeId) : [];
|
||||||
|
|
||||||
|
return unique(suspended.concat(muted));
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||||
import Notification from '../../../../models/notification';
|
import Notification from '../../../../models/notification';
|
||||||
import Mute from '../../../../models/mute';
|
|
||||||
import { packMany } from '../../../../models/notification';
|
import { packMany } from '../../../../models/notification';
|
||||||
import { getFriendIds } from '../../common/get-friends';
|
import { getFriendIds } from '../../common/get-friends';
|
||||||
import read from '../../common/read-notification';
|
import read from '../../common/read-notification';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
|
import { getHideUserIds } from '../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -60,15 +60,13 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
return rej('cannot set sinceId and untilId');
|
return rej('cannot set sinceId and untilId');
|
||||||
}
|
}
|
||||||
|
|
||||||
const mute = await Mute.find({
|
const hideUserIds = await getHideUserIds(user);
|
||||||
muterId: user._id
|
|
||||||
});
|
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
notifieeId: user._id,
|
notifieeId: user._id,
|
||||||
$and: [{
|
$and: [{
|
||||||
notifierId: {
|
notifierId: {
|
||||||
$nin: mute.map(m => m.muteeId)
|
$nin: hideUserIds
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
} as any;
|
} as any;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||||
import Note from '../../../../models/note';
|
import Note from '../../../../models/note';
|
||||||
import Mute from '../../../../models/mute';
|
|
||||||
import { packMany } from '../../../../models/note';
|
import { packMany } from '../../../../models/note';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { countIf } from '../../../../prelude/array';
|
import { countIf } from '../../../../prelude/array';
|
||||||
import fetchMeta from '../../../../misc/fetch-meta';
|
import fetchMeta from '../../../../misc/fetch-meta';
|
||||||
|
import { getHideUserIds } from '../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -64,10 +64,8 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
return rej('only one of sinceId, untilId, sinceDate, untilDate can be specified');
|
return rej('only one of sinceId, untilId, sinceDate, untilDate can be specified');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ミュートしているユーザーを取得
|
// 隠すユーザーを取得
|
||||||
const mutedUserIds = user ? (await Mute.find({
|
const hideUserIds = await getHideUserIds(user);
|
||||||
muterId: user._id
|
|
||||||
})).map(m => m.muteeId) : null;
|
|
||||||
|
|
||||||
//#region Construct query
|
//#region Construct query
|
||||||
const sort = {
|
const sort = {
|
||||||
|
@ -83,17 +81,17 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
replyId: null
|
replyId: null
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
if (mutedUserIds && mutedUserIds.length > 0) {
|
if (hideUserIds && hideUserIds.length > 0) {
|
||||||
query.userId = {
|
query.userId = {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
};
|
};
|
||||||
|
|
||||||
query['_reply.userId'] = {
|
query['_reply.userId'] = {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
};
|
};
|
||||||
|
|
||||||
query['_renote.userId'] = {
|
query['_renote.userId'] = {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||||
import Note from '../../../../models/note';
|
import Note from '../../../../models/note';
|
||||||
import Mute from '../../../../models/mute';
|
|
||||||
import { getFriends } from '../../common/get-friends';
|
import { getFriends } from '../../common/get-friends';
|
||||||
import { packMany } from '../../../../models/note';
|
import { packMany } from '../../../../models/note';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { countIf } from '../../../../prelude/array';
|
import { countIf } from '../../../../prelude/array';
|
||||||
import fetchMeta from '../../../../misc/fetch-meta';
|
import fetchMeta from '../../../../misc/fetch-meta';
|
||||||
import activeUsersChart from '../../../../chart/active-users';
|
import activeUsersChart from '../../../../chart/active-users';
|
||||||
|
import { getHideUserIds } from '../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -103,15 +103,13 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
return rej('only one of sinceId, untilId, sinceDate, untilDate can be specified');
|
return rej('only one of sinceId, untilId, sinceDate, untilDate can be specified');
|
||||||
}
|
}
|
||||||
|
|
||||||
const [followings, mutedUserIds] = await Promise.all([
|
const [followings, hideUserIds] = await Promise.all([
|
||||||
// フォローを取得
|
// フォローを取得
|
||||||
// Fetch following
|
// Fetch following
|
||||||
getFriends(user._id, true, false),
|
getFriends(user._id, true, false),
|
||||||
|
|
||||||
// ミュートしているユーザーを取得
|
// 隠すユーザーを取得
|
||||||
Mute.find({
|
getHideUserIds(user)
|
||||||
muterId: user._id
|
|
||||||
}).then(ms => ms.map(m => m.muteeId))
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//#region Construct query
|
//#region Construct query
|
||||||
|
@ -175,15 +173,15 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
'_user.host': null
|
'_user.host': null
|
||||||
}],
|
}],
|
||||||
|
|
||||||
// mute
|
// hide
|
||||||
userId: {
|
userId: {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
'_reply.userId': {
|
'_reply.userId': {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
'_renote.userId': {
|
'_renote.userId': {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
} as any;
|
} as any;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||||
import Note from '../../../../models/note';
|
import Note from '../../../../models/note';
|
||||||
import Mute from '../../../../models/mute';
|
|
||||||
import { packMany } from '../../../../models/note';
|
import { packMany } from '../../../../models/note';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { countIf } from '../../../../prelude/array';
|
import { countIf } from '../../../../prelude/array';
|
||||||
import fetchMeta from '../../../../misc/fetch-meta';
|
import fetchMeta from '../../../../misc/fetch-meta';
|
||||||
import activeUsersChart from '../../../../chart/active-users';
|
import activeUsersChart from '../../../../chart/active-users';
|
||||||
|
import { getHideUserIds } from '../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -80,10 +80,8 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
return rej('only one of sinceId, untilId, sinceDate, untilDate can be specified');
|
return rej('only one of sinceId, untilId, sinceDate, untilDate can be specified');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ミュートしているユーザーを取得
|
// 隠すユーザーを取得
|
||||||
const mutedUserIds = user ? (await Mute.find({
|
const hideUserIds = await getHideUserIds(user);
|
||||||
muterId: user._id
|
|
||||||
})).map(m => m.muteeId) : null;
|
|
||||||
|
|
||||||
//#region Construct query
|
//#region Construct query
|
||||||
const sort = {
|
const sort = {
|
||||||
|
@ -103,17 +101,17 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
'_user.host': null
|
'_user.host': null
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
if (mutedUserIds && mutedUserIds.length > 0) {
|
if (hideUserIds && hideUserIds.length > 0) {
|
||||||
query.userId = {
|
query.userId = {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
};
|
};
|
||||||
|
|
||||||
query['_reply.userId'] = {
|
query['_reply.userId'] = {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
};
|
};
|
||||||
|
|
||||||
query['_renote.userId'] = {
|
query['_renote.userId'] = {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { getFriendIds, getFriends } from '../../common/get-friends';
|
||||||
import { packMany } from '../../../../models/note';
|
import { packMany } from '../../../../models/note';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import read from '../../../../services/note/read';
|
import read from '../../../../services/note/read';
|
||||||
import Mute from '../../../../models/mute';
|
import { getHideUserIds } from '../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -86,22 +86,20 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
}]
|
}]
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
// ミュートしているユーザーを取得
|
// 隠すユーザーを取得
|
||||||
const mutedUserIds = (await Mute.find({
|
const hideUserIds = await getHideUserIds(user);
|
||||||
muterId: user._id
|
|
||||||
})).map(m => m.muteeId);
|
|
||||||
|
|
||||||
if (mutedUserIds && mutedUserIds.length > 0) {
|
if (hideUserIds && hideUserIds.length > 0) {
|
||||||
query.userId = {
|
query.userId = {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
};
|
};
|
||||||
|
|
||||||
query['_reply.userId'] = {
|
query['_reply.userId'] = {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
};
|
};
|
||||||
|
|
||||||
query['_renote.userId'] = {
|
query['_renote.userId'] = {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import $ from 'cafy';
|
||||||
import Vote from '../../../../../models/poll-vote';
|
import Vote from '../../../../../models/poll-vote';
|
||||||
import Note, { pack } from '../../../../../models/note';
|
import Note, { pack } from '../../../../../models/note';
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import Mute from '../../../../../models/mute';
|
import { getHideUserIds } from '../../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -38,10 +38,8 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
const nin = votes && votes.length != 0 ? votes.map(v => v.noteId) : [];
|
const nin = votes && votes.length != 0 ? votes.map(v => v.noteId) : [];
|
||||||
|
|
||||||
// ミュートしているユーザーを取得
|
// 隠すユーザーを取得
|
||||||
const mutedUserIds = await Mute.find({
|
const hideUserIds = await getHideUserIds(user);
|
||||||
muterId: user._id
|
|
||||||
}).then(ms => ms.map(m => m.muteeId));
|
|
||||||
|
|
||||||
const notes = await Note
|
const notes = await Note
|
||||||
.find({
|
.find({
|
||||||
|
@ -51,7 +49,7 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
},
|
},
|
||||||
userId: {
|
userId: {
|
||||||
$ne: user._id,
|
$ne: user._id,
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
poll: {
|
poll: {
|
||||||
$exists: true,
|
$exists: true,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||||
import Note, { packMany } from '../../../../models/note';
|
import Note, { packMany } from '../../../../models/note';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import Mute from '../../../../models/mute';
|
|
||||||
import { getFriends } from '../../common/get-friends';
|
import { getFriends } from '../../common/get-friends';
|
||||||
|
import { getHideUserIds } from '../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -35,15 +35,13 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
const [followings, mutedUserIds] = await Promise.all([
|
const [followings, hideUserIds] = await Promise.all([
|
||||||
// フォローを取得
|
// フォローを取得
|
||||||
// Fetch following
|
// Fetch following
|
||||||
user ? getFriends(user._id) : [],
|
user ? getFriends(user._id) : [],
|
||||||
|
|
||||||
// ミュートしているユーザーを取得
|
// 隠すユーザーを取得
|
||||||
user ? (await Mute.find({
|
getHideUserIds(user)
|
||||||
muterId: user._id
|
|
||||||
})).map(m => m.muteeId) : null
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const visibleQuery = user == null ? [{
|
const visibleQuery = user == null ? [{
|
||||||
|
@ -75,9 +73,9 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
$or: visibleQuery
|
$or: visibleQuery
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
if (mutedUserIds && mutedUserIds.length > 0) {
|
if (hideUserIds && hideUserIds.length > 0) {
|
||||||
q['userId'] = {
|
q['userId'] = {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||||
import Note from '../../../../models/note';
|
import Note from '../../../../models/note';
|
||||||
import Mute from '../../../../models/mute';
|
|
||||||
import { getFriendIds } from '../../common/get-friends';
|
import { getFriendIds } from '../../common/get-friends';
|
||||||
import { packMany } from '../../../../models/note';
|
import { packMany } from '../../../../models/note';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
|
import { getHideUserIds } from '../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -143,47 +143,43 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me != null) {
|
if (me != null) {
|
||||||
const mutes = await Mute.find({
|
const hideUserIds = await getHideUserIds(me);
|
||||||
muterId: me._id,
|
|
||||||
deletedAt: { $exists: false }
|
|
||||||
});
|
|
||||||
const mutedUserIds = mutes.map(m => m.muteeId);
|
|
||||||
|
|
||||||
switch (ps.mute) {
|
switch (ps.mute) {
|
||||||
case 'mute_all':
|
case 'mute_all':
|
||||||
push({
|
push({
|
||||||
userId: {
|
userId: {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
'_reply.userId': {
|
'_reply.userId': {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
'_renote.userId': {
|
'_renote.userId': {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'mute_related':
|
case 'mute_related':
|
||||||
push({
|
push({
|
||||||
'_reply.userId': {
|
'_reply.userId': {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
'_renote.userId': {
|
'_renote.userId': {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'mute_direct':
|
case 'mute_direct':
|
||||||
push({
|
push({
|
||||||
userId: {
|
userId: {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'direct_only':
|
case 'direct_only':
|
||||||
push({
|
push({
|
||||||
userId: {
|
userId: {
|
||||||
$in: mutedUserIds
|
$in: hideUserIds
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -191,11 +187,11 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||||
push({
|
push({
|
||||||
$or: [{
|
$or: [{
|
||||||
'_reply.userId': {
|
'_reply.userId': {
|
||||||
$in: mutedUserIds
|
$in: hideUserIds
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'_renote.userId': {
|
'_renote.userId': {
|
||||||
$in: mutedUserIds
|
$in: hideUserIds
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
@ -204,15 +200,15 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||||
push({
|
push({
|
||||||
$or: [{
|
$or: [{
|
||||||
userId: {
|
userId: {
|
||||||
$in: mutedUserIds
|
$in: hideUserIds
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'_reply.userId': {
|
'_reply.userId': {
|
||||||
$in: mutedUserIds
|
$in: hideUserIds
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'_renote.userId': {
|
'_renote.userId': {
|
||||||
$in: mutedUserIds
|
$in: hideUserIds
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||||
import Note from '../../../../models/note';
|
import Note from '../../../../models/note';
|
||||||
import Mute from '../../../../models/mute';
|
|
||||||
import { getFriends } from '../../common/get-friends';
|
import { getFriends } from '../../common/get-friends';
|
||||||
import { packMany } from '../../../../models/note';
|
import { packMany } from '../../../../models/note';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { countIf } from '../../../../prelude/array';
|
import { countIf } from '../../../../prelude/array';
|
||||||
import activeUsersChart from '../../../../chart/active-users';
|
import activeUsersChart from '../../../../chart/active-users';
|
||||||
|
import { getHideUserIds } from '../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -101,15 +101,13 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [followings, mutedUserIds] = await Promise.all([
|
const [followings, hideUserIds] = await Promise.all([
|
||||||
// フォローを取得
|
// フォローを取得
|
||||||
// Fetch following
|
// Fetch following
|
||||||
getFriends(user._id),
|
getFriends(user._id),
|
||||||
|
|
||||||
// ミュートしているユーザーを取得
|
// 隠すユーザーを取得
|
||||||
Mute.find({
|
getHideUserIds(user)
|
||||||
muterId: user._id
|
|
||||||
}).then(ms => ms.map(m => m.muteeId))
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//#region Construct query
|
//#region Construct query
|
||||||
|
@ -164,13 +162,13 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// mute
|
// mute
|
||||||
userId: {
|
userId: {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
'_reply.userId': {
|
'_reply.userId': {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
'_renote.userId': {
|
'_renote.userId': {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
} as any;
|
} as any;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||||
import Note from '../../../../models/note';
|
import Note from '../../../../models/note';
|
||||||
import Mute from '../../../../models/mute';
|
|
||||||
import { packMany } from '../../../../models/note';
|
import { packMany } from '../../../../models/note';
|
||||||
import UserList from '../../../../models/user-list';
|
import UserList from '../../../../models/user-list';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { getFriends } from '../../common/get-friends';
|
import { getFriends } from '../../common/get-friends';
|
||||||
|
import { getHideUserIds } from '../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -102,7 +102,7 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
const [list, followings, mutedUserIds] = await Promise.all([
|
const [list, followings, hideUserIds] = await Promise.all([
|
||||||
// リストを取得
|
// リストを取得
|
||||||
// Fetch the list
|
// Fetch the list
|
||||||
UserList.findOne({
|
UserList.findOne({
|
||||||
|
@ -114,10 +114,8 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
// Fetch following
|
// Fetch following
|
||||||
getFriends(user._id, true, false),
|
getFriends(user._id, true, false),
|
||||||
|
|
||||||
// ミュートしているユーザーを取得
|
// 隠すユーザーを取得
|
||||||
Mute.find({
|
getHideUserIds(user)
|
||||||
muterId: user._id
|
|
||||||
}).then(ms => ms.map(m => m.muteeId))
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (list.userIds.length == 0) {
|
if (list.userIds.length == 0) {
|
||||||
|
@ -178,13 +176,13 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// mute
|
// mute
|
||||||
userId: {
|
userId: {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
'_reply.userId': {
|
'_reply.userId': {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
'_renote.userId': {
|
'_renote.userId': {
|
||||||
$nin: mutedUserIds
|
$nin: hideUserIds
|
||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
} as any;
|
} as any;
|
||||||
|
|
|
@ -2,12 +2,12 @@ const ms = require('ms');
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User, { pack, ILocalUser } from '../../../../models/user';
|
import User, { pack, ILocalUser } from '../../../../models/user';
|
||||||
import { getFriendIds } from '../../common/get-friends';
|
import { getFriendIds } from '../../common/get-friends';
|
||||||
import Mute from '../../../../models/mute';
|
|
||||||
import * as request from 'request-promise-native';
|
import * as request from 'request-promise-native';
|
||||||
import config from '../../../../config';
|
import config from '../../../../config';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import fetchMeta from '../../../../misc/fetch-meta';
|
import fetchMeta from '../../../../misc/fetch-meta';
|
||||||
import resolveUser from '../../../../remote/resolve-user';
|
import resolveUser from '../../../../remote/resolve-user';
|
||||||
|
import { getHideUserIds } from '../../common/get-hide-users';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -62,15 +62,13 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||||
// ID list of the user itself and other users who the user follows
|
// ID list of the user itself and other users who the user follows
|
||||||
const followingIds = await getFriendIds(me._id);
|
const followingIds = await getFriendIds(me._id);
|
||||||
|
|
||||||
// ミュートしているユーザーを取得
|
// 隠すユーザーを取得
|
||||||
const mutedUserIds = (await Mute.find({
|
const hideUserIds = await getHideUserIds(me);
|
||||||
muterId: me._id
|
|
||||||
})).map(m => m.muteeId);
|
|
||||||
|
|
||||||
const users = await User
|
const users = await User
|
||||||
.find({
|
.find({
|
||||||
_id: {
|
_id: {
|
||||||
$nin: followingIds.concat(mutedUserIds)
|
$nin: followingIds.concat(hideUserIds)
|
||||||
},
|
},
|
||||||
isLocked: { $ne: true },
|
isLocked: { $ne: true },
|
||||||
updatedAt: {
|
updatedAt: {
|
||||||
|
|
Loading…
Reference in a new issue