2019-04-07 21:50:36 +09:00
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
2019-01-25 19:37:45 +09:00
|
|
|
import * as assert from 'assert';
|
2023-03-03 11:13:12 +09:00
|
|
|
import { Following } from '@/models/entities/Following.js';
|
|
|
|
import { connectStream, signup, api, post, startServer, initTestDb, waitFire } from '../utils.js';
|
|
|
|
import type { INestApplicationContext } from '@nestjs/common';
|
2019-01-23 12:15:27 +09:00
|
|
|
|
2019-04-07 21:50:36 +09:00
|
|
|
describe('Streaming', () => {
|
2023-03-12 20:57:01 +09:00
|
|
|
let app: INestApplicationContext;
|
2019-04-07 21:50:36 +09:00
|
|
|
let Followings: any;
|
2019-01-23 12:15:27 +09:00
|
|
|
|
2019-04-18 14:29:17 +09:00
|
|
|
const follow = async (follower: any, followee: any) => {
|
2019-04-07 21:50:36 +09:00
|
|
|
await Followings.save({
|
|
|
|
id: 'a',
|
|
|
|
createdAt: new Date(),
|
|
|
|
followerId: follower.id,
|
|
|
|
followeeId: followee.id,
|
|
|
|
followerHost: follower.host,
|
|
|
|
followerInbox: null,
|
|
|
|
followerSharedInbox: null,
|
|
|
|
followeeHost: followee.host,
|
|
|
|
followeeInbox: null,
|
2022-05-21 22:21:41 +09:00
|
|
|
followeeSharedInbox: null,
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
|
|
|
};
|
2019-01-23 12:15:27 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
describe('Streaming', () => {
|
|
|
|
// Local users
|
|
|
|
let ayano: any;
|
|
|
|
let kyoko: any;
|
|
|
|
let chitose: any;
|
2019-01-23 12:15:27 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
// Remote users
|
|
|
|
let akari: any;
|
|
|
|
let chinatsu: any;
|
2019-01-23 12:15:27 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
let kyokoNote: any;
|
|
|
|
let list: any;
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-09-18 03:27:08 +09:00
|
|
|
beforeAll(async () => {
|
2023-03-12 20:57:01 +09:00
|
|
|
app = await startServer();
|
2022-07-03 20:54:54 +09:00
|
|
|
const connection = await initTestDb(true);
|
|
|
|
Followings = connection.getRepository(Following);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
ayano = await signup({ username: 'ayano' });
|
|
|
|
kyoko = await signup({ username: 'kyoko' });
|
|
|
|
chitose = await signup({ username: 'chitose' });
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
akari = await signup({ username: 'akari', host: 'example.com' });
|
|
|
|
chinatsu = await signup({ username: 'chinatsu', host: 'example.com' });
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
kyokoNote = await post(kyoko, { text: 'foo' });
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
// Follow: ayano => kyoko
|
|
|
|
await api('following/create', { userId: kyoko.id }, ayano);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
// Follow: ayano => akari
|
|
|
|
await follow(ayano, akari);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
// List: chitose => ayano, kyoko
|
|
|
|
list = await api('users/lists/create', {
|
|
|
|
name: 'my list',
|
|
|
|
}, chitose).then(x => x.body);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
await api('users/lists/push', {
|
|
|
|
listId: list.id,
|
|
|
|
userId: ayano.id,
|
|
|
|
}, chitose);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
await api('users/lists/push', {
|
|
|
|
listId: list.id,
|
|
|
|
userId: kyoko.id,
|
|
|
|
}, chitose);
|
2023-03-03 11:13:12 +09:00
|
|
|
}, 1000 * 60 * 2);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-09-18 03:27:08 +09:00
|
|
|
afterAll(async () => {
|
2023-03-12 20:57:01 +09:00
|
|
|
await app.close();
|
2022-07-03 20:54:54 +09:00
|
|
|
});
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
describe('Events', () => {
|
2023-02-02 18:18:25 +09:00
|
|
|
test('mention event', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
kyoko, 'main', // kyoko:main
|
|
|
|
() => post(ayano, { text: 'foo @kyoko bar' }), // ayano mention => kyoko
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'mention' && msg.body.userId === ayano.id, // wait ayano
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('renote event', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
kyoko, 'main', // kyoko:main
|
|
|
|
() => post(ayano, { renoteId: kyokoNote.id }), // ayano renote
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'renote' && msg.body.renoteId === kyokoNote.id, // wait renote
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
2022-07-03 20:54:54 +09:00
|
|
|
});
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
describe('Home Timeline', () => {
|
2023-02-02 18:18:25 +09:00
|
|
|
test('自分の投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'homeTimeline', // ayano:Home
|
|
|
|
() => api('notes/create', { text: 'foo' }, ayano), // ayano posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.text === 'foo',
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
|
|
|
});
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしているユーザーの投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'homeTimeline', // ayano:home
|
|
|
|
() => api('notes/create', { text: 'foo' }, kyoko), // kyoko posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
2019-01-23 12:15:27 +09:00
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしていないユーザーの投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
kyoko, 'homeTimeline', // kyoko:home
|
|
|
|
() => api('notes/create', { text: 'foo' }, ayano), // ayano posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === ayano.id, // wait ayano
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしているユーザーのダイレクト投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'homeTimeline', // ayano:home
|
2022-09-18 03:27:08 +09:00
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [ayano.id] }, kyoko), // kyoko dm => ayano
|
|
|
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
2019-01-23 12:15:27 +09:00
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしているユーザーでも自分が指定されていないダイレクト投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'homeTimeline', // ayano:home
|
2022-09-18 03:27:08 +09:00
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [chitose.id] }, kyoko), // kyoko dm => chitose
|
|
|
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-01-23 12:15:27 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, false);
|
2019-01-23 12:15:27 +09:00
|
|
|
});
|
2022-07-03 20:54:54 +09:00
|
|
|
}); // Home
|
2019-01-25 15:56:49 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
describe('Local Timeline', () => {
|
2023-02-02 18:18:25 +09:00
|
|
|
test('自分の投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'localTimeline', // ayano:Local
|
|
|
|
() => api('notes/create', { text: 'foo' }, ayano), // ayano posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.text === 'foo',
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
|
|
|
});
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしていないローカルユーザーの投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'localTimeline', // ayano:Local
|
|
|
|
() => api('notes/create', { text: 'foo' }, chitose), // chitose posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === chitose.id, // wait chitose
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
2019-01-25 16:14:09 +09:00
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('リモートユーザーの投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'localTimeline', // ayano:Local
|
|
|
|
() => api('notes/create', { text: 'foo' }, chinatsu), // chinatsu posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === chinatsu.id, // wait chinatsu
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-01-25 16:14:09 +09:00
|
|
|
|
2019-04-07 21:50:36 +09:00
|
|
|
assert.strictEqual(fired, false);
|
2019-01-25 16:14:09 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしてたとしてもリモートユーザーの投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'localTimeline', // ayano:Local
|
|
|
|
() => api('notes/create', { text: 'foo' }, akari), // akari posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === akari.id, // wait akari
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
|
|
|
});
|
2019-01-25 16:14:09 +09:00
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('ホーム指定の投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'localTimeline', // ayano:Local
|
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'home' }, kyoko), // kyoko home posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
2019-01-25 16:14:09 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしているローカルユーザーのダイレクト投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'localTimeline', // ayano:Local
|
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [ayano.id] }, kyoko), // kyoko DM => ayano
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2020-01-09 17:29:03 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしていないローカルユーザーのフォロワー宛て投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'localTimeline', // ayano:Local
|
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'followers' }, chitose),
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === chitose.id, // wait chitose
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
|
|
|
});
|
2022-07-03 20:54:54 +09:00
|
|
|
});
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
describe('Hybrid Timeline', () => {
|
2023-02-02 18:18:25 +09:00
|
|
|
test('自分の投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'hybridTimeline', // ayano:Hybrid
|
|
|
|
() => api('notes/create', { text: 'foo' }, ayano), // ayano posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.text === 'foo',
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしていないローカルユーザーの投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'hybridTimeline', // ayano:Hybrid
|
|
|
|
() => api('notes/create', { text: 'foo' }, chitose), // chitose posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === chitose.id, // wait chitose
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしているリモートユーザーの投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'hybridTimeline', // ayano:Hybrid
|
|
|
|
() => api('notes/create', { text: 'foo' }, akari), // akari posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === akari.id, // wait akari
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしていないリモートユーザーの投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'hybridTimeline', // ayano:Hybrid
|
|
|
|
() => api('notes/create', { text: 'foo' }, chinatsu), // chinatsu posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === chinatsu.id, // wait chinatsu
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしているユーザーのダイレクト投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'hybridTimeline', // ayano:Hybrid
|
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [ayano.id] }, kyoko),
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-18 14:39:49 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-18 14:39:49 +09:00
|
|
|
});
|
2019-04-18 14:34:47 +09:00
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしているユーザーのホーム投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'hybridTimeline', // ayano:Hybrid
|
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'home' }, kyoko),
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-18 14:34:47 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-18 14:34:47 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしていないローカルユーザーのホーム投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'hybridTimeline', // ayano:Hybrid
|
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'home' }, chitose),
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === chitose.id,
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-18 14:34:47 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしていないローカルユーザーのフォロワー宛て投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'hybridTimeline', // ayano:Hybrid
|
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'followers' }, chitose),
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === chitose.id,
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
|
|
|
});
|
2022-07-03 20:54:54 +09:00
|
|
|
});
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
describe('Global Timeline', () => {
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしていないローカルユーザーの投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'globalTimeline', // ayano:Global
|
|
|
|
() => api('notes/create', { text: 'foo' }, chitose), // chitose posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === chitose.id, // wait chitose
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
2019-04-23 02:50:59 +09:00
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('フォローしていないリモートユーザーの投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'globalTimeline', // ayano:Global
|
|
|
|
() => api('notes/create', { text: 'foo' }, chinatsu), // chinatsu posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === chinatsu.id, // wait chinatsu
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-23 02:50:59 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-23 02:50:59 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('ホーム投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
ayano, 'globalTimeline', // ayano:Global
|
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'home' }, kyoko), // kyoko posts
|
2022-09-18 03:27:08 +09:00
|
|
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-23 02:50:59 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
2022-07-03 20:54:54 +09:00
|
|
|
});
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
describe('UserList Timeline', () => {
|
2023-02-02 18:18:25 +09:00
|
|
|
test('リストに入れているユーザーの投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
chitose, 'userList',
|
|
|
|
() => api('notes/create', { text: 'foo' }, ayano),
|
|
|
|
msg => msg.type === 'note' && msg.body.userId === ayano.id,
|
2022-09-18 03:27:08 +09:00
|
|
|
{ listId: list.id },
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('リストに入れていないユーザーの投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
chitose, 'userList',
|
|
|
|
() => api('notes/create', { text: 'foo' }, chinatsu),
|
|
|
|
msg => msg.type === 'note' && msg.body.userId === chinatsu.id,
|
2022-09-18 03:27:08 +09:00
|
|
|
{ listId: list.id },
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
|
|
|
});
|
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
// #4471
|
2023-02-02 18:18:25 +09:00
|
|
|
test('リストに入れているユーザーのダイレクト投稿が流れる', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
chitose, 'userList',
|
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'specified', visibleUserIds: [chitose.id] }, ayano),
|
|
|
|
msg => msg.type === 'note' && msg.body.userId === ayano.id,
|
2022-09-18 03:27:08 +09:00
|
|
|
{ listId: list.id },
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.strictEqual(fired, true);
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
// #4335
|
2023-02-02 18:18:25 +09:00
|
|
|
test('リストに入れているがフォローはしてないユーザーのフォロワー宛て投稿は流れない', async () => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const fired = await waitFire(
|
|
|
|
chitose, 'userList',
|
|
|
|
() => api('notes/create', { text: 'foo', visibility: 'followers' }, kyoko),
|
|
|
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id,
|
2022-09-18 03:27:08 +09:00
|
|
|
{ listId: list.id },
|
2022-07-03 20:54:54 +09:00
|
|
|
);
|
2019-04-07 21:50:36 +09:00
|
|
|
|
|
|
|
assert.strictEqual(fired, false);
|
2022-07-03 20:54:54 +09:00
|
|
|
});
|
|
|
|
});
|
2019-04-07 21:50:36 +09:00
|
|
|
|
2022-07-03 20:54:54 +09:00
|
|
|
describe('Hashtag Timeline', () => {
|
2023-02-02 18:18:25 +09:00
|
|
|
test('指定したハッシュタグの投稿が流れる', () => new Promise<void>(async done => {
|
2022-07-03 20:54:54 +09:00
|
|
|
const ws = await connectStream(chitose, 'hashtag', ({ type, body }) => {
|
2022-09-18 03:27:08 +09:00
|
|
|
if (type === 'note') {
|
2022-07-03 20:54:54 +09:00
|
|
|
assert.deepStrictEqual(body.text, '#foo');
|
|
|
|
ws.close();
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
q: [
|
|
|
|
['foo'],
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
post(chitose, {
|
|
|
|
text: '#foo',
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
2023-03-03 11:13:12 +09:00
|
|
|
// XXX: QueryFailedError: duplicate key value violates unique constraint "IDX_347fec870eafea7b26c8a73bac"
|
|
|
|
|
|
|
|
// test('指定したハッシュタグの投稿が流れる (AND)', () => new Promise<void>(async done => {
|
|
|
|
// let fooCount = 0;
|
|
|
|
// let barCount = 0;
|
|
|
|
// let fooBarCount = 0;
|
|
|
|
|
|
|
|
// const ws = await connectStream(chitose, 'hashtag', ({ type, body }) => {
|
|
|
|
// if (type === 'note') {
|
|
|
|
// if (body.text === '#foo') fooCount++;
|
|
|
|
// if (body.text === '#bar') barCount++;
|
|
|
|
// if (body.text === '#foo #bar') fooBarCount++;
|
|
|
|
// }
|
|
|
|
// }, {
|
|
|
|
// q: [
|
|
|
|
// ['foo', 'bar'],
|
|
|
|
// ],
|
|
|
|
// });
|
|
|
|
|
|
|
|
// post(chitose, {
|
|
|
|
// text: '#foo',
|
|
|
|
// });
|
|
|
|
|
|
|
|
// post(chitose, {
|
|
|
|
// text: '#bar',
|
|
|
|
// });
|
|
|
|
|
|
|
|
// post(chitose, {
|
|
|
|
// text: '#foo #bar',
|
|
|
|
// });
|
|
|
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
// assert.strictEqual(fooCount, 0);
|
|
|
|
// assert.strictEqual(barCount, 0);
|
|
|
|
// assert.strictEqual(fooBarCount, 1);
|
|
|
|
// ws.close();
|
|
|
|
// done();
|
|
|
|
// }, 3000);
|
|
|
|
// }));
|
2022-07-03 20:54:54 +09:00
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('指定したハッシュタグの投稿が流れる (OR)', () => new Promise<void>(async done => {
|
2022-07-03 20:54:54 +09:00
|
|
|
let fooCount = 0;
|
|
|
|
let barCount = 0;
|
|
|
|
let fooBarCount = 0;
|
|
|
|
let piyoCount = 0;
|
|
|
|
|
|
|
|
const ws = await connectStream(chitose, 'hashtag', ({ type, body }) => {
|
2022-09-18 03:27:08 +09:00
|
|
|
if (type === 'note') {
|
2022-07-03 20:54:54 +09:00
|
|
|
if (body.text === '#foo') fooCount++;
|
|
|
|
if (body.text === '#bar') barCount++;
|
|
|
|
if (body.text === '#foo #bar') fooBarCount++;
|
|
|
|
if (body.text === '#piyo') piyoCount++;
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
q: [
|
|
|
|
['foo'],
|
|
|
|
['bar'],
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
post(chitose, {
|
|
|
|
text: '#foo',
|
|
|
|
});
|
|
|
|
|
|
|
|
post(chitose, {
|
|
|
|
text: '#bar',
|
|
|
|
});
|
|
|
|
|
|
|
|
post(chitose, {
|
|
|
|
text: '#foo #bar',
|
|
|
|
});
|
|
|
|
|
|
|
|
post(chitose, {
|
|
|
|
text: '#piyo',
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
assert.strictEqual(fooCount, 1);
|
|
|
|
assert.strictEqual(barCount, 1);
|
|
|
|
assert.strictEqual(fooBarCount, 1);
|
|
|
|
assert.strictEqual(piyoCount, 0);
|
|
|
|
ws.close();
|
|
|
|
done();
|
|
|
|
}, 3000);
|
|
|
|
}));
|
|
|
|
|
2023-02-02 18:18:25 +09:00
|
|
|
test('指定したハッシュタグの投稿が流れる (AND + OR)', () => new Promise<void>(async done => {
|
2022-07-03 20:54:54 +09:00
|
|
|
let fooCount = 0;
|
|
|
|
let barCount = 0;
|
|
|
|
let fooBarCount = 0;
|
|
|
|
let piyoCount = 0;
|
|
|
|
let waaaCount = 0;
|
|
|
|
|
|
|
|
const ws = await connectStream(chitose, 'hashtag', ({ type, body }) => {
|
2022-09-18 03:27:08 +09:00
|
|
|
if (type === 'note') {
|
2022-07-03 20:54:54 +09:00
|
|
|
if (body.text === '#foo') fooCount++;
|
|
|
|
if (body.text === '#bar') barCount++;
|
|
|
|
if (body.text === '#foo #bar') fooBarCount++;
|
|
|
|
if (body.text === '#piyo') piyoCount++;
|
|
|
|
if (body.text === '#waaa') waaaCount++;
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
q: [
|
|
|
|
['foo', 'bar'],
|
|
|
|
['piyo'],
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
post(chitose, {
|
|
|
|
text: '#foo',
|
|
|
|
});
|
|
|
|
|
|
|
|
post(chitose, {
|
|
|
|
text: '#bar',
|
|
|
|
});
|
|
|
|
|
|
|
|
post(chitose, {
|
|
|
|
text: '#foo #bar',
|
|
|
|
});
|
|
|
|
|
|
|
|
post(chitose, {
|
|
|
|
text: '#piyo',
|
|
|
|
});
|
|
|
|
|
|
|
|
post(chitose, {
|
|
|
|
text: '#waaa',
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
assert.strictEqual(fooCount, 0);
|
|
|
|
assert.strictEqual(barCount, 0);
|
|
|
|
assert.strictEqual(fooBarCount, 1);
|
|
|
|
assert.strictEqual(piyoCount, 1);
|
|
|
|
assert.strictEqual(waaaCount, 0);
|
|
|
|
ws.close();
|
|
|
|
done();
|
|
|
|
}, 3000);
|
|
|
|
}));
|
|
|
|
});
|
2019-04-07 21:50:36 +09:00
|
|
|
});
|
2019-01-23 12:15:27 +09:00
|
|
|
});
|