2023-07-26 22:31:52 -07:00
|
|
|
/*
|
2024-02-13 07:59:27 -08:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-26 22:31:52 -07:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2021-11-07 01:04:32 -08:00
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
|
|
|
import * as assert from 'assert';
|
2024-01-08 00:43:52 -08:00
|
|
|
import { api, signup, simpleGet } from '../utils.js';
|
2023-06-24 16:34:18 -07:00
|
|
|
import type * as misskey from 'misskey-js';
|
2021-11-07 01:04:32 -08:00
|
|
|
|
|
|
|
describe('FF visibility', () => {
|
2024-01-02 20:41:28 -08:00
|
|
|
let alice: misskey.entities.SignupResponse;
|
|
|
|
let bob: misskey.entities.SignupResponse;
|
2021-11-07 01:04:32 -08:00
|
|
|
|
2022-09-17 11:27:08 -07:00
|
|
|
beforeAll(async () => {
|
2021-11-07 01:04:32 -08:00
|
|
|
alice = await signup({ username: 'alice' });
|
|
|
|
bob = await signup({ username: 'bob' });
|
2023-03-02 18:13:12 -08:00
|
|
|
}, 1000 * 60 * 2);
|
2021-11-07 01:04:32 -08:00
|
|
|
|
2023-12-18 03:59:20 -08:00
|
|
|
test('followingVisibility, followersVisibility がともに public なユーザーのフォロー/フォロワーを誰でも見れる', async () => {
|
2023-03-02 18:13:12 -08:00
|
|
|
await api('/i/update', {
|
2023-12-18 03:59:20 -08:00
|
|
|
followingVisibility: 'public',
|
|
|
|
followersVisibility: 'public',
|
2021-11-07 01:04:32 -08:00
|
|
|
}, alice);
|
|
|
|
|
2023-03-02 18:13:12 -08:00
|
|
|
const followingRes = await api('/users/following', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
2023-03-02 18:13:12 -08:00
|
|
|
const followersRes = await api('/users/followers', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
2022-09-17 11:27:08 -07:00
|
|
|
});
|
2021-11-07 01:04:32 -08:00
|
|
|
|
2023-12-18 03:59:20 -08:00
|
|
|
test('followingVisibility が public であれば followersVisibility の設定に関わらずユーザーのフォローを誰でも見れる', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'public',
|
|
|
|
followersVisibility: 'public',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'public',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'public',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followersVisibility が public であれば followingVisibility の設定に関わらずユーザーのフォロワーを誰でも見れる', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'public',
|
|
|
|
followersVisibility: 'public',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'public',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'public',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followingVisibility, followersVisibility がともに followers なユーザーのフォロー/フォロワーを自分で見れる', async () => {
|
2023-03-02 18:13:12 -08:00
|
|
|
await api('/i/update', {
|
2023-12-18 03:59:20 -08:00
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'followers',
|
2021-11-07 01:04:32 -08:00
|
|
|
}, alice);
|
|
|
|
|
2023-03-02 18:13:12 -08:00
|
|
|
const followingRes = await api('/users/following', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
2023-03-02 18:13:12 -08:00
|
|
|
const followersRes = await api('/users/followers', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
2022-09-17 11:27:08 -07:00
|
|
|
});
|
2021-11-07 01:04:32 -08:00
|
|
|
|
2023-12-18 03:59:20 -08:00
|
|
|
test('followingVisibility が followers なユーザーのフォローを followersVisibility の設定に関わらず自分で見れる', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'public',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followersVisibility が followers なユーザーのフォロワーを followingVisibility の設定に関わらず自分で見れる', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'public',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followingVisibility, followersVisibility がともに followers なユーザーのフォロー/フォロワーを非フォロワーが見れない', async () => {
|
2023-03-02 18:13:12 -08:00
|
|
|
await api('/i/update', {
|
2023-12-18 03:59:20 -08:00
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'followers',
|
2021-11-07 01:04:32 -08:00
|
|
|
}, alice);
|
|
|
|
|
2023-03-02 18:13:12 -08:00
|
|
|
const followingRes = await api('/users/following', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
2023-03-02 18:13:12 -08:00
|
|
|
const followersRes = await api('/users/followers', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
|
|
|
assert.strictEqual(followingRes.status, 400);
|
|
|
|
assert.strictEqual(followersRes.status, 400);
|
2022-09-17 11:27:08 -07:00
|
|
|
});
|
2021-11-07 01:04:32 -08:00
|
|
|
|
2023-12-18 03:59:20 -08:00
|
|
|
test('followingVisibility が followers なユーザーのフォローを followersVisibility の設定に関わらず非フォロワーが見れない', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'public',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 400);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 400);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 400);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followersVisibility が followers なユーザーのフォロワーを followingVisibility の設定に関わらず非フォロワーが見れない', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'public',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 400);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 400);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 400);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followingVisibility, followersVisibility がともに followers なユーザーのフォロー/フォロワーをフォロワーが見れる', async () => {
|
2023-03-02 18:13:12 -08:00
|
|
|
await api('/i/update', {
|
2023-12-18 03:59:20 -08:00
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'followers',
|
2021-11-07 01:04:32 -08:00
|
|
|
}, alice);
|
|
|
|
|
2023-03-02 18:13:12 -08:00
|
|
|
await api('/following/create', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
2023-03-02 18:13:12 -08:00
|
|
|
const followingRes = await api('/users/following', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
2023-03-02 18:13:12 -08:00
|
|
|
const followersRes = await api('/users/followers', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
2022-09-17 11:27:08 -07:00
|
|
|
});
|
2021-11-07 01:04:32 -08:00
|
|
|
|
2023-12-18 03:59:20 -08:00
|
|
|
test('followingVisibility が followers なユーザーのフォローを followersVisibility の設定に関わらずフォロワーが見れる', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'public',
|
|
|
|
}, alice);
|
|
|
|
await api('/following/create', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
await api('/following/create', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
await api('/following/create', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followersVisibility が followers なユーザーのフォロワーを followingVisibility の設定に関わらずフォロワーが見れる', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'public',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
await api('/following/create', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
await api('/following/create', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
await api('/following/create', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followingVisibility, followersVisibility がともに private なユーザーのフォロー/フォロワーを自分で見れる', async () => {
|
2023-03-02 18:13:12 -08:00
|
|
|
await api('/i/update', {
|
2023-12-18 03:59:20 -08:00
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'private',
|
2021-11-07 01:04:32 -08:00
|
|
|
}, alice);
|
|
|
|
|
2023-03-02 18:13:12 -08:00
|
|
|
const followingRes = await api('/users/following', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
2023-03-02 18:13:12 -08:00
|
|
|
const followersRes = await api('/users/followers', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
2022-09-17 11:27:08 -07:00
|
|
|
});
|
2021-11-07 01:04:32 -08:00
|
|
|
|
2023-12-18 03:59:20 -08:00
|
|
|
test('followingVisibility が private なユーザーのフォローを followersVisibility の設定に関わらず自分で見れる', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'public',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followingRes.body), true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followersVisibility が private なユーザーのフォロワーを followingVisibility の設定に関わらず自分で見れる', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'public',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, alice);
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
assert.strictEqual(Array.isArray(followersRes.body), true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followingVisibility, followersVisibility がともに private なユーザーのフォロー/フォロワーを他人が見れない', async () => {
|
2023-03-02 18:13:12 -08:00
|
|
|
await api('/i/update', {
|
2023-12-18 03:59:20 -08:00
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'private',
|
2021-11-07 01:04:32 -08:00
|
|
|
}, alice);
|
|
|
|
|
2023-03-02 18:13:12 -08:00
|
|
|
const followingRes = await api('/users/following', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
2023-03-02 18:13:12 -08:00
|
|
|
const followersRes = await api('/users/followers', {
|
2021-11-07 01:04:32 -08:00
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
|
|
|
|
assert.strictEqual(followingRes.status, 400);
|
|
|
|
assert.strictEqual(followersRes.status, 400);
|
2022-09-17 11:27:08 -07:00
|
|
|
});
|
2021-11-07 01:04:32 -08:00
|
|
|
|
2023-12-18 03:59:20 -08:00
|
|
|
test('followingVisibility が private なユーザーのフォローを followersVisibility の設定に関わらず他人が見れない', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'public',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 400);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 400);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await api('/users/following', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followingRes.status, 400);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followersVisibility が private なユーザーのフォロワーを followingVisibility の設定に関わらず他人が見れない', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'public',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 400);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'followers',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 400);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followingVisibility: 'private',
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await api('/users/followers', {
|
|
|
|
userId: alice.id,
|
|
|
|
}, bob);
|
|
|
|
assert.strictEqual(followersRes.status, 400);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-11-07 01:04:32 -08:00
|
|
|
describe('AP', () => {
|
2023-12-18 03:59:20 -08:00
|
|
|
test('followingVisibility が public 以外ならばAPからはフォローを取得できない', async () => {
|
2021-11-07 01:04:32 -08:00
|
|
|
{
|
2023-03-02 18:13:12 -08:00
|
|
|
await api('/i/update', {
|
2023-12-18 03:59:20 -08:00
|
|
|
followingVisibility: 'public',
|
2021-11-07 01:04:32 -08:00
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followingRes = await simpleGet(`/users/${alice.id}/following`, 'application/activity+json');
|
|
|
|
assert.strictEqual(followingRes.status, 200);
|
|
|
|
}
|
|
|
|
{
|
2023-03-02 18:13:12 -08:00
|
|
|
await api('/i/update', {
|
2023-12-18 03:59:20 -08:00
|
|
|
followingVisibility: 'followers',
|
2021-11-07 01:04:32 -08:00
|
|
|
}, alice);
|
|
|
|
|
2023-03-02 18:13:12 -08:00
|
|
|
const followingRes = await simpleGet(`/users/${alice.id}/following`, 'application/activity+json');
|
2021-11-07 01:04:32 -08:00
|
|
|
assert.strictEqual(followingRes.status, 403);
|
|
|
|
}
|
|
|
|
{
|
2023-03-02 18:13:12 -08:00
|
|
|
await api('/i/update', {
|
2023-12-18 03:59:20 -08:00
|
|
|
followingVisibility: 'private',
|
2021-11-07 01:04:32 -08:00
|
|
|
}, alice);
|
|
|
|
|
2023-03-02 18:13:12 -08:00
|
|
|
const followingRes = await simpleGet(`/users/${alice.id}/following`, 'application/activity+json');
|
2021-11-07 01:04:32 -08:00
|
|
|
assert.strictEqual(followingRes.status, 403);
|
2023-12-18 03:59:20 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
test('followersVisibility が public 以外ならばAPからはフォロワーを取得できない', async () => {
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followersVisibility: 'public',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await simpleGet(`/users/${alice.id}/followers`, 'application/activity+json');
|
|
|
|
assert.strictEqual(followersRes.status, 200);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followersVisibility: 'followers',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await simpleGet(`/users/${alice.id}/followers`, 'application/activity+json');
|
|
|
|
assert.strictEqual(followersRes.status, 403);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
await api('/i/update', {
|
|
|
|
followersVisibility: 'private',
|
|
|
|
}, alice);
|
|
|
|
|
|
|
|
const followersRes = await simpleGet(`/users/${alice.id}/followers`, 'application/activity+json');
|
2021-11-07 01:04:32 -08:00
|
|
|
assert.strictEqual(followersRes.status, 403);
|
|
|
|
}
|
2022-09-17 11:27:08 -07:00
|
|
|
});
|
2021-11-07 01:04:32 -08:00
|
|
|
});
|
|
|
|
});
|