2023-10-02 19:29:20 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
process.env.NODE_ENV = 'test';
|
2023-10-02 20:22:57 -05:00
|
|
|
process.env.FORCE_FOLLOW_REMOTE_USER_FOR_TESTING = 'true';
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
import * as assert from 'assert';
|
|
|
|
import { signup, api, post, react, startServer, waitFire, sleep } from '../utils.js';
|
|
|
|
import type { INestApplicationContext } from '@nestjs/common';
|
|
|
|
import type * as misskey from 'misskey-js';
|
|
|
|
|
|
|
|
describe('Timelines', () => {
|
|
|
|
let app: INestApplicationContext;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
app = await startServer();
|
|
|
|
}, 1000 * 60 * 2);
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await app.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Home TL', () => {
|
2023-10-02 19:38:32 -05:00
|
|
|
test('自分の visibility: followers なノートが含まれる', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
|
|
|
const aliceNote = await post(alice, { text: 'hi', visibility: 'followers' });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
|
|
|
|
assert.strictEqual(res.body.find((note: any) => note.id === aliceNote.id).text, 'hi');
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('フォローしているユーザーのノートが含まれる', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('フォローしているユーザーの visibility: followers なノートが含まれる', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'followers' });
|
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
assert.strictEqual(res.body.find((note: any) => note.id === bobNote.id).text, 'hi');
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('withReplies: false でフォローしているユーザーの他人への返信が含まれない', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('withReplies: true でフォローしているユーザーの他人への返信が含まれる', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
await api('/following/update', { userId: bob.id, withReplies: true }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('withReplies: true でフォローしているユーザーの他人へのDM返信が含まれない', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
await api('/following/update', { userId: bob.id, withReplies: true }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id, visibility: 'specified', visibleUserIds: [carolNote.id] });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('withReplies: true でフォローしているユーザーの他人の visibility: followers な投稿への返信が含まれない', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
await api('/following/update', { userId: bob.id, withReplies: true }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi', visibility: 'followers' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 20:36:10 -05:00
|
|
|
test('withReplies: true でフォローしているユーザーの行った別のフォローしているユーザーの visibility: followers な投稿への返信が含まれる', async () => {
|
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
await api('/following/create', { userId: carol.id }, alice);
|
|
|
|
await api('/following/update', { userId: bob.id, withReplies: true }, alice);
|
|
|
|
const carolNote = await post(carol, { text: 'hi', visibility: 'followers' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
|
2023-10-02 20:58:10 -05:00
|
|
|
assert.strictEqual(res.body.find((note: any) => note.id === carolNote.id).text, 'hi');
|
2023-10-02 20:36:10 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('withReplies: true でフォローしているユーザーの行った別のフォローしているユーザーの投稿への visibility: specified な返信が含まれない', async () => {
|
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
await api('/following/create', { userId: carol.id }, alice);
|
|
|
|
await api('/following/update', { userId: bob.id, withReplies: true }, alice);
|
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id, visibility: 'specified', visibleUserIds: [carolNote.id] });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('withReplies: false でフォローしているユーザーのそのユーザー自身への返信が含まれる', async () => {
|
2023-10-02 20:13:26 -05:00
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
2023-10-02 19:29:20 -05:00
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const bobNote1 = await post(bob, { text: 'hi' });
|
|
|
|
const bobNote2 = await post(bob, { text: 'hi', replyId: bobNote1.id });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote1.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote2.id), true);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('自分の他人への返信が含まれる', async () => {
|
2023-10-02 20:13:26 -05:00
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
2023-10-02 19:55:44 -05:00
|
|
|
const aliceNote = await post(alice, { text: 'hi', replyId: bobNote.id });
|
2023-10-02 19:29:20 -05:00
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === aliceNote.id), true);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('フォローしているユーザーの他人の投稿のリノートが含まれる', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { renoteId: carolNote.id });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('[withRenotes: false] フォローしているユーザーの他人の投稿のリノートが含まれない', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { renoteId: carolNote.id });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {
|
|
|
|
withRenotes: false,
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('[withRenotes: false] フォローしているユーザーの他人の投稿の引用が含まれる', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', renoteId: carolNote.id });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {
|
|
|
|
withRenotes: false,
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 20:36:10 -05:00
|
|
|
test('フォローしているユーザーの他人への visibility: specified なノートが含まれない', async () => {
|
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'specified', visibleUserIds: [carol.id] });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('フォローしているユーザーが行ったミュートしているユーザーのリノートが含まれない', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
await api('/mute/create', { userId: carol.id }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', renoteId: carolNote.id });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
test('withReplies: true でフォローしているユーザーが行ったミュートしているユーザーの投稿への返信が含まれない', async () => {
|
2023-10-02 19:29:20 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
await api('/following/update', { userId: bob.id, withReplies: true }, alice);
|
|
|
|
await api('/mute/create', { userId: carol.id }, alice);
|
2023-10-02 19:29:20 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
2023-10-02 19:29:20 -05:00
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
2023-10-02 20:13:26 -05:00
|
|
|
|
|
|
|
test('フォローしているリモートユーザーのノートが含まれる', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]);
|
|
|
|
|
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('フォローしているリモートユーザーの visibility: home なノートが含まれる', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]);
|
|
|
|
|
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'home' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
});
|
2023-10-02 19:29:20 -05:00
|
|
|
});
|
|
|
|
|
2023-10-02 19:38:32 -05:00
|
|
|
describe('Local TL', () => {
|
|
|
|
test('visibility: home なノートが含まれない', async () => {
|
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
|
|
|
const carolNote = await post(carol, { text: 'hi', visibility: 'home' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/local-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 20:13:26 -05:00
|
|
|
test('リモートユーザーのノートが含まれない', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]);
|
|
|
|
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/local-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
});
|
|
|
|
|
2023-10-02 20:22:57 -05:00
|
|
|
// 含まれても良いと思うけど実装が面倒なので含まれない
|
|
|
|
test('フォローしているユーザーの visibility: home なノートが含まれない', async () => {
|
2023-10-02 19:38:32 -05:00
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
|
|
|
await api('/following/create', {
|
|
|
|
userId: carol.id,
|
|
|
|
}, alice);
|
|
|
|
const carolNote = await post(carol, { text: 'hi', visibility: 'home' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/local-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
2023-10-02 20:22:57 -05:00
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
2023-10-02 19:38:32 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('ミュートしているユーザーのノートが含まれない', async () => {
|
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/mute/create', { userId: carol.id }, alice);
|
2023-10-02 19:38:32 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/local-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('フォローしているユーザーが行ったミュートしているユーザーのリノートが含まれない', async () => {
|
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
await api('/mute/create', { userId: carol.id }, alice);
|
2023-10-02 19:38:32 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', renoteId: carolNote.id });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/local-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('withReplies: true でフォローしているユーザーが行ったミュートしているユーザーの投稿への返信が含まれない', async () => {
|
|
|
|
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
|
|
|
|
2023-10-02 19:42:37 -05:00
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
await api('/following/update', { userId: bob.id, withReplies: true }, alice);
|
|
|
|
await api('/mute/create', { userId: carol.id }, alice);
|
2023-10-02 19:38:32 -05:00
|
|
|
const carolNote = await post(carol, { text: 'hi' });
|
|
|
|
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/local-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-10-02 20:13:26 -05:00
|
|
|
describe('Social TL', () => {
|
|
|
|
test('ローカルユーザーのノートが含まれる', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
|
|
|
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/hybrid-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('ローカルユーザーの visibility: home なノートが含まれない', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
|
|
|
|
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'home' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/hybrid-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('フォローしているローカルユーザーの visibility: home なノートが含まれる', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
|
|
|
|
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'home' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/hybrid-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('リモートユーザーのノートが含まれない', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]);
|
|
|
|
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/local-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('フォローしているリモートユーザーのノートが含まれる', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]);
|
|
|
|
|
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/hybrid-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('フォローしているリモートユーザーの visibility: home なノートが含まれる', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup({ host: 'example.com' })]);
|
|
|
|
|
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'home' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/hybrid-timeline', {}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-10-02 20:44:09 -05:00
|
|
|
describe('User List TL', () => {
|
|
|
|
test('リスインしているフォローしていないユーザーのノートが含まれる', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
|
|
|
|
|
|
|
const list = await api('/users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
|
|
|
await api('/users/lists/push', { listId: list.id, userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/user-list-timeline', { listId: list.id }, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
});
|
|
|
|
|
2023-10-02 20:58:10 -05:00
|
|
|
test('リスインしているフォローしていないユーザーの visibility: home なノートが含まれる', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
|
|
|
|
|
|
|
const list = await api('/users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
|
|
|
await api('/users/lists/push', { listId: list.id, userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'home' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/user-list-timeline', { listId: list.id }, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
});
|
|
|
|
|
2023-10-02 21:03:23 -05:00
|
|
|
/*
|
2023-10-02 20:44:09 -05:00
|
|
|
test('リスインしているフォローしていないユーザーの visibility: followers なノートが含まれない', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
|
|
|
|
|
|
|
const list = await api('/users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
|
|
|
await api('/users/lists/push', { listId: list.id, userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'followers' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/user-list-timeline', { listId: list.id }, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
|
|
|
});
|
2023-10-02 21:03:23 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
test('リスインしているフォローしていないユーザーの visibility: followers なノートが含まれるが隠される', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
|
|
|
|
|
|
|
const list = await api('/users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
|
|
|
await api('/users/lists/push', { listId: list.id, userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'followers' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/user-list-timeline', { listId: list.id }, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
assert.strictEqual(res.body.find((note: any) => note.id === bobNote.id).text, null);
|
|
|
|
});
|
2023-10-02 20:58:10 -05:00
|
|
|
|
|
|
|
test('リスインしているフォローしているユーザーの visibility: home なノートが含まれる', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
|
|
|
|
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
const list = await api('/users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
|
|
|
await api('/users/lists/push', { listId: list.id, userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'home' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/user-list-timeline', { listId: list.id }, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('リスインしているフォローしているユーザーの visibility: followers なノートが含まれる', async () => {
|
|
|
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
|
|
|
|
|
|
|
await api('/following/create', { userId: bob.id }, alice);
|
|
|
|
const list = await api('/users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
|
|
|
await api('/users/lists/push', { listId: list.id, userId: bob.id }, alice);
|
|
|
|
const bobNote = await post(bob, { text: 'hi', visibility: 'followers' });
|
|
|
|
|
|
|
|
await sleep(100); // redisに追加されるのを待つ
|
|
|
|
|
|
|
|
const res = await api('/notes/user-list-timeline', { listId: list.id }, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
|
|
|
assert.strictEqual(res.body.find((note: any) => note.id === bobNote.id).text, 'hi');
|
|
|
|
});
|
2023-10-02 20:44:09 -05:00
|
|
|
});
|
|
|
|
|
2023-10-02 19:29:20 -05:00
|
|
|
// TODO: リノートミュート済みユーザーのテスト
|
|
|
|
// TODO: withFilesのテスト
|
|
|
|
});
|