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

feat: user-level instance mute #7712

Merged
merged 82 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
7747ec5
Update ja-JP.yml
syuilo Jan 23, 2021
e4bcdd7
Merge branch 'develop'
syuilo Jan 23, 2021
49e6c2e
Merge branch 'develop'
syuilo Feb 7, 2021
d6c8b9b
Merge branch 'develop'
syuilo Feb 19, 2021
3d68a09
Merge branch 'develop'
syuilo Feb 21, 2021
b090ff9
Merge branch 'develop'
syuilo Feb 28, 2021
9a4a534
Merge branch 'develop'
syuilo Mar 2, 2021
f7e9725
Merge branch 'develop'
syuilo Mar 6, 2021
18693fb
Merge branch 'develop'
syuilo Mar 7, 2021
52d577c
Merge branch 'develop'
syuilo Mar 22, 2021
3e11011
Merge branch 'develop'
syuilo Mar 24, 2021
449dc17
Merge branch 'develop'
syuilo Apr 14, 2021
5e1d17d
Merge branch 'develop'
syuilo Apr 15, 2021
938fcb3
Merge branch 'develop'
syuilo Apr 17, 2021
6310919
Merge branch 'develop'
syuilo Apr 18, 2021
37dc1c9
Merge branch 'develop'
syuilo Apr 23, 2021
8043409
Merge branch 'develop'
syuilo Apr 24, 2021
92977f3
Merge branch 'develop'
syuilo Apr 25, 2021
17fff8c
Merge branch 'develop'
syuilo Apr 26, 2021
ea7d4d3
Merge branch 'develop'
syuilo Apr 28, 2021
cdef5cd
Merge branch 'develop'
syuilo May 4, 2021
b6c9ab0
Merge branch 'develop'
syuilo May 4, 2021
05203e2
Merge branch 'develop'
syuilo May 5, 2021
8accb78
Merge branch 'develop'
syuilo May 5, 2021
f96c60c
Merge branch 'develop'
syuilo May 11, 2021
70d02cf
Merge branch 'develop'
syuilo May 21, 2021
942c802
Merge branch 'develop'
syuilo May 21, 2021
929e545
Merge branch 'develop'
syuilo May 31, 2021
d04014f
Merge branch 'develop'
syuilo Jun 10, 2021
acb9244
Merge branch 'develop'
syuilo Jul 20, 2021
12913a1
Merge branch 'develop'
syuilo Jul 23, 2021
943a194
Merge branch 'develop'
syuilo Jul 23, 2021
5e6e1e2
Merge branch 'develop'
syuilo Jul 26, 2021
c52e30e
Merge branch 'develop'
syuilo Aug 8, 2021
df530bb
Merge branch 'develop'
syuilo Aug 9, 2021
df53968
Merge branch 'develop'
syuilo Aug 9, 2021
42c4ea3
Merge branch 'develop'
syuilo Aug 11, 2021
9fd0e90
Merge branch 'develop'
syuilo Aug 12, 2021
df67836
Merge branch 'develop'
syuilo Aug 17, 2021
f00ceed
Merge branch 'develop'
syuilo Aug 21, 2021
e967d9d
Merge branch 'develop'
syuilo Aug 24, 2021
7115bd4
Merge branch 'develop'
syuilo Aug 24, 2021
ffdbf75
Added settable config for muted instances
puff-fan-420 Aug 26, 2021
ef57094
added psql query for removal of muted notes
puff-fan-420 Aug 26, 2021
b1d5ac3
Added filtering and trimming for instance mutes
puff-fan-420 Aug 26, 2021
ccfa680
cleaned up filtering of bad instance mutes and added a refresh at the…
puff-fan-420 Aug 26, 2021
78cc88c
Added notification & streaming timeline muting
puff-fan-420 Aug 26, 2021
56c4d83
Updated changelog
puff-fan-420 Aug 26, 2021
9d793f2
Added missing semicolon
puff-fan-420 Aug 26, 2021
9f846a6
Apply japanese string suggestions from robflop
puff-fan-420 Aug 27, 2021
3d75979
Changed Ja-JP instance mute title string to one suggested by sousuke
puff-fan-420 Aug 28, 2021
0b63f17
Update ja-JP instanceMuteDescription based on sousuke's suggestion
puff-fan-420 Aug 28, 2021
ba18674
added notification mute
puff-fan-420 Sep 2, 2021
2b3cdf6
added notification and note children muting
puff-fan-420 Sep 2, 2021
9eed781
Fixed a bug where local notifications were getting filtered on cold s…
puff-fan-420 Sep 3, 2021
4b48ba4
Merge branch 'develop'
syuilo Sep 4, 2021
c82ce92
Merge branch 'develop'
syuilo Sep 5, 2021
338793d
Merge branch 'develop'
syuilo Sep 22, 2021
8a1f3a4
Merge branch 'develop'
syuilo Oct 16, 2021
d0d5068
Merge branch 'develop'
syuilo Oct 22, 2021
a1af83c
Merge branch 'develop'
syuilo Oct 22, 2021
26b2685
Merge branch 'develop'
syuilo Oct 23, 2021
6d55726
Merge branch 'develop'
syuilo Oct 24, 2021
8078319
Merge branch 'develop'
syuilo Oct 24, 2021
e149278
Merge branch 'master' into feature/user-instance-mute
puff-fan-420 Oct 25, 2021
2df5df8
Fixed instance mute imports
puff-fan-420 Oct 25, 2021
5775d10
Fixed not saving/loading instance mutes
puff-fan-420 Oct 25, 2021
da4bacf
Merge branch 'develop' of github.com:misskey-dev/misskey into feature…
puff-fan-420 Nov 23, 2021
7b744df
Merge branch 'develop' of github.com:misskey-dev/misskey into feature…
puff-fan-420 Nov 28, 2021
4545af4
removed en-US translations for instance mute
Nov 29, 2021
18b6e57
moved instance mute migration to js
Nov 29, 2021
d6ffc97
changed settings index back to spaces
Nov 29, 2021
cd0943a
removed destructuring assignment from notification stream in instance…
puff-fan-420 Nov 29, 2021
7c928ac
added .note accessor for checking note data instead of notification data
Nov 29, 2021
788b059
changed note to use Packed<'Note'> instead of any and removed usage o…
puff-fan-420 Nov 29, 2021
d45b623
changed notification mute check to check specifically for notificatio…
Nov 29, 2021
56b09a4
changed to using single quotes
Dec 4, 2021
75f4fea
moved @click to the end for the linter
Dec 4, 2021
2194fd3
Merge branch 'develop' of github.com:misskey-dev/misskey into feature…
Dec 4, 2021
344b834
revert unnecessary changes
Dec 4, 2021
97c3bdd
restored newlines
Dec 4, 2021
7122246
whitespace removal
Dec 4, 2021
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.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

## 12.x.x (unreleased)

### Features
- Added a user-level instance mute in user settings

### Improvements
- クライアントのデザインの調整

Expand Down
6 changes: 6 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ mention: "Mention"
mentions: "Mentions"
directNotes: "Direct notes"
importAndExport: "Import / Export"
instanceMute: "Instance Mutes"
tamaina marked this conversation as resolved.
Show resolved Hide resolved
import: "Import"
export: "Export"
files: "Files"
Expand Down Expand Up @@ -957,6 +958,11 @@ _wordMute:
soft: "Soft"
hard: "Hard"
mutedNotes: "Muted notes"
_instanceMute:
instanceMuteDescription: "Will mute any notes/renotes from the listed instances, including a user replying to a user from a muted instance."
instanceMuteDescription2: "Separate with newlines"
title: "Hides notes from listed instances"
heading: "List of instances to be muted"
_theme:
explore: "Explore Themes"
install: "Install a theme"
Expand Down
7 changes: 7 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ smtpSecure: "SMTP 接続に暗黙的なSSL/TLSを使用する"
smtpSecureInfo: "STARTTLS使用時はオフにします。"
testEmail: "配信テスト"
wordMute: "ワードミュート"
instanceMute: "インスタンスミュート"
userSaysSomething: "{name}が何かを言いました"
makeActive: "アクティブにする"
display: "表示"
Expand Down Expand Up @@ -976,6 +977,12 @@ _wordMute:
hard: "ハード"
mutedNotes: "ミュートされたノート"

_instanceMute:
instanceMuteDescription: "ミュートしたインスタンスのユーザーからの返信を含めて、設定したインスタンスの全てのノートとRenoteをミュートします。"
instanceMuteDescription2: "改行で区切って設定します"
title: "設定したインスタンスのノートを隠します。"
heading: "ミュートするインスタンス"

_theme:
explore: "テーマを探す"
install: "テーマのインストール"
Expand Down
15 changes: 15 additions & 0 deletions migration/1629968054000_userInstanceBlocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class userInstanceBlocks1629968054000 implements MigrationInterface {
name = 'userInstanceBlocks1629968054000'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user_profile" ADD "mutedInstances" jsonb NOT NULL DEFAULT '[]'`);
await queryRunner.query(`COMMENT ON COLUMN "user_profile"."mutedInstances" IS 'List of instances muted by the user.'`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "mutedInstances"`);
}

}
2 changes: 2 additions & 0 deletions src/client/pages/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<FormLink :active="page === 'import-export'" replace to="/settings/import-export"><template #icon><i class="fas fa-boxes"></i></template>{{ $ts.importAndExport }}</FormLink>
<FormLink :active="page === 'mute-block'" replace to="/settings/mute-block"><template #icon><i class="fas fa-ban"></i></template>{{ $ts.muteAndBlock }}</FormLink>
<FormLink :active="page === 'word-mute'" replace to="/settings/word-mute"><template #icon><i class="fas fa-comment-slash"></i></template>{{ $ts.wordMute }}</FormLink>
<FormLink :active="page === 'instance-mute'" replace to="/settings/instance-mute"><template #icon><i class="fas fa-volume-mute"></i></template>{{ $ts.instanceMute }}</FormLink>
<FormLink :active="page === 'api'" replace to="/settings/api"><template #icon><i class="fas fa-key"></i></template>API</FormLink>
<FormLink :active="page === 'other'" replace to="/settings/other"><template #icon><i class="fas fa-ellipsis-h"></i></template>{{ $ts.other }}</FormLink>
</FormGroup>
Expand Down Expand Up @@ -108,6 +109,7 @@ export default defineComponent({
case 'notifications': return defineAsyncComponent(() => import('./notifications.vue'));
case 'mute-block': return defineAsyncComponent(() => import('./mute-block.vue'));
case 'word-mute': return defineAsyncComponent(() => import('./word-mute.vue'));
case 'instance-mute': return defineAsyncComponent(() => import('./instance-mute.vue'));
case 'integration': return defineAsyncComponent(() => import('./integration.vue'));
case 'security': return defineAsyncComponent(() => import('./security.vue'));
case '2fa': return defineAsyncComponent(() => import('./2fa.vue'));
Expand Down
83 changes: 83 additions & 0 deletions src/client/pages/settings/instance-mute.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<template>
<div>
<FormBase>
<div class="_formItem">
<FormInfo>{{ $ts._instanceMute.title}}</FormInfo>
<FormTextarea v-model:value="instanceMutes">
<span>{{$ts._instanceMute.heading}}</span>
<template #desc>{{ $ts._instanceMute.instanceMuteDescription}}<br>{{$ts._instanceMute.instanceMuteDescription2}}</template>
</FormTextarea>
</div>
<FormButton @click="save()" primary inline :disabled="!changed"><i class="fas fa-save"></i> {{ $ts.save }}</FormButton>
</FormBase>
</div>
</template>

<script>
import { defineComponent } from 'vue'
import FormBase from '@client/components/form/base.vue';
import FormTextarea from '@client/components/form/textarea.vue';
import FormInfo from '@client/components/form/info.vue';
import FormKeyValueView from '@client/components/form/key-value-view.vue';
import FormButton from '@client/components/form/button.vue';
import * as os from '@client/os';
import number from '@client/filters/number';
import * as symbols from '@client/symbols';

export default defineComponent({
components: {
FormBase,
FormButton,
FormTextarea,
FormKeyValueView,
FormInfo,
},

emits: ['info'],

data() {
return {
[symbols.PAGE_INFO]: {
title: this.$ts.instanceMute,
icon: 'fas fa-volume-mute'
},
tab: 'soft',
instanceMutes: '',
changed: false,
}
},

watch: {
instanceMutes: {
handler() {
this.changed = true;
},
deep: true
},
},

mounted() {
this.$emit('info', this[symbols.PAGE_INFO]);
},


async created() {
this.instanceMutes = this.$i.mutedInstances.join('\n');
},

methods: {
async save() {
let mutes = this.instanceMutes.trim().split('\n').map(el => el.trim()).filter(el => el);
await os.api('i/update', {
mutedInstances: mutes,
});
this.changed = false;

// Refresh filtered list to signal to the user how they've been saved
this.instanceMutes = mutes.join('\n');
},

number //?
}
})
</script>
12 changes: 12 additions & 0 deletions src/misc/is-instance-muted.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PackedNote } from '@/models/repositories/note';
import { User } from '@/models/entities/user';

export function isInstanceMuted(note: PackedNote, muted_instances: string[]): boolean {
const note_user = (note.user as User);
const note_reply_user = ((note.reply as PackedNote)?.user as User);
const note_renote_user = ((note.renote as PackedNote)?.user as User);

return muted_instances.includes(note_user.host ?? '') ||
muted_instances.includes(note_reply_user?.host ?? '') ||
muted_instances.includes(note_renote_user?.host ?? '');
}
5 changes: 5 additions & 0 deletions src/models/entities/user-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ export class UserProfile {
})
public mutedWords: string[][];

@Column('jsonb', {
default: []
})
public mutedInstances: string[];

@Column('enum', {
enum: notificationTypes,
array: true,
Expand Down
5 changes: 5 additions & 0 deletions src/models/repositories/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export class UserRepository extends Repository<User> {
hasPendingReceivedFollowRequest: this.getHasPendingReceivedFollowRequest(user.id),
integrations: profile!.integrations,
mutedWords: profile!.mutedWords,
mutedInstances: profile!.mutedInstances,
mutingNotificationTypes: profile!.mutingNotificationTypes,
emailNotificationTypes: profile!.emailNotificationTypes,
} : {}),
Expand Down Expand Up @@ -617,6 +618,10 @@ export const packedUserSchema = {
type: 'array' as const,
nullable: false as const, optional: true as const
},
mutedInstances: {
type: 'array' as const,
nullable: false as const, optional: true as const
},
mutingNotificationTypes: {
type: 'array' as const,
nullable: false as const, optional: true as const
Expand Down
40 changes: 40 additions & 0 deletions src/server/api/common/generate-muted-instance-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { User } from '@/models/entities/user';
import { id } from '@/models/id';
import { UserProfiles } from '@/models/index';
import { SelectQueryBuilder, Brackets } from 'typeorm';

function createMutesQuery(id: string) {
return UserProfiles.createQueryBuilder('user_profile')
.select('user_profile.mutedInstances')
.where('user_profile.userId = :muterId', { muterId: id });
}

export function generateMutedInstanceQuery(q: SelectQueryBuilder<any>, me: { id: User['id'] }) {
const mutingQuery = createMutesQuery(me.id);

q
.andWhere(new Brackets(qb => { qb
.andWhere('note.userHost IS NULL')
.orWhere(`NOT((${ mutingQuery.getQuery() })::jsonb ? note.userHost)`);
}))
.andWhere(new Brackets(qb => { qb
.where(`note.replyUserHost IS NULL`)
.orWhere(`NOT ((${ mutingQuery.getQuery() })::jsonb ? note.replyUserHost)`);
}))
.andWhere(new Brackets(qb => { qb
.where(`note.renoteUserHost IS NULL`)
.orWhere(`NOT ((${ mutingQuery.getQuery() })::jsonb ? note.renoteUserHost)`);
}));
q.setParameters(mutingQuery.getParameters());
}

export function generateMutedInstanceNotificationQuery(q: SelectQueryBuilder<any>, me: { id: User['id'] }) {
const mutingQuery = createMutesQuery(me.id);

q.andWhere(new Brackets(qb => { qb
.andWhere('notifier.host IS NULL')
.orWhere(`NOT (( ${mutingQuery.getQuery()} )::jsonb ? notifier.host)`);
}));

q.setParameters(mutingQuery.getParameters());
}
3 changes: 3 additions & 0 deletions src/server/api/endpoints/i/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ID } from '@/misc/cafy-id';
import { readNotification } from '../../common/read-notification';
import define from '../../define';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { generateMutedInstanceNotificationQuery } from '../../common/generate-muted-instance-query';
import { Notifications, Followings, Mutings, Users } from '@/models/index';
import { notificationTypes } from '../../../../types';
import read from '@/services/note/read';
Expand Down Expand Up @@ -92,6 +93,8 @@ export default define(meta, async (ps, user) => {
query.andWhere(`notification.notifierId NOT IN (${ mutingQuery.getQuery() })`);
query.setParameters(mutingQuery.getParameters());

generateMutedInstanceNotificationQuery(query, user);

query.andWhere(`notification.notifierId NOT IN (${ suspendedQuery.getQuery() })`);

if (ps.following) {
Expand Down
5 changes: 5 additions & 0 deletions src/server/api/endpoints/i/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ export const meta = {
validator: $.optional.arr($.arr($.str))
},

mutedInstances: {
validator: $.optional.arr($.str)
},

mutingNotificationTypes: {
validator: $.optional.arr($.str.or(notificationTypes as unknown as string[]))
},
Expand Down Expand Up @@ -176,6 +180,7 @@ export default define(meta, async (ps, _user, token) => {
profileUpdates.mutedWords = ps.mutedWords;
profileUpdates.enableWordMute = ps.mutedWords.length > 0;
}
if (ps.mutedInstances !== undefined) profileUpdates.mutedInstances = ps.mutedInstances;
if (ps.mutingNotificationTypes !== undefined) profileUpdates.mutingNotificationTypes = ps.mutingNotificationTypes as typeof notificationTypes[number][];
if (typeof ps.isLocked === 'boolean') updates.isLocked = ps.isLocked;
if (typeof ps.isExplorable === 'boolean') updates.isExplorable = ps.isExplorable;
Expand Down
2 changes: 2 additions & 0 deletions src/server/api/endpoints/notes/children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { Brackets } from 'typeorm';
import { Notes } from '@/models/index';
import { generateBlockedUserQuery } from '../../common/generate-block-query';
import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query';

export const meta = {
tags: ['notes'],
Expand Down Expand Up @@ -65,6 +66,7 @@ export default define(meta, async (ps, user) => {
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user);
if (user) generateBlockedUserQuery(query, user);
if (user) generateMutedInstanceQuery(query, user);

const notes = await query.take(ps.limit!).getMany();

Expand Down
2 changes: 2 additions & 0 deletions src/server/api/endpoints/notes/global-timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ApiError } from '../../error';
import { makePaginationQuery } from '../../common/make-pagination-query';
import { Notes } from '@/models/index';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query';
import { activeUsersChart } from '@/services/chart/index';
import { generateRepliesQuery } from '../../common/generate-replies-query';
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query';
Expand Down Expand Up @@ -83,6 +84,7 @@ export default define(meta, async (ps, user) => {
if (user) generateMutedUserQuery(query, user);
if (user) generateMutedNoteQuery(query, user);
if (user) generateBlockedUserQuery(query, user);
if (user) generateMutedInstanceQuery(query, user);

if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\'');
Expand Down
2 changes: 2 additions & 0 deletions src/server/api/endpoints/notes/hybrid-timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Followings, Notes } from '@/models/index';
import { Brackets } from 'typeorm';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query';
import { activeUsersChart } from '@/services/chart/index';
import { generateRepliesQuery } from '../../common/generate-replies-query';
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query';
Expand Down Expand Up @@ -108,6 +109,7 @@ export default define(meta, async (ps, user) => {
generateRepliesQuery(query, user);
generateVisibilityQuery(query, user);
generateMutedUserQuery(query, user);
generateMutedInstanceQuery(query, user);
generateMutedNoteQuery(query, user);
generateBlockedUserQuery(query, user);

Expand Down
2 changes: 2 additions & 0 deletions src/server/api/endpoints/notes/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query';
import { Notes, Followings } from '@/models/index';
import { generateVisibilityQuery } from '../../common/generate-visibility-query';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query';
import { activeUsersChart } from '@/services/chart/index';
import { Brackets } from 'typeorm';
import { generateRepliesQuery } from '../../common/generate-replies-query';
Expand Down Expand Up @@ -100,6 +101,7 @@ export default define(meta, async (ps, user) => {
generateRepliesQuery(query, user);
generateVisibilityQuery(query, user);
generateMutedUserQuery(query, user);
generateMutedInstanceQuery(query, user);
generateMutedNoteQuery(query, user);
generateBlockedUserQuery(query, user);

Expand Down
2 changes: 2 additions & 0 deletions src/server/api/endpoints/users/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Notes } from '@/models/index';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query';
import { Brackets } from 'typeorm';
import { generateBlockedUserQuery } from '../../common/generate-block-query';
import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query';

export const meta = {
tags: ['users', 'notes'],
Expand Down Expand Up @@ -102,6 +103,7 @@ export default define(meta, async (ps, me) => {
generateVisibilityQuery(query, me);
if (me) generateMutedUserQuery(query, me, user);
if (me) generateBlockedUserQuery(query, me);
if (me) generateMutedInstanceQuery(query, me);

if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\'');
Expand Down
4 changes: 4 additions & 0 deletions src/server/api/stream/channels/global-timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Notes } from '@/models/index';
import { PackedNote } from '@/models/repositories/note';
import { checkWordMute } from '@/misc/check-word-mute';
import { isBlockerUserRelated } from '@/misc/is-blocker-user-related';
import { isInstanceMuted } from '@/misc/is-instance-muted';

export default class extends Channel {
public readonly chName = 'globalTimeline';
Expand Down Expand Up @@ -48,6 +49,9 @@ export default class extends Channel {
if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return;
}

// Ignore notes from instances the user has muted
if (isInstanceMuted(note, this.userProfile?.mutedInstances ?? [])) return;

// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
if (isMutedUserRelated(note, this.muting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
Expand Down
Loading