From 4cd62f23f32830ec622806f2ddb6df75390148ae Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Jul 2020 09:36:43 +0900 Subject: [PATCH] refactor: Rename function --- .../{should-mute-this-note.ts => is-muted-user-related.ts} | 2 +- src/server/api/stream/channels/antenna.ts | 4 ++-- src/server/api/stream/channels/global-timeline.ts | 4 ++-- src/server/api/stream/channels/hashtag.ts | 4 ++-- src/server/api/stream/channels/home-timeline.ts | 4 ++-- src/server/api/stream/channels/hybrid-timeline.ts | 4 ++-- src/server/api/stream/channels/local-timeline.ts | 4 ++-- src/server/api/stream/channels/user-list.ts | 4 ++-- src/services/add-note-to-antenna.ts | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) rename src/misc/{should-mute-this-note.ts => is-muted-user-related.ts} (76%) diff --git a/src/misc/should-mute-this-note.ts b/src/misc/is-muted-user-related.ts similarity index 76% rename from src/misc/should-mute-this-note.ts rename to src/misc/is-muted-user-related.ts index 8f606a294..6f074bcb9 100644 --- a/src/misc/should-mute-this-note.ts +++ b/src/misc/is-muted-user-related.ts @@ -1,4 +1,4 @@ -export default function(note: any, mutedUserIds: string[]): boolean { +export function isMutedUserRelated(note: any, mutedUserIds: string[]): boolean { if (mutedUserIds.includes(note.userId)) { return true; } diff --git a/src/server/api/stream/channels/antenna.ts b/src/server/api/stream/channels/antenna.ts index 714edb502..b5a792f81 100644 --- a/src/server/api/stream/channels/antenna.ts +++ b/src/server/api/stream/channels/antenna.ts @@ -1,7 +1,7 @@ import autobind from 'autobind-decorator'; import Channel from '../channel'; import { Notes } from '../../../../models'; -import shouldMuteThisNote from '../../../../misc/should-mute-this-note'; +import { isMutedUserRelated } from '../../../../misc/is-muted-user-related'; export default class extends Channel { public readonly chName = 'antenna'; @@ -25,7 +25,7 @@ export default class extends Channel { const note = await Notes.pack(body.id, this.user, { detail: true }); // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する - if (shouldMuteThisNote(note, this.muting)) return; + if (isMutedUserRelated(note, this.muting)) return; this.send('note', note); } else { diff --git a/src/server/api/stream/channels/global-timeline.ts b/src/server/api/stream/channels/global-timeline.ts index 39800fa77..d530907d8 100644 --- a/src/server/api/stream/channels/global-timeline.ts +++ b/src/server/api/stream/channels/global-timeline.ts @@ -1,5 +1,5 @@ import autobind from 'autobind-decorator'; -import shouldMuteThisNote from '../../../../misc/should-mute-this-note'; +import { isMutedUserRelated } from '../../../../misc/is-muted-user-related'; import Channel from '../channel'; import { fetchMeta } from '../../../../misc/fetch-meta'; import { Notes } from '../../../../models'; @@ -46,7 +46,7 @@ export default class extends Channel { } // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する - if (shouldMuteThisNote(note, this.muting)) return; + if (isMutedUserRelated(note, this.muting)) return; // 流れてきたNoteがミュートすべきNoteだったら無視する // TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある) diff --git a/src/server/api/stream/channels/hashtag.ts b/src/server/api/stream/channels/hashtag.ts index e55a50832..32d8111f7 100644 --- a/src/server/api/stream/channels/hashtag.ts +++ b/src/server/api/stream/channels/hashtag.ts @@ -1,5 +1,5 @@ import autobind from 'autobind-decorator'; -import shouldMuteThisNote from '../../../../misc/should-mute-this-note'; +import { isMutedUserRelated } from '../../../../misc/is-muted-user-related'; import Channel from '../channel'; import { Notes } from '../../../../models'; import { PackedNote } from '../../../../models/repositories/note'; @@ -34,7 +34,7 @@ export default class extends Channel { } // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する - if (shouldMuteThisNote(note, this.muting)) return; + if (isMutedUserRelated(note, this.muting)) return; this.send('note', note); } diff --git a/src/server/api/stream/channels/home-timeline.ts b/src/server/api/stream/channels/home-timeline.ts index 8504d4547..caf4ccf5e 100644 --- a/src/server/api/stream/channels/home-timeline.ts +++ b/src/server/api/stream/channels/home-timeline.ts @@ -1,5 +1,5 @@ import autobind from 'autobind-decorator'; -import shouldMuteThisNote from '../../../../misc/should-mute-this-note'; +import { isMutedUserRelated } from '../../../../misc/is-muted-user-related'; import Channel from '../channel'; import { Notes } from '../../../../models'; import { PackedNote } from '../../../../models/repositories/note'; @@ -51,7 +51,7 @@ export default class extends Channel { } // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する - if (shouldMuteThisNote(note, this.muting)) return; + if (isMutedUserRelated(note, this.muting)) return; // 流れてきたNoteがミュートすべきNoteだったら無視する // TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある) diff --git a/src/server/api/stream/channels/hybrid-timeline.ts b/src/server/api/stream/channels/hybrid-timeline.ts index bc491934e..1aec98aa7 100644 --- a/src/server/api/stream/channels/hybrid-timeline.ts +++ b/src/server/api/stream/channels/hybrid-timeline.ts @@ -1,5 +1,5 @@ import autobind from 'autobind-decorator'; -import shouldMuteThisNote from '../../../../misc/should-mute-this-note'; +import { isMutedUserRelated } from '../../../../misc/is-muted-user-related'; import Channel from '../channel'; import { fetchMeta } from '../../../../misc/fetch-meta'; import { Notes } from '../../../../models'; @@ -60,7 +60,7 @@ export default class extends Channel { } // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する - if (shouldMuteThisNote(note, this.muting)) return; + if (isMutedUserRelated(note, this.muting)) return; // 流れてきたNoteがミュートすべきNoteだったら無視する // TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある) diff --git a/src/server/api/stream/channels/local-timeline.ts b/src/server/api/stream/channels/local-timeline.ts index 3279912f8..6426ccc23 100644 --- a/src/server/api/stream/channels/local-timeline.ts +++ b/src/server/api/stream/channels/local-timeline.ts @@ -1,5 +1,5 @@ import autobind from 'autobind-decorator'; -import shouldMuteThisNote from '../../../../misc/should-mute-this-note'; +import { isMutedUserRelated } from '../../../../misc/is-muted-user-related'; import Channel from '../channel'; import { fetchMeta } from '../../../../misc/fetch-meta'; import { Notes } from '../../../../models'; @@ -48,7 +48,7 @@ export default class extends Channel { } // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する - if (shouldMuteThisNote(note, this.muting)) return; + if (isMutedUserRelated(note, this.muting)) return; // 流れてきたNoteがミュートすべきNoteだったら無視する // TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある) diff --git a/src/server/api/stream/channels/user-list.ts b/src/server/api/stream/channels/user-list.ts index e1b7a8883..4191a0de5 100644 --- a/src/server/api/stream/channels/user-list.ts +++ b/src/server/api/stream/channels/user-list.ts @@ -1,7 +1,7 @@ import autobind from 'autobind-decorator'; import Channel from '../channel'; import { Notes, UserListJoinings, UserLists } from '../../../../models'; -import shouldMuteThisNote from '../../../../misc/should-mute-this-note'; +import { isMutedUserRelated } from '../../../../misc/is-muted-user-related'; import { User } from '../../../../models/entities/user'; import { PackedNote } from '../../../../models/repositories/note'; @@ -73,7 +73,7 @@ export default class extends Channel { } // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する - if (shouldMuteThisNote(note, this.muting)) return; + if (isMutedUserRelated(note, this.muting)) return; this.send('note', note); } diff --git a/src/services/add-note-to-antenna.ts b/src/services/add-note-to-antenna.ts index 88a6613c6..57a0df275 100644 --- a/src/services/add-note-to-antenna.ts +++ b/src/services/add-note-to-antenna.ts @@ -2,7 +2,7 @@ import { Antenna } from '../models/entities/antenna'; import { Note } from '../models/entities/note'; import { AntennaNotes, Mutings, Notes } from '../models'; import { genId } from '../misc/gen-id'; -import shouldMuteThisNote from '../misc/should-mute-this-note'; +import { isMutedUserRelated } from '../misc/is-muted-user-related'; import { ensure } from '../prelude/ensure'; import { publishAntennaStream, publishMainStream } from './stream'; import { User } from '../models/entities/user'; @@ -39,7 +39,7 @@ export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: U _note.renote = await Notes.findOne(note.renoteId).then(ensure); } - if (shouldMuteThisNote(_note, mutings.map(x => x.muteeId))) { + if (isMutedUserRelated(_note, mutings.map(x => x.muteeId))) { return; }