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

VRTL/VSTLに連合なし投稿を含めるかを選択可能に #36

Merged
merged 3 commits into from
Jun 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
3 changes: 3 additions & 0 deletions CHANGELOG-VRTL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
VRTLのブランチで行われた変更点をまとめています

<!-- VV Please add changelog here VV -->
- feat: VRTL/VSTLに連合なし投稿を含めるかを選択可能に
- もともとのVRTL/VSTLでは連合なし投稿が常に含まれていましたが、正しくVRTL/VSTLのノートを表現するために含めないようにできるようになりました
- VSTLの場合、連合なし投稿を含めないようにしてもフォローしている人の連合なし投稿は表示されます
- fix(frontend): ウィジェットでVRTL/VSTLが使用できない問題を修正
- fix(backend): 自分自身に対するリプライがwithReplies = falseなVRTL/VSTLにて含まれていない問題を修正
- feat(backend): `vmimiRelayTimelineImplemented` と `disableVmimiRelayTimeline` nodeinfo に追加しました
Expand Down
4 changes: 4 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4716,6 +4716,10 @@ export interface Locale extends ILocale {
* TLに現在フォロー中の人全員の返信を含めないようにする
*/
"hideRepliesToOthersInTimelineAll": string;
/**
* TLに連合なし投稿を含める
*/
"showLocalOnlyInTimeline": string;
/**
* この操作は元に戻せません。本当にTLに現在フォロー中の人全員の返信を含めるようにしますか?
*/
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ showRepliesToOthersInTimeline: "TLに他の人への返信を含める"
hideRepliesToOthersInTimeline: "TLに他の人への返信を含めない"
showRepliesToOthersInTimelineAll: "TLに現在フォロー中の人全員の返信を含めるようにする"
hideRepliesToOthersInTimelineAll: "TLに現在フォロー中の人全員の返信を含めないようにする"
showLocalOnlyInTimeline: "TLに連合なし投稿を含める"
confirmShowRepliesAll: "この操作は元に戻せません。本当にTLに現在フォロー中の人全員の返信を含めるようにしますか?"
confirmHideRepliesAll: "この操作は元に戻せません。本当にTLに現在フォロー中の人全員の返信を含めないようにしますか?"
externalServices: "外部サービス"
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ 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)) {
if (note.visibility === 'public' && this.vmimiRelayTimelineService.isRelayedInstance(note.userHost) && !note.localOnly) {
this.fanoutTimelineService.push('vmimiRelayTimelineWithReplies', note.id, meta.vmimiRelayTimelineCacheMax, r);
if (note.replyUserHost == null) {
this.fanoutTimelineService.push(`vmimiRelayTimelineWithReplyTo:${note.replyUserId}`, note.id, meta.vmimiRelayTimelineCacheMax / 10, r);
Expand All @@ -971,7 +971,7 @@ export class NoteCreateService implements OnApplicationShutdown {
this.fanoutTimelineService.push('localTimelineWithFiles', note.id, 500, r);
}
}
if (note.visibility === 'public' && this.vmimiRelayTimelineService.isRelayedInstance(note.userHost)) {
if (note.visibility === 'public' && this.vmimiRelayTimelineService.isRelayedInstance(note.userHost) && !note.localOnly) {
this.fanoutTimelineService.push('vmimiRelayTimeline', note.id, meta.vmimiRelayTimelineCacheMax, r);
if (note.fileIds.length > 0) {
this.fanoutTimelineService.push('vmimiRelayTimelineWithFiles', note.id, meta.vmimiRelayTimelineCacheMax / 2, r);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const paramDef = {
withFiles: { type: 'boolean', default: false },
withRenotes: { type: 'boolean', default: true },
withReplies: { type: 'boolean', default: false },
withLocalOnly: { type: 'boolean', default: true },
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
allowPartial: { type: 'boolean', default: true }, // this timeline is new so true by default
sinceId: { type: 'string', format: 'misskey:id' },
Expand Down Expand Up @@ -106,6 +107,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
limit: ps.limit,
withFiles: ps.withFiles,
withReplies: ps.withReplies,
withLocalOnly: ps.withLocalOnly,
}, me);

process.nextTick(() => {
Expand All @@ -122,18 +124,21 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
`homeTimelineWithFiles:${me.id}`,
'vmimiRelayTimelineWithFiles',
];
if (ps.withLocalOnly) timelineConfig = [...timelineConfig, 'localTimelineWithFiles'];
} else if (ps.withReplies) {
timelineConfig = [
`homeTimeline:${me.id}`,
'vmimiRelayTimeline',
'vmimiRelayTimelineWithReplies',
];
if (ps.withLocalOnly) timelineConfig = [...timelineConfig, 'localTimeline', 'localTimelineWithReplies'];
} else {
timelineConfig = [
`homeTimeline:${me.id}`,
'vmimiRelayTimeline',
`vmimiRelayTimelineWithReplyTo:${me.id}`,
];
if (ps.withLocalOnly) timelineConfig = [...timelineConfig, 'localTimeline', `localTimelineWithReplyTo:${me.id}`];
}

const redisTimeline = await this.fanoutTimelineEndpointService.timeline({
Expand All @@ -152,6 +157,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
limit,
withFiles: ps.withFiles,
withReplies: ps.withReplies,
withLocalOnly: ps.withLocalOnly,
}, me),
});

Expand All @@ -169,6 +175,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
limit: number,
withFiles: boolean,
withReplies: boolean,
withLocalOnly: boolean,
}, me: MiLocalUser) {
const followees = await this.userFollowingService.getFollowees(me.id);
const followingChannels = await this.channelFollowingsRepository.find({
Expand All @@ -185,6 +192,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
qb.where('note.userId IN (:...meOrFolloweeIds)', { meOrFolloweeIds: meOrFolloweeIds });
qb.orWhere(new Brackets(qb => {
qb.where('note.visibility = \'public\'');
if (!ps.withLocalOnly) qb.andWhere('note.localOnly = FALSE');
qb.andWhere(new Brackets(qb => {
qb.where('note.userHost IS NULL');
if (vmimiRelayInstances.length !== 0) {
Expand All @@ -196,6 +204,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
qb.where('note.userId = :meId', { meId: me.id });
qb.orWhere(new Brackets(qb => {
qb.where('note.visibility = \'public\'');
if (!ps.withLocalOnly) qb.andWhere('note.localOnly = FALSE');
qb.andWhere(new Brackets(qb => {
qb.where('note.userHost IS NULL');
if (vmimiRelayInstances.length !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const paramDef = {
withFiles: { type: 'boolean', default: false },
withRenotes: { type: 'boolean', default: true },
withReplies: { type: 'boolean', default: false },
withLocalOnly: { type: 'boolean', default: true },
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
allowPartial: { type: 'boolean', default: true }, // this timeline is new so true by default
sinceId: { type: 'string', format: 'misskey:id' },
Expand Down Expand Up @@ -98,6 +99,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withFiles: ps.withFiles,
withRenotes: ps.withRenotes,
withReplies: ps.withReplies,
withLocalOnly: ps.withLocalOnly,
}, me);

process.nextTick(() => {
Expand All @@ -117,10 +119,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
me,
useDbFallback: serverSettings.enableFanoutTimelineDbFallback,
redisTimelines:
ps.withFiles ? ['vmimiRelayTimelineWithFiles']
: ps.withReplies ? ['vmimiRelayTimeline', 'vmimiRelayTimelineWithReplies']
: me ? ['vmimiRelayTimeline', `vmimiRelayTimelineWithReplyTo:${me.id}`]
: ['vmimiRelayTimeline'],
ps.withFiles ? ['vmimiRelayTimelineWithFiles', ...(ps.withLocalOnly ? ['localTimelineWithFiles'] as const : [])]
: ps.withReplies ? ['vmimiRelayTimeline', 'vmimiRelayTimelineWithReplies', ...(ps.withLocalOnly ? ['localTimeline', 'localTimelineWithReplies'] as const : [])]
: me ? ['vmimiRelayTimeline', `vmimiRelayTimelineWithReplyTo:${me.id}`, ...(ps.withLocalOnly ? ['localTimeline', `localTimelineWithReplyTo:${me.id}`] as const : [])]
: ['vmimiRelayTimeline', ...(ps.withLocalOnly ? ['localTimeline'] as const : [])],
alwaysIncludeMyNotes: true,
excludePureRenotes: !ps.withRenotes,
dbFallback: async (untilId, sinceId, limit) => await this.getFromDb({
Expand All @@ -130,6 +132,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withFiles: ps.withFiles,
withRenotes: ps.withRenotes,
withReplies: ps.withReplies,
withLocalOnly: ps.withLocalOnly,
}, me),
});

Expand All @@ -150,6 +153,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
withFiles: boolean,
withRenotes: boolean,
withReplies: boolean,
withLocalOnly: boolean,
}, me: MiLocalUser | null) {
//#region Construct query
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId)
Expand All @@ -169,6 +173,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
}));

if (!ps.withLocalOnly) {
query.andWhere('note.localOnly = FALSE');
}

if (!ps.withReplies) {
query.andWhere(new Brackets(qb => {
qb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class VmimiRelayHybridTimelineChannel extends Channel {
private withRenotes: boolean;
private withReplies: boolean;
private withFiles: boolean;
private withLocalOnly: boolean;

constructor(
private metaService: MetaService,
Expand All @@ -44,6 +45,7 @@ class VmimiRelayHybridTimelineChannel extends Channel {
this.withRenotes = params.withRenotes ?? true;
this.withReplies = params.withReplies ?? false;
this.withFiles = params.withFiles ?? false;
this.withLocalOnly = params.withLocalOnly ?? true;

// Subscribe events
this.subscriber.on('notesStream', this.onNote);
Expand All @@ -62,7 +64,7 @@ class VmimiRelayHybridTimelineChannel extends Channel {
if (!(
(note.channelId == null && isMe) ||
(note.channelId == null && Object.hasOwn(this.following, note.userId)) ||
(note.channelId == null && (this.vmimiRelayTimelineService.isRelayedInstance(note.user.host) && note.visibility === 'public')) ||
(note.channelId == null && (this.vmimiRelayTimelineService.isRelayedInstance(note.user.host) && note.visibility === 'public') && (this.withLocalOnly || !note.localOnly)) ||
(note.channelId != null && this.followingChannels.has(note.channelId))
)) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class VmimiRelayTimelineChannel extends Channel {
private withRenotes: boolean;
private withReplies: boolean;
private withFiles: boolean;
private withLocalOnly: boolean;

constructor(
private metaService: MetaService,
Expand All @@ -41,6 +42,7 @@ class VmimiRelayTimelineChannel extends Channel {
this.withRenotes = params.withRenotes ?? true;
this.withReplies = params.withReplies ?? false;
this.withFiles = params.withFiles ?? false;
this.withLocalOnly = params.withLocalOnly ?? true;

// Subscribe events
this.subscriber.on('notesStream', this.onNote);
Expand All @@ -51,6 +53,7 @@ class VmimiRelayTimelineChannel extends Channel {
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;

if (!this.vmimiRelayTimelineService.isRelayedInstance(note.user.host ?? null)) return;
if (!this.withLocalOnly && note.localOnly) return;
if (note.visibility !== 'public') return;
if (note.channelId != null) return;

Expand Down
7 changes: 7 additions & 0 deletions packages/frontend/src/components/MkTimeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ const props = withDefaults(defineProps<{
withRenotes?: boolean;
withReplies?: boolean;
onlyFiles?: boolean;
withLocalOnly?: boolean;
}>(), {
withRenotes: true,
withReplies: false,
onlyFiles: false,
withLocalOnly: true,
});

const emit = defineEmits<{
Expand All @@ -57,6 +59,7 @@ type TimelineQueryType = {
withRenotes?: boolean,
withReplies?: boolean,
withFiles?: boolean,
withLocalOnly?: boolean,
visibility?: string,
listId?: string,
channelId?: string,
Expand Down Expand Up @@ -126,12 +129,14 @@ function connectChannel() {
withRenotes: props.withRenotes,
withFiles: props.onlyFiles ? true : undefined,
withReplies: props.withReplies,
withLocalOnly: props.withLocalOnly,
});
} else if (props.src === 'vmimi-relay-social') {
connection = stream.useChannel('vmimiRelayHybridTimeline', {
withRenotes: props.withRenotes,
withFiles: props.onlyFiles ? true : undefined,
withReplies: props.withReplies,
withLocalOnly: props.withLocalOnly,
});
} else if (props.src === 'mentions') {
connection = stream.useChannel('main');
Expand Down Expand Up @@ -211,13 +216,15 @@ function updatePaginationQuery() {
withRenotes: props.withRenotes,
withFiles: props.onlyFiles ? true : undefined,
withReplies: props.withReplies,
withLocalOnly: props.withLocalOnly,
};
} else if (props.src === 'vmimi-relay-social') {
endpoint = 'notes/vmimi-relay-hybrid-timeline';
query = {
withRenotes: props.withRenotes,
withFiles: props.onlyFiles ? true : undefined,
withReplies: props.withReplies,
withLocalOnly: props.withLocalOnly,
};
} else if (props.src === 'mentions') {
endpoint = 'notes/mentions';
Expand Down
13 changes: 11 additions & 2 deletions packages/frontend/src/pages/timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ SPDX-License-Identifier: AGPL-3.0-only
<div :class="$style.tl">
<MkTimeline
ref="tlComponent"
:key="src + withRenotes + withReplies + onlyFiles"
:key="src + withRenotes + withReplies + onlyFiles + withLocalOnly"
:src="src.split(':')[0]"
:list="src.split(':')[1]"
:withRenotes="withRenotes"
:withReplies="withReplies"
:onlyFiles="onlyFiles"
:withLocalOnly="withLocalOnly"
:sound="true"
@queue="queueUpdated"
/>
Expand Down Expand Up @@ -76,6 +77,10 @@ const withRenotes = computed<boolean>({
get: () => defaultStore.reactiveState.tl.value.filter.withRenotes,
set: (x) => saveTlFilter('withRenotes', x),
});
const withLocalOnly = computed<boolean>({
get: () => defaultStore.reactiveState.tl.value.filter.withLocalOnly,
set: (x) => saveTlFilter('withLocalOnly', x),
});

// computed内での無限ループを防ぐためのフラグ
const localSocialTLFilterSwitchStore = ref<'withReplies' | 'onlyFiles' | false>('withReplies');
Expand Down Expand Up @@ -263,7 +268,11 @@ const headerActions = computed(() => {
text: i18n.ts.fileAttachedOnly,
ref: onlyFiles,
disabled: src.value === 'local' || src.value === 'social' || src.value === 'vmimi-relay' || src.value === 'vmimi-relay-social' ? withReplies : false,
}], ev.currentTarget ?? ev.target);
}, src.value === 'vmimi-relay' || src.value === 'vmimi-relay-social' ? {
type: 'switch',
text: i18n.ts.showLocalOnlyInTimeline,
ref: withLocalOnly,
} : undefined], ev.currentTarget ?? ev.target);
},
},
];
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export const defaultStore = markRaw(new Storage('base', {
withRenotes: true,
withSensitive: true,
onlyFiles: false,
withLocalOnly: true,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/ui/deck/deck-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type Column = {
withRenotes?: boolean;
withReplies?: boolean;
onlyFiles?: boolean;
withLocalOnly?: boolean;
soundSetting: SoundStore;
};

Expand Down
16 changes: 14 additions & 2 deletions packages/frontend/src/ui/deck/tl-column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkTimeline
v-else-if="column.tl"
ref="timeline"
:key="column.tl + withRenotes + withReplies + onlyFiles"
:key="column.tl + withRenotes + withReplies + onlyFiles + withLocalOnly"
:src="column.tl"
:withRenotes="withRenotes"
:withReplies="withReplies"
:onlyFiles="onlyFiles"
:withLocalOnly="withLocalOnly"
@note="onNote"
/>
</XColumn>
Expand Down Expand Up @@ -63,6 +64,7 @@ const soundSetting = ref<SoundStore>(props.column.soundSetting ?? { type: null,
const withRenotes = ref(props.column.withRenotes ?? true);
const withReplies = ref(props.column.withReplies ?? false);
const onlyFiles = ref(props.column.onlyFiles ?? false);
const withLocalOnly = ref(props.column.withLocalOnly ?? true);

watch(withRenotes, v => {
updateColumn(props.column.id, {
Expand All @@ -82,6 +84,12 @@ watch(onlyFiles, v => {
});
});

watch(withLocalOnly, v => {
updateColumn(props.column.id, {
withLocalOnly: v,
});
});

watch(soundSetting, v => {
updateColumn(props.column.id, { soundSetting: v });
});
Expand Down Expand Up @@ -150,7 +158,11 @@ const menu: MenuItem[] = [{
text: i18n.ts.fileAttachedOnly,
ref: onlyFiles,
disabled: props.column.tl === 'local' || props.column.tl === 'social' || props.column.tl === 'vmimi-relay-social' || props.column.tl === 'vmimi-relay' ? withReplies : false,
}];
}, props.column.tl === 'vmimi-relay-social' || props.column.tl === 'vmimi-relay' ? {
type: 'switch',
text: i18n.ts.showLocalOnlyInTimeline,
ref: withLocalOnly,
} : undefined];
</script>

<style lang="scss" module>
Expand Down
2 changes: 2 additions & 0 deletions packages/misskey-js/etc/misskey-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ export type Channels = {
withRenotes?: boolean;
withFiles?: boolean;
withReplies?: boolean;
withLocalOnly?: boolean;
};
events: {
note: (payload: Note) => void;
Expand All @@ -614,6 +615,7 @@ export type Channels = {
withRenotes?: boolean;
withReplies?: boolean;
withFiles?: boolean;
withLocalOnly?: boolean;
};
events: {
note: (payload: Note) => void;
Expand Down
Loading
Loading