notes/local-timeline と notes/global-timeline のサインインを不要に

This commit is contained in:
syuilo 2018-05-28 21:59:57 +09:00
parent 06e77a4f16
commit 43eb8bd99b
3 changed files with 36 additions and 29 deletions

View File

@ -515,7 +515,6 @@ const endpoints: Endpoint[] = [
}, },
{ {
name: 'notes/local-timeline', name: 'notes/local-timeline',
withCredential: true,
limit: { limit: {
duration: ms('10minutes'), duration: ms('10minutes'),
max: 100 max: 100
@ -523,7 +522,6 @@ const endpoints: Endpoint[] = [
}, },
{ {
name: 'notes/global-timeline', name: 'notes/global-timeline',
withCredential: true,
limit: { limit: {
duration: ms('10minutes'), duration: ms('10minutes'),
max: 100 max: 100

View File

@ -9,7 +9,7 @@ import { pack } from '../../../../models/note';
/** /**
* Get timeline of global * Get timeline of global
*/ */
module.exports = async (params, user, app) => { module.exports = async (params, user) => {
// Get 'limit' parameter // Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit); const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param'; if (limitErr) throw 'invalid limit param';
@ -36,9 +36,9 @@ module.exports = async (params, user, app) => {
} }
// ミュートしているユーザーを取得 // ミュートしているユーザーを取得
const mutedUserIds = (await Mute.find({ const mutedUserIds = user ? (await Mute.find({
muterId: user._id muterId: user._id
})).map(m => m.muteeId); })).map(m => m.muteeId) : null;
//#region Construct query //#region Construct query
const sort = { const sort = {
@ -46,18 +46,24 @@ module.exports = async (params, user, app) => {
}; };
const query = { const query = {
// mute // public only
userId: { visibility: 'public'
$nin: mutedUserIds
},
'_reply.userId': {
$nin: mutedUserIds
},
'_renote.userId': {
$nin: mutedUserIds
}
} as any; } as any;
if (mutedUserIds && mutedUserIds.length > 0) {
query.userId = {
$nin: mutedUserIds
};
query['_reply.userId'] = {
$nin: mutedUserIds
};
query['_renote.userId'] = {
$nin: mutedUserIds
};
}
if (sinceId) { if (sinceId) {
sort._id = 1; sort._id = 1;
query._id = { query._id = {

View File

@ -9,7 +9,7 @@ import { pack } from '../../../../models/note';
/** /**
* Get timeline of local * Get timeline of local
*/ */
module.exports = async (params, user, app) => { module.exports = async (params, user) => {
// Get 'limit' parameter // Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit); const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param'; if (limitErr) throw 'invalid limit param';
@ -36,9 +36,9 @@ module.exports = async (params, user, app) => {
} }
// ミュートしているユーザーを取得 // ミュートしているユーザーを取得
const mutedUserIds = (await Mute.find({ const mutedUserIds = user ? (await Mute.find({
muterId: user._id muterId: user._id
})).map(m => m.muteeId); })).map(m => m.muteeId) : null;
//#region Construct query //#region Construct query
const sort = { const sort = {
@ -46,17 +46,6 @@ module.exports = async (params, user, app) => {
}; };
const query = { const query = {
// mute
userId: {
$nin: mutedUserIds
},
'_reply.userId': {
$nin: mutedUserIds
},
'_renote.userId': {
$nin: mutedUserIds
},
// public only // public only
visibility: 'public', visibility: 'public',
@ -64,6 +53,20 @@ module.exports = async (params, user, app) => {
'_user.host': null '_user.host': null
} as any; } as any;
if (mutedUserIds && mutedUserIds.length > 0) {
query.userId = {
$nin: mutedUserIds
};
query['_reply.userId'] = {
$nin: mutedUserIds
};
query['_renote.userId'] = {
$nin: mutedUserIds
};
}
if (sinceId) { if (sinceId) {
sort._id = 1; sort._id = 1;
query._id = { query._id = {