mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-01 23:10:40 +01:00
tweak
This commit is contained in:
parent
610b68c8ff
commit
3dd84f7824
2 changed files with 54 additions and 31 deletions
|
@ -481,12 +481,10 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
// Increment notes count (user)
|
// Increment notes count (user)
|
||||||
this.incNotesCountOfUser(user);
|
this.incNotesCountOfUser(user);
|
||||||
|
|
||||||
if (data.visibility === 'public' || data.visibility === 'home') {
|
if (data.visibility === 'specified') {
|
||||||
|
// TODO?
|
||||||
|
} else {
|
||||||
this.pushToTl(note, user);
|
this.pushToTl(note, user);
|
||||||
} else if (data.visibility === 'followers') {
|
|
||||||
this.pushToTl(note, user);
|
|
||||||
} else if (data.visibility === 'specified') {
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.antennaService.addNoteToAntennas(note, user);
|
this.antennaService.addNoteToAntennas(note, user);
|
||||||
|
@ -913,44 +911,42 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.visibility === 'public' || note.visibility === 'home') {
|
// 自分自身以外への返信
|
||||||
// 自分自身以外への返信
|
if (note.replyId && note.replyUserId !== note.userId) {
|
||||||
if (note.replyId && note.replyUserId !== note.userId) {
|
redisPipeline.xadd(
|
||||||
|
`userTimelineWithReplies:${user.id}`,
|
||||||
|
'MAXLEN', '~', note.userHost == null ? meta.perLocalUserUserTimelineCacheMax.toString() : meta.perRemoteUserUserTimelineCacheMax.toString(),
|
||||||
|
'*',
|
||||||
|
'note', note.id);
|
||||||
|
} else {
|
||||||
|
redisPipeline.xadd(
|
||||||
|
`userTimeline:${user.id}`,
|
||||||
|
'MAXLEN', '~', note.userHost == null ? meta.perLocalUserUserTimelineCacheMax.toString() : meta.perRemoteUserUserTimelineCacheMax.toString(),
|
||||||
|
'*',
|
||||||
|
'note', note.id);
|
||||||
|
|
||||||
|
if (note.fileIds.length > 0) {
|
||||||
redisPipeline.xadd(
|
redisPipeline.xadd(
|
||||||
`userTimelineWithReplies:${user.id}`,
|
`userTimelineWithFiles:${user.id}`,
|
||||||
'MAXLEN', '~', note.userHost == null ? meta.perLocalUserUserTimelineCacheMax.toString() : meta.perRemoteUserUserTimelineCacheMax.toString(),
|
'MAXLEN', '~', note.userHost == null ? (meta.perLocalUserUserTimelineCacheMax / 2).toString() : (meta.perRemoteUserUserTimelineCacheMax / 2).toString(),
|
||||||
'*',
|
'*',
|
||||||
'note', note.id);
|
'note', note.id);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (note.visibility === 'public' && note.userHost == null) {
|
||||||
redisPipeline.xadd(
|
redisPipeline.xadd(
|
||||||
`userTimeline:${user.id}`,
|
'localTimeline',
|
||||||
'MAXLEN', '~', note.userHost == null ? meta.perLocalUserUserTimelineCacheMax.toString() : meta.perRemoteUserUserTimelineCacheMax.toString(),
|
'MAXLEN', '~', '1000',
|
||||||
'*',
|
'*',
|
||||||
'note', note.id);
|
'note', note.id);
|
||||||
|
|
||||||
if (note.fileIds.length > 0) {
|
if (note.fileIds.length > 0) {
|
||||||
redisPipeline.xadd(
|
redisPipeline.xadd(
|
||||||
`userTimelineWithFiles:${user.id}`,
|
'localTimelineWithFiles',
|
||||||
'MAXLEN', '~', note.userHost == null ? (meta.perLocalUserUserTimelineCacheMax / 2).toString() : (meta.perRemoteUserUserTimelineCacheMax / 2).toString(),
|
'MAXLEN', '~', '500',
|
||||||
'*',
|
'*',
|
||||||
'note', note.id);
|
'note', note.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.visibility === 'public' && note.userHost == null) {
|
|
||||||
redisPipeline.xadd(
|
|
||||||
'localTimeline',
|
|
||||||
'MAXLEN', '~', '1000',
|
|
||||||
'*',
|
|
||||||
'note', note.id);
|
|
||||||
|
|
||||||
if (note.fileIds.length > 0) {
|
|
||||||
redisPipeline.xadd(
|
|
||||||
'localTimelineWithFiles',
|
|
||||||
'MAXLEN', '~', '500',
|
|
||||||
'*',
|
|
||||||
'note', note.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -701,6 +701,18 @@ describe('Timelines', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('User TL', () => {
|
describe('User TL', () => {
|
||||||
|
test.concurrent('ノートが含まれる', async () => {
|
||||||
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||||
|
|
||||||
|
const bobNote = await post(bob, { text: 'hi' });
|
||||||
|
|
||||||
|
await sleep(100); // redisに追加されるのを待つ
|
||||||
|
|
||||||
|
const res = await api('/users/notes', { userId: bob.id }, alice);
|
||||||
|
|
||||||
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
||||||
|
});
|
||||||
|
|
||||||
test.concurrent('フォローしていないユーザーの visibility: followers なノートが含まれない', async () => {
|
test.concurrent('フォローしていないユーザーの visibility: followers なノートが含まれない', async () => {
|
||||||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||||
|
|
||||||
|
@ -756,6 +768,21 @@ describe('Timelines', () => {
|
||||||
assert.strictEqual(res.body.some((note: any) => note.id === bobNote1.id), true);
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote1.id), true);
|
||||||
assert.strictEqual(res.body.some((note: any) => note.id === bobNote2.id), true);
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote2.id), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.concurrent('[withFiles: true] ファイル付きノートのみ含まれる', async () => {
|
||||||
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||||
|
|
||||||
|
const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/assets/main/icon.png');
|
||||||
|
const bobNote1 = await post(bob, { text: 'hi' });
|
||||||
|
const bobNote2 = await post(bob, { fileIds: [file.id] });
|
||||||
|
|
||||||
|
await sleep(100); // redisに追加されるのを待つ
|
||||||
|
|
||||||
|
const res = await api('/users/notes', { userId: bob.id, withFiles: true }, alice);
|
||||||
|
|
||||||
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote1.id), false);
|
||||||
|
assert.strictEqual(res.body.some((note: any) => note.id === bobNote2.id), true);
|
||||||
|
}, 1000 * 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: リノートミュート済みユーザーのテスト
|
// TODO: リノートミュート済みユーザーのテスト
|
||||||
|
|
Loading…
Reference in a new issue