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