Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtual kemomimi relay social timeline #176

Merged
merged 6 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@

-->

## 2024.3.1-kinel.3

### General
- Enhance: ぶいみみリレーソーシャルタイムラインを追加しました
- ぶいみみリレーソーシャルタイムラインは、ぶいみみリレータイムラインとホームタイムラインのノートが流れます
- Feat: ぶいみみリレータイムラインの`TLに他の人への返信を含める`の動作をローカルタイムラインに揃えました
- `TLに他の人への返信を含める`を有効にすると、ぶいみみリレーに参加しているサーバーのユーザーが他の誰かにリプライしたノートが表示されます。無効にするとこれらが含まれなくなります。

### Client

### Server
- Feat: ぶいみみリレータイムラインがFFTを用いて再実装されました。

## 2024.3.1-kinel.2

### General
Expand Down
4 changes: 4 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8601,6 +8601,10 @@ export interface Locale extends ILocale {
* ぶいみみリレー
*/
"vmimiRelay": string;
/**
* ぶいみみリレーソーシャル
*/
"vmimiRelaySocial": string;
};
"_play": {
/**
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,7 @@ _timelines:
social: "ソーシャル"
global: "グローバル"
vmimiRelay: "ぶいみみリレー"
vmimiRelaySocial: "ぶいみみリレーソーシャル"

_play:
new: "Playの作成"
Expand Down
16 changes: 16 additions & 0 deletions packages/backend/migration/1713168415416-VmimiRelayTimeline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: anatawa12 and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/

export class VmimiRelayTimeline1713168415416 {
name = 'VmimiRelayTimeline1713168415416'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "vmimiRelayTimelineCacheMax" integer NOT NULL DEFAULT '300'`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "vmimiRelayTimelineCacheMax"`);
}
}
5 changes: 5 additions & 0 deletions packages/backend/src/core/FanoutTimelineService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export type FanoutTimelineName =
// role timelines
| `roleTimeline:${string}` // any notes are included

// vmimi relay timelines
| 'vmimiRelayTimeline' // replies are not included
| 'vmimiRelayTimelineWithFiles' // only non-reply notes with files are included
| 'vmimiRelayTimelineWithReplies' // only replies are included

@Injectable()
export class FanoutTimelineService {
constructor(
Expand Down
11 changes: 11 additions & 0 deletions packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { NoteReadService } from '@/core/NoteReadService.js';
import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js';
import { bindThis } from '@/decorators.js';
import { DB_MAX_NOTE_TEXT_LENGTH } from '@/const.js';
import { VmimiRelayTimelineService } from '@/core/VmimiRelayTimelineService.js';
import { RoleService } from '@/core/RoleService.js';
import { MetaService } from '@/core/MetaService.js';
import { SearchService } from '@/core/SearchService.js';
Expand Down Expand Up @@ -196,6 +197,7 @@ export class NoteCreateService implements OnApplicationShutdown {
@Inject(DI.channelFollowingsRepository)
private channelFollowingsRepository: ChannelFollowingsRepository,

private vmimiRelayTimelineService: VmimiRelayTimelineService,
private userEntityService: UserEntityService,
private noteEntityService: NoteEntityService,
private idService: IdService,
Expand Down Expand Up @@ -958,6 +960,9 @@ export class NoteCreateService implements OnApplicationShutdown {
this.fanoutTimelineService.push(`localTimelineWithReplyTo:${note.replyUserId}`, note.id, 300 / 10, r);
}
}
if (note.visibility === 'public' && this.vmimiRelayTimelineService.isRelayedInstance(note.userHost)) {
this.fanoutTimelineService.push('vmimiRelayTimelineWithReplies', note.id, meta.vmimiRelayTimelineCacheMax, r);
}
} else {
this.fanoutTimelineService.push(`userTimeline:${user.id}`, note.id, note.userHost == null ? meta.perLocalUserUserTimelineCacheMax : meta.perRemoteUserUserTimelineCacheMax, r);
if (note.fileIds.length > 0) {
Expand All @@ -970,6 +975,12 @@ export class NoteCreateService implements OnApplicationShutdown {
this.fanoutTimelineService.push('localTimelineWithFiles', note.id, 500, r);
}
}
if (note.visibility === 'public' && this.vmimiRelayTimelineService.isRelayedInstance(note.userHost)) {
this.fanoutTimelineService.push('vmimiRelayTimeline', note.id, meta.vmimiRelayTimelineCacheMax, r);
if (note.fileIds.length > 0) {
this.fanoutTimelineService.push('vmimiRelayTimelineWithFiles', note.id, meta.vmimiRelayTimelineCacheMax / 2, r);
}
}
}

if (Math.random() < 0.1) {
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/core/RoleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { NotificationService } from '@/core/NotificationService.js';
import type { OnApplicationShutdown, OnModuleInit } from '@nestjs/common';

export type RolePolicies = {
vrtlAvailable: boolean;
gtlAvailable: boolean;
ltlAvailable: boolean;
canPublicNote: boolean;
Expand Down Expand Up @@ -60,6 +61,7 @@ export type RolePolicies = {
};

export const DEFAULT_POLICIES: RolePolicies = {
vrtlAvailable: true,
gtlAvailable: true,
ltlAvailable: true,
canPublicNote: true,
Expand Down Expand Up @@ -327,6 +329,7 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
}

return {
vrtlAvailable: calc('vrtlAvailable', vs => vs.some(v => v === true)),
gtlAvailable: calc('gtlAvailable', vs => vs.some(v => v === true)),
ltlAvailable: calc('ltlAvailable', vs => vs.some(v => v === true)),
canPublicNote: calc('canPublicNote', vs => vs.some(v => v === true)),
Expand Down
19 changes: 0 additions & 19 deletions packages/backend/src/core/VmimiRelayTimelineService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,4 @@ export class VmimiRelayTimelineService {
this.checkForUpdateInstanceList();
return this.instanceHostsArray;
}

@bindThis
generateFilterQuery(query: SelectQueryBuilder<any>, excludeReplies: boolean) {
const names = this.hostNames;
query.andWhere(new Brackets(qb => {
qb.where('note.userHost IS NULL');
if (names.length !== 0) {
qb.orWhere('note.userHost IN (:...vmimiRelayInstances)', { vmimiRelayInstances: names });
}
}));
if (excludeReplies) {
query.andWhere(new Brackets(qb => {
qb.where('note.replyUserHost IS NULL');
if (names.length !== 0) {
qb.orWhere('note.replyUserHost IN (:...vmimiRelayInstances)', { vmimiRelayInstances: names });
}
}));
}
}
}
5 changes: 5 additions & 0 deletions packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,11 @@ export class MiMeta {
})
public preservedUsernames: string[];

@Column('integer', {
default: 300,
})
public vmimiRelayTimelineCacheMax: number;

@Column('boolean', {
default: true,
})
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/models/json-schema/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export const packedRolePoliciesSchema = {
type: 'object',
optional: false, nullable: false,
properties: {
vrtlAvailable: {
type: 'boolean',
optional: false, nullable: false,
},
gtlAvailable: {
type: 'boolean',
optional: false, nullable: false,
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/ServerModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { ChannelChannelService } from './api/stream/channels/channel.js';
import { DriveChannelService } from './api/stream/channels/drive.js';
import { GlobalTimelineChannelService } from './api/stream/channels/global-timeline.js';
import { VmimiRelayTimelineChannelService } from './api/stream/channels/vmimi-relay-timeline.js';
import { VmimiRelayHybridTimelineChannelService } from './api/stream/channels/vmimi-relay-hybrid-timeline.js';
import { HashtagChannelService } from './api/stream/channels/hashtag.js';
import { HomeTimelineChannelService } from './api/stream/channels/home-timeline.js';
import { HybridTimelineChannelService } from './api/stream/channels/hybrid-timeline.js';
Expand Down Expand Up @@ -80,6 +81,7 @@ import { ReversiGameChannelService } from './api/stream/channels/reversi-game.js
DriveChannelService,
GlobalTimelineChannelService,
VmimiRelayTimelineChannelService,
VmimiRelayHybridTimelineChannelService,
HashtagChannelService,
RoleTimelineChannelService,
ReversiChannelService,
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/src/server/api/EndpointsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ import * as ep___notes_favorites_delete from './endpoints/notes/favorites/delete
import * as ep___notes_featured from './endpoints/notes/featured.js';
import * as ep___notes_globalTimeline from './endpoints/notes/global-timeline.js';
import * as ep___notes_vmimiRelayTimeline from './endpoints/notes/vmimi-relay-timeline.js';
import * as ep___notes_vmimiRelayHybridTimeline from './endpoints/notes/vmimi-relay-hybrid-timeline.js';
import * as ep___notes_hybridTimeline from './endpoints/notes/hybrid-timeline.js';
import * as ep___notes_localTimeline from './endpoints/notes/local-timeline.js';
import * as ep___notes_mentions from './endpoints/notes/mentions.js';
Expand Down Expand Up @@ -650,6 +651,7 @@ const $notes_favorites_delete: Provider = { provide: 'ep:notes/favorites/delete'
const $notes_featured: Provider = { provide: 'ep:notes/featured', useClass: ep___notes_featured.default };
const $notes_globalTimeline: Provider = { provide: 'ep:notes/global-timeline', useClass: ep___notes_globalTimeline.default };
const $notes_vmimiRelayTimeline: Provider = { provide: 'ep:notes/vmimi-relay-timeline', useClass: ep___notes_vmimiRelayTimeline.default };
const $notes_vmimiRelayHybridTimeline: Provider = { provide: 'ep:notes/vmimi-relay-hybrid-timeline', useClass: ep___notes_vmimiRelayHybridTimeline.default };
const $notes_hybridTimeline: Provider = { provide: 'ep:notes/hybrid-timeline', useClass: ep___notes_hybridTimeline.default };
const $notes_localTimeline: Provider = { provide: 'ep:notes/local-timeline', useClass: ep___notes_localTimeline.default };
const $notes_mentions: Provider = { provide: 'ep:notes/mentions', useClass: ep___notes_mentions.default };
Expand Down Expand Up @@ -1029,6 +1031,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__
$notes_featured,
$notes_globalTimeline,
$notes_vmimiRelayTimeline,
$notes_vmimiRelayHybridTimeline,
$notes_hybridTimeline,
$notes_localTimeline,
$notes_mentions,
Expand Down Expand Up @@ -1402,6 +1405,7 @@ const $reversi_verify: Provider = { provide: 'ep:reversi/verify', useClass: ep__
$notes_featured,
$notes_globalTimeline,
$notes_vmimiRelayTimeline,
$notes_vmimiRelayHybridTimeline,
$notes_hybridTimeline,
$notes_localTimeline,
$notes_mentions,
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/api/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ import * as ep___notes_favorites_delete from './endpoints/notes/favorites/delete
import * as ep___notes_featured from './endpoints/notes/featured.js';
import * as ep___notes_globalTimeline from './endpoints/notes/global-timeline.js';
import * as ep___notes_vmimiRelayTimeline from './endpoints/notes/vmimi-relay-timeline.js';
import * as ep___notes_vmimiRelayHybridTimeline from './endpoints/notes/vmimi-relay-hybrid-timeline.js';
import * as ep___notes_hybridTimeline from './endpoints/notes/hybrid-timeline.js';
import * as ep___notes_localTimeline from './endpoints/notes/local-timeline.js';
import * as ep___notes_mentions from './endpoints/notes/mentions.js';
Expand Down Expand Up @@ -648,6 +649,7 @@ const eps = [
['notes/featured', ep___notes_featured],
['notes/global-timeline', ep___notes_globalTimeline],
['notes/vmimi-relay-timeline', ep___notes_vmimiRelayTimeline],
['notes/vmimi-relay-hybrid-timeline', ep___notes_vmimiRelayHybridTimeline],
['notes/hybrid-timeline', ep___notes_hybridTimeline],
['notes/local-timeline', ep___notes_localTimeline],
['notes/mentions', ep___notes_mentions],
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
bannedEmailDomains: instance.bannedEmailDomains,
policies: { ...DEFAULT_POLICIES, ...instance.policies },
manifestJsonOverride: instance.manifestJsonOverride,
vmimiRelayTimelineCacheMax: instance.vmimiRelayTimelineCacheMax,
enableFanoutTimeline: instance.enableFanoutTimeline,
enableFanoutTimelineDbFallback: instance.enableFanoutTimelineDbFallback,
perLocalUserUserTimelineCacheMax: instance.perLocalUserUserTimelineCacheMax,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export const paramDef = {
manifestJsonOverride: { type: 'string' },
enableFanoutTimeline: { type: 'boolean' },
enableFanoutTimelineDbFallback: { type: 'boolean' },
vmimiRelayTimelineCacheMax: { type: 'integer' },
perLocalUserUserTimelineCacheMax: { type: 'integer' },
perRemoteUserUserTimelineCacheMax: { type: 'integer' },
perUserHomeTimelineCacheMax: { type: 'integer' },
Expand Down Expand Up @@ -561,6 +562,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
set.perLocalUserUserTimelineCacheMax = ps.perLocalUserUserTimelineCacheMax;
}

if (ps.vmimiRelayTimelineCacheMax !== undefined) {
set.vmimiRelayTimelineCacheMax = ps.vmimiRelayTimelineCacheMax;
}

if (ps.perRemoteUserUserTimelineCacheMax !== undefined) {
set.perRemoteUserUserTimelineCacheMax = ps.perRemoteUserUserTimelineCacheMax;
}
Expand Down
Loading
Loading