cherry pick

This commit is contained in:
tamaina 2025-07-16 22:18:11 +09:00
parent 5164a94e96
commit eee0aba8af
1 changed files with 229 additions and 60 deletions

View File

@ -9,9 +9,9 @@
import * as assert from 'assert'; import * as assert from 'assert';
import { setTimeout } from 'node:timers/promises'; import { setTimeout } from 'node:timers/promises';
import { Redis } from 'ioredis'; import { Redis } from 'ioredis';
import { api, post, randomString, sendEnvUpdateRequest, signup, uploadUrl, role } from '../utils.js'; import { SignupResponse, Note, UserList } from 'misskey-js/entities.js';
import { api, post, randomString, sendEnvUpdateRequest, signup, uploadUrl } from '../utils.js';
import { loadConfig } from '@/config.js'; import { loadConfig } from '@/config.js';
import { SignupResponse, Role } from 'misskey-js/entities.js';
function genHost() { function genHost() {
return randomString() + '.example.com'; return randomString() + '.example.com';
@ -653,27 +653,87 @@ describe('Timelines', () => {
assert.strictEqual(await redisForTimelines.exists(`list:homeTimeline:${bob.id}`), 0); assert.strictEqual(await redisForTimelines.exists(`list:homeTimeline:${bob.id}`), 0);
}); });
test('凍結: 凍結後に凍結されたユーザーのノートは見えなくなる', async () => { describe('凍結', () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]); let alice: SignupResponse, bob: SignupResponse, carol: SignupResponse;
let aliceNote: Note, bobNote: Note, carolNote: Note;
beforeAll(async () => {
[alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
await api('following/create', { userId: bob.id }, alice); await api('following/create', { userId: bob.id }, alice);
await api('following/create', { userId: carol.id }, alice); await api('following/create', { userId: carol.id }, alice);
const aliceNote = await post(alice, { text: 'hi' }); aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'yo' }); bobNote = await post(bob, { text: 'yo' });
const carolNote = await post(carol, { text: 'kon\'nichiwa' }); carolNote = await post(carol, { text: 'kon\'nichiwa' });
await waitForPushToTl(); await waitForPushToTl();
await api('admin/suspend-user', { userId: carol.id }, root); await api('admin/suspend-user', { userId: carol.id }, root);
await setTimeout(100);
});
await setTimeout(250); test('凍結後に凍結されたユーザーのノートは見えなくなる', async () => {
const res = await api('notes/timeline', { limit: 100 }, alice); const res = await api('notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.length, 2); assert.strictEqual(res.body.length, 2);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true); assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some(note => note.id === bobNote.id), true); assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), false); assert.strictEqual(res.body.some(note => note.id === carolNote.id), false);
}); });
test('凍結解除後に凍結されていたユーザーのノートは見えるようになる', async () => {
await api('admin/unsuspend-user', { userId: carol.id }, root);
await setTimeout(100);
const res = await api('notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.length, 3);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), true);
assert.strictEqual(res.body.find(note => note.id === carolNote.id)?.text, 'kon\'nichiwa');
});
});
describe('凍結(リモート)', () => {
let alice: SignupResponse, bob: SignupResponse, carol: SignupResponse;
let aliceNote: Note, bobNote: Note, carolNote: Note;
beforeAll(async () => {
[alice, bob, carol] = await Promise.all([signup(), signup({ host: genHost() }), signup({ host: genHost() })]);
await sendEnvUpdateRequest({ key: 'FORCE_FOLLOW_REMOTE_USER_FOR_TESTING', value: 'true' });
await api('following/create', { userId: bob.id }, alice);
await api('following/create', { userId: carol.id }, alice);
aliceNote = await post(alice, { text: 'hi' });
bobNote = await post(bob, { text: 'yo' });
carolNote = await post(carol, { text: 'kon\'nichiwa' });
await waitForPushToTl();
await api('admin/suspend-user', { userId: carol.id }, root);
await setTimeout(100);
});
test('凍結後に凍結されたユーザーのノートは見えなくなる', async () => {
const res = await api('notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.length, 2);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), false);
});
test('凍結解除後に凍結されていたユーザーのノートは見えるようになる', async () => {
await api('admin/unsuspend-user', { userId: carol.id }, root);
await setTimeout(100);
const res = await api('notes/timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.length, 3);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), true);
});
});
}); });
describe('Local TL', () => { describe('Local TL', () => {
@ -911,26 +971,43 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some(note => note.id === bobNote2.id), true); assert.strictEqual(res.body.some(note => note.id === bobNote2.id), true);
}, 1000 * 10); }, 1000 * 10);
test('凍結: 凍結後に凍結されたユーザーのノートは見えなくなる', async () => { describe('凍結', () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]); let alice: SignupResponse, bob: SignupResponse, carol: SignupResponse;
let aliceNote: Note, bobNote: Note, carolNote: Note;
await api('following/create', { userId: bob.id }, alice); beforeAll(async () => {
await api('following/create', { userId: carol.id }, alice); [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'yo' }); aliceNote = await post(alice, { text: 'hi' });
const carolNote = await post(carol, { text: 'kon\'nichiwa' }); bobNote = await post(bob, { text: 'yo' });
carolNote = await post(carol, { text: 'kon\'nichiwa' });
await waitForPushToTl(); await waitForPushToTl();
});
test('凍結後に凍結されたユーザーのノートは見えなくなる', async () => {
await api('admin/suspend-user', { userId: carol.id }, root); await api('admin/suspend-user', { userId: carol.id }, root);
await setTimeout(100);
await setTimeout(250);
const res = await api('notes/local-timeline', { limit: 100 }, alice); const res = await api('notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true); assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some(note => note.id === bobNote.id), true); assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), false); assert.strictEqual(res.body.some(note => note.id === carolNote.id), false);
}); });
test('凍結解除後に凍結されていたユーザーのノートは見えるようになる', async () => {
await api('admin/unsuspend-user', { userId: carol.id }, root);
await setTimeout(100);
const res = await api('notes/local-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), true);
assert.strictEqual(res.body.find(note => note.id === carolNote.id)?.text, 'kon\'nichiwa');
});
});
}); });
describe('Social TL', () => { describe('Social TL', () => {
@ -1151,25 +1228,97 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some(note => note.id === bobNote2.id), true); assert.strictEqual(res.body.some(note => note.id === bobNote2.id), true);
}, 1000 * 10); }, 1000 * 10);
test('凍結: 凍結後に凍結されたユーザーのノートは見えなくなる', async () => { describe('凍結', () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]); /*
* bob = ()
* carol = ()
* dave = ()
*/
let alice: SignupResponse, bob: SignupResponse, carol: SignupResponse, dave: SignupResponse;
let aliceNote: Note, bobNote: Note, carolNote: Note, daveNote: Note;
await api('following/create', { userId: bob.id }, alice); beforeAll(async () => {
await api('following/create', { userId: carol.id }, alice); [alice, bob, carol, dave] = await Promise.all([signup(), signup(), signup(), signup()]);
const aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'yo' }); await api('following/create', { userId: dave.id }, alice);
const carolNote = await post(carol, { text: 'kon\'nichiwa' }); aliceNote = await post(alice, { text: 'hi' });
bobNote = await post(bob, { text: 'yo' });
carolNote = await post(carol, { text: 'kon\'nichiwa' });
daveNote = await post(dave, { text: 'hello' });
await waitForPushToTl(); await waitForPushToTl();
await api('admin/suspend-user', { userId: carol.id }, root); await api('admin/suspend-user', { userId: carol.id }, root);
await api('admin/suspend-user', { userId: dave.id }, root);
await setTimeout(250); await setTimeout(250);
});
test('凍結後に凍結されたユーザーのノートは見えなくなる', async () => {
const res = await api('notes/hybrid-timeline', { limit: 100 }, alice); const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true); assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some(note => note.id === bobNote.id), true); assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), false); assert.strictEqual(res.body.some(note => note.id === carolNote.id), false);
assert.strictEqual(res.body.some(note => note.id === daveNote.id), false);
});
test('凍結解除後に凍結されていたユーザーのノートは見えるようになる', async () => {
await api('admin/unsuspend-user', { userId: carol.id }, root);
await api('admin/unsuspend-user', { userId: dave.id }, root);
await setTimeout(250);
const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), true);
assert.strictEqual(res.body.some(note => note.id === daveNote.id), true);
});
});
describe('凍結 (リモート)', () => {
/*
* carol = ()
* elle = ()
*/
let alice: SignupResponse, carol: SignupResponse, elle: SignupResponse;
let aliceNote: Note, carolNote: Note, elleNote: Note;
beforeAll(async () => {
[alice, carol, elle] = await Promise.all([signup(), signup({ host: genHost() }), signup({ host: genHost() })]);
await sendEnvUpdateRequest({ key: 'FORCE_FOLLOW_REMOTE_USER_FOR_TESTING', value: 'true' });
await api('following/create', { userId: elle.id }, alice);
aliceNote = await post(alice, { text: 'hi' });
carolNote = await post(carol, { text: 'kon\'nichiwa' });
elleNote = await post(elle, { text: 'hi there' });
await waitForPushToTl();
await api('admin/suspend-user', { userId: carol.id }, root);
await api('admin/suspend-user', { userId: elle.id }, root);
await setTimeout(250);
});
test('凍結後に凍結されたユーザーのノートは見えなくなる', async () => {
const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), false);
assert.strictEqual(res.body.some(note => note.id === elleNote.id), false);
});
test('凍結解除後に凍結されていたユーザーのノートは見えるようになる', async () => {
await api('admin/unsuspend-user', { userId: carol.id }, root);
await api('admin/unsuspend-user', { userId: elle.id }, root);
await setTimeout(250);
const res = await api('notes/hybrid-timeline', { limit: 100 }, alice);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), false);
assert.strictEqual(res.body.some(note => note.id === elleNote.id), true);
});
}); });
}); });
@ -1417,27 +1566,47 @@ describe('Timelines', () => {
assert.strictEqual(res.body.some(note => note.id === bobNote.id), false); assert.strictEqual(res.body.some(note => note.id === bobNote.id), false);
}); });
test('凍結: 凍結後に凍結されたユーザーのノートは見えなくなる', async () => { describe('凍結', () => {
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]); let alice: SignupResponse, bob: SignupResponse, carol: SignupResponse;
let aliceNote: Note, bobNote: Note, carolNote: Note;
let list: UserList;
beforeAll(async () => {
[alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
list = await api('users/lists/create', { name: 'list' }, alice).then(res => res.body);
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); await api('users/lists/push', { listId: list.id, userId: bob.id }, alice);
await api('users/lists/push', { listId: list.id, userId: carol.id }, alice); await api('users/lists/push', { listId: list.id, userId: carol.id }, alice);
const aliceNote = await post(alice, { text: 'hi' }); aliceNote = await post(alice, { text: 'hi' });
const bobNote = await post(bob, { text: 'yo' }); bobNote = await post(bob, { text: 'yo' });
const carolNote = await post(carol, { text: 'kon\'nichiwa' }); carolNote = await post(carol, { text: 'kon\'nichiwa' });
await waitForPushToTl(); await waitForPushToTl();
await api('admin/suspend-user', { userId: carol.id }, root); await api('admin/suspend-user', { userId: carol.id }, root);
await setTimeout(100);
});
await setTimeout(250); test('凍結後に凍結されたユーザーのノートは見えなくなる', async () => {
const res = await api('notes/user-list-timeline', { listId: list.id }, alice); const res = await api('notes/user-list-timeline', { listId: list.id }, alice);
assert.strictEqual(res.body.length, 1);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), false);
assert.strictEqual(res.body.some(note => note.id === bobNote.id), true); assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), false); assert.strictEqual(res.body.some(note => note.id === carolNote.id), false);
}); });
test('凍結解除後に凍結されていたユーザーのノートは見えるようになる', async () => {
await api('admin/unsuspend-user', { userId: carol.id }, root);
await setTimeout(100);
const res = await api('notes/user-list-timeline', { listId: list.id }, alice);
assert.strictEqual(res.body.some(note => note.id === aliceNote.id), false);
assert.strictEqual(res.body.some(note => note.id === bobNote.id), true);
assert.strictEqual(res.body.some(note => note.id === carolNote.id), true);
});
});
}); });
describe('User TL', () => { describe('User TL', () => {