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