From 1b9d316e7c2446211f4b5b6ec27dce0d9b4f0968 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Jul 2020 09:38:41 +0900 Subject: [PATCH] refactor: Rename function --- .../{generate-mute-query.ts => generate-muted-user-query.ts} | 4 ++-- src/server/api/common/inject-featured.ts | 4 ++-- src/server/api/endpoints/antennas/notes.ts | 4 ++-- src/server/api/endpoints/clips/notes.ts | 4 ++-- src/server/api/endpoints/notes/children.ts | 4 ++-- src/server/api/endpoints/notes/featured.ts | 4 ++-- src/server/api/endpoints/notes/global-timeline.ts | 4 ++-- src/server/api/endpoints/notes/hybrid-timeline.ts | 4 ++-- src/server/api/endpoints/notes/local-timeline.ts | 4 ++-- src/server/api/endpoints/notes/mentions.ts | 4 ++-- src/server/api/endpoints/notes/renotes.ts | 4 ++-- src/server/api/endpoints/notes/replies.ts | 4 ++-- src/server/api/endpoints/notes/search-by-tag.ts | 4 ++-- src/server/api/endpoints/notes/search.ts | 4 ++-- src/server/api/endpoints/notes/timeline.ts | 4 ++-- src/server/api/endpoints/users.ts | 4 ++-- src/server/api/endpoints/users/notes.ts | 4 ++-- src/server/api/endpoints/users/recommendation.ts | 4 ++-- 18 files changed, 36 insertions(+), 36 deletions(-) rename src/server/api/common/{generate-mute-query.ts => generate-muted-user-query.ts} (87%) diff --git a/src/server/api/common/generate-mute-query.ts b/src/server/api/common/generate-muted-user-query.ts similarity index 87% rename from src/server/api/common/generate-mute-query.ts rename to src/server/api/common/generate-muted-user-query.ts index 4504d2351..b346f2f0f 100644 --- a/src/server/api/common/generate-mute-query.ts +++ b/src/server/api/common/generate-muted-user-query.ts @@ -2,7 +2,7 @@ import { User } from '../../../models/entities/user'; import { Mutings } from '../../../models'; import { SelectQueryBuilder, Brackets } from 'typeorm'; -export function generateMuteQuery(q: SelectQueryBuilder, me: User, exclude?: User) { +export function generateMutedUserQuery(q: SelectQueryBuilder, me: User, exclude?: User) { const mutingQuery = Mutings.createQueryBuilder('muting') .select('muting.muteeId') .where('muting.muterId = :muterId', { muterId: me.id }); @@ -28,7 +28,7 @@ export function generateMuteQuery(q: SelectQueryBuilder, me: User, exclude? q.setParameters(mutingQuery.getParameters()); } -export function generateMuteQueryForUsers(q: SelectQueryBuilder, me: User) { +export function generateMutedUserQueryForUsers(q: SelectQueryBuilder, me: User) { const mutingQuery = Mutings.createQueryBuilder('muting') .select('muting.muteeId') .where('muting.muterId = :muterId', { muterId: me.id }); diff --git a/src/server/api/common/inject-featured.ts b/src/server/api/common/inject-featured.ts index 92e1e3b39..098d20e72 100644 --- a/src/server/api/common/inject-featured.ts +++ b/src/server/api/common/inject-featured.ts @@ -2,7 +2,7 @@ import rndstr from 'rndstr'; import { Note } from '../../../models/entities/note'; import { User } from '../../../models/entities/user'; import { Notes, UserProfiles, NoteReactions } from '../../../models'; -import { generateMuteQuery } from './generate-mute-query'; +import { generateMutedUserQuery } from './generate-muted-user-query'; import { ensure } from '../../../prelude/ensure'; // TODO: リアクション、Renote、返信などをしたノートは除外する @@ -29,7 +29,7 @@ export async function injectFeatured(timeline: Note[], user?: User | null) { if (user) { query.andWhere('note.userId != :userId', { userId: user.id }); - generateMuteQuery(query, user); + generateMutedUserQuery(query, user); const reactionQuery = NoteReactions.createQueryBuilder('reaction') .select('reaction.noteId') diff --git a/src/server/api/endpoints/antennas/notes.ts b/src/server/api/endpoints/antennas/notes.ts index 54af6c7d3..402a2758b 100644 --- a/src/server/api/endpoints/antennas/notes.ts +++ b/src/server/api/endpoints/antennas/notes.ts @@ -4,7 +4,7 @@ import define from '../../define'; import { Antennas, Notes, AntennaNotes } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { ApiError } from '../../error'; export const meta = { @@ -62,7 +62,7 @@ export default define(meta, async (ps, user) => { .setParameters(antennaQuery.getParameters()); generateVisibilityQuery(query, user); - generateMuteQuery(query, user); + generateMutedUserQuery(query, user); const notes = await query .take(ps.limit!) diff --git a/src/server/api/endpoints/clips/notes.ts b/src/server/api/endpoints/clips/notes.ts index d4d994d55..4cd7e8c62 100644 --- a/src/server/api/endpoints/clips/notes.ts +++ b/src/server/api/endpoints/clips/notes.ts @@ -4,7 +4,7 @@ import define from '../../define'; import { Clips, Notes } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; export const meta = { tags: ['account', 'notes', 'clips'], @@ -57,7 +57,7 @@ export default define(meta, async (ps, user) => { .setParameters(clipQuery.getParameters()); generateVisibilityQuery(query, user); - generateMuteQuery(query, user); + generateMutedUserQuery(query, user); const notes = await query .take(ps.limit!) diff --git a/src/server/api/endpoints/notes/children.ts b/src/server/api/endpoints/notes/children.ts index e1a5cc1c8..0875e0f24 100644 --- a/src/server/api/endpoints/notes/children.ts +++ b/src/server/api/endpoints/notes/children.ts @@ -3,7 +3,7 @@ import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { Brackets } from 'typeorm'; import { Notes } from '../../../../models'; @@ -67,7 +67,7 @@ export default define(meta, async (ps, user) => { .leftJoinAndSelect('note.user', 'user'); generateVisibilityQuery(query, user); - if (user) generateMuteQuery(query, user); + if (user) generateMutedUserQuery(query, user); const notes = await query.take(ps.limit!).getMany(); diff --git a/src/server/api/endpoints/notes/featured.ts b/src/server/api/endpoints/notes/featured.ts index 0dc705de7..4dda7d0ed 100644 --- a/src/server/api/endpoints/notes/featured.ts +++ b/src/server/api/endpoints/notes/featured.ts @@ -1,6 +1,6 @@ import $ from 'cafy'; import define from '../../define'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { Notes } from '../../../../models'; export const meta = { @@ -51,7 +51,7 @@ export default define(meta, async (ps, user) => { .andWhere(`note.visibility = 'public'`) .leftJoinAndSelect('note.user', 'user'); - if (user) generateMuteQuery(query, user); + if (user) generateMutedUserQuery(query, user); let notes = await query .orderBy('note.score', 'DESC') diff --git a/src/server/api/endpoints/notes/global-timeline.ts b/src/server/api/endpoints/notes/global-timeline.ts index 4361b8a29..5e61c1784 100644 --- a/src/server/api/endpoints/notes/global-timeline.ts +++ b/src/server/api/endpoints/notes/global-timeline.ts @@ -5,7 +5,7 @@ import { fetchMeta } from '../../../../misc/fetch-meta'; import { ApiError } from '../../error'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { Notes } from '../../../../models'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { activeUsersChart } from '../../../../services/chart'; import { generateRepliesQuery } from '../../common/generate-replies-query'; import { injectPromo } from '../../common/inject-promo'; @@ -83,7 +83,7 @@ export default define(meta, async (ps, user) => { .leftJoinAndSelect('note.user', 'user'); generateRepliesQuery(query, user); - if (user) generateMuteQuery(query, user); + if (user) generateMutedUserQuery(query, user); if (user) generateMutedNoteQuery(query, user); if (ps.withFiles) { diff --git a/src/server/api/endpoints/notes/hybrid-timeline.ts b/src/server/api/endpoints/notes/hybrid-timeline.ts index 82199e607..fab4e9f4e 100644 --- a/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -7,7 +7,7 @@ import { makePaginationQuery } from '../../common/make-pagination-query'; import { Followings, Notes } from '../../../../models'; import { Brackets } from 'typeorm'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { activeUsersChart } from '../../../../services/chart'; import { generateRepliesQuery } from '../../common/generate-replies-query'; import { injectPromo } from '../../common/inject-promo'; @@ -133,7 +133,7 @@ export default define(meta, async (ps, user) => { generateRepliesQuery(query, user); generateVisibilityQuery(query, user); - generateMuteQuery(query, user); + generateMutedUserQuery(query, user); generateMutedNoteQuery(query, user); if (ps.includeMyRenotes === false) { diff --git a/src/server/api/endpoints/notes/local-timeline.ts b/src/server/api/endpoints/notes/local-timeline.ts index 9d51b3b48..38ec1d472 100644 --- a/src/server/api/endpoints/notes/local-timeline.ts +++ b/src/server/api/endpoints/notes/local-timeline.ts @@ -4,7 +4,7 @@ import define from '../../define'; import { fetchMeta } from '../../../../misc/fetch-meta'; import { ApiError } from '../../error'; import { Notes } from '../../../../models'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; import { activeUsersChart } from '../../../../services/chart'; @@ -101,7 +101,7 @@ export default define(meta, async (ps, user) => { generateRepliesQuery(query, user); generateVisibilityQuery(query, user); - if (user) generateMuteQuery(query, user); + if (user) generateMutedUserQuery(query, user); if (user) generateMutedNoteQuery(query, user); if (ps.withFiles) { diff --git a/src/server/api/endpoints/notes/mentions.ts b/src/server/api/endpoints/notes/mentions.ts index a478d89c0..8a9d295d3 100644 --- a/src/server/api/endpoints/notes/mentions.ts +++ b/src/server/api/endpoints/notes/mentions.ts @@ -4,7 +4,7 @@ import define from '../../define'; import read from '../../../../services/note/read'; import { Notes, Followings } from '../../../../models'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { Brackets } from 'typeorm'; @@ -66,7 +66,7 @@ export default define(meta, async (ps, user) => { .leftJoinAndSelect('note.user', 'user'); generateVisibilityQuery(query, user); - generateMuteQuery(query, user); + generateMutedUserQuery(query, user); if (ps.visibility) { query.andWhere('note.visibility = :visibility', { visibility: ps.visibility }); diff --git a/src/server/api/endpoints/notes/renotes.ts b/src/server/api/endpoints/notes/renotes.ts index 1a6f66b36..31c24f294 100644 --- a/src/server/api/endpoints/notes/renotes.ts +++ b/src/server/api/endpoints/notes/renotes.ts @@ -4,7 +4,7 @@ import define from '../../define'; import { getNote } from '../../common/getters'; import { ApiError } from '../../error'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { Notes } from '../../../../models'; @@ -71,7 +71,7 @@ export default define(meta, async (ps, user) => { .leftJoinAndSelect('note.user', 'user'); generateVisibilityQuery(query, user); - if (user) generateMuteQuery(query, user); + if (user) generateMutedUserQuery(query, user); const renotes = await query.take(ps.limit!).getMany(); diff --git a/src/server/api/endpoints/notes/replies.ts b/src/server/api/endpoints/notes/replies.ts index 3bf16804e..9fad74c78 100644 --- a/src/server/api/endpoints/notes/replies.ts +++ b/src/server/api/endpoints/notes/replies.ts @@ -4,7 +4,7 @@ import define from '../../define'; import { Notes } from '../../../../models'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; export const meta = { desc: { @@ -62,7 +62,7 @@ export default define(meta, async (ps, user) => { .leftJoinAndSelect('note.user', 'user'); generateVisibilityQuery(query, user); - if (user) generateMuteQuery(query, user); + if (user) generateMutedUserQuery(query, user); const timeline = await query.take(ps.limit!).getMany(); diff --git a/src/server/api/endpoints/notes/search-by-tag.ts b/src/server/api/endpoints/notes/search-by-tag.ts index b30fe732e..446beb32d 100644 --- a/src/server/api/endpoints/notes/search-by-tag.ts +++ b/src/server/api/endpoints/notes/search-by-tag.ts @@ -3,7 +3,7 @@ import { ID } from '../../../../misc/cafy-id'; import define from '../../define'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { Notes } from '../../../../models'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; import { Brackets } from 'typeorm'; import { safeForSql } from '../../../../misc/safe-for-sql'; @@ -97,7 +97,7 @@ export default define(meta, async (ps, me) => { .leftJoinAndSelect('note.user', 'user'); generateVisibilityQuery(query, me); - if (me) generateMuteQuery(query, me); + if (me) generateMutedUserQuery(query, me); if (ps.tag) { if (!safeForSql(ps.tag)) return; diff --git a/src/server/api/endpoints/notes/search.ts b/src/server/api/endpoints/notes/search.ts index 602c1a71f..2c75d2a55 100644 --- a/src/server/api/endpoints/notes/search.ts +++ b/src/server/api/endpoints/notes/search.ts @@ -7,7 +7,7 @@ import { ID } from '../../../../misc/cafy-id'; import config from '../../../../config'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; export const meta = { desc: { @@ -69,7 +69,7 @@ export default define(meta, async (ps, me) => { .leftJoinAndSelect('note.user', 'user'); generateVisibilityQuery(query, me); - if (me) generateMuteQuery(query, me); + if (me) generateMutedUserQuery(query, me); const notes = await query.take(ps.limit!).getMany(); diff --git a/src/server/api/endpoints/notes/timeline.ts b/src/server/api/endpoints/notes/timeline.ts index c6929f4a5..657739820 100644 --- a/src/server/api/endpoints/notes/timeline.ts +++ b/src/server/api/endpoints/notes/timeline.ts @@ -4,7 +4,7 @@ import define from '../../define'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { Notes, Followings } from '../../../../models'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { activeUsersChart } from '../../../../services/chart'; import { Brackets } from 'typeorm'; import { generateRepliesQuery } from '../../common/generate-replies-query'; @@ -126,7 +126,7 @@ export default define(meta, async (ps, user) => { generateRepliesQuery(query, user); generateVisibilityQuery(query, user); - generateMuteQuery(query, user); + generateMutedUserQuery(query, user); generateMutedNoteQuery(query, user); if (ps.includeMyRenotes === false) { diff --git a/src/server/api/endpoints/users.ts b/src/server/api/endpoints/users.ts index d21dceb27..9d7991b40 100644 --- a/src/server/api/endpoints/users.ts +++ b/src/server/api/endpoints/users.ts @@ -1,7 +1,7 @@ import $ from 'cafy'; import define from '../define'; import { Users } from '../../../models'; -import { generateMuteQueryForUsers } from '../common/generate-mute-query'; +import { generateMutedUserQueryForUsers } from '../common/generate-muted-user-query'; export const meta = { tags: ['users'], @@ -87,7 +87,7 @@ export default define(meta, async (ps, me) => { default: query.orderBy('user.id', 'ASC'); break; } - if (me) generateMuteQueryForUsers(query, me); + if (me) generateMutedUserQueryForUsers(query, me); query.take(ps.limit!); query.skip(ps.offset); diff --git a/src/server/api/endpoints/users/notes.ts b/src/server/api/endpoints/users/notes.ts index f5f08dc89..33e3ecb03 100644 --- a/src/server/api/endpoints/users/notes.ts +++ b/src/server/api/endpoints/users/notes.ts @@ -6,7 +6,7 @@ import { getUser } from '../../common/getters'; import { makePaginationQuery } from '../../common/make-pagination-query'; import { generateVisibilityQuery } from '../../common/generate-visibility-query'; import { Notes } from '../../../../models'; -import { generateMuteQuery } from '../../common/generate-mute-query'; +import { generateMutedUserQuery } from '../../common/generate-muted-user-query'; import { Brackets } from 'typeorm'; export const meta = { @@ -134,7 +134,7 @@ export default define(meta, async (ps, me) => { .leftJoinAndSelect('note.user', 'user'); generateVisibilityQuery(query, me); - if (me) generateMuteQuery(query, me, user); + if (me) generateMutedUserQuery(query, me, user); if (ps.withFiles) { query.andWhere('note.fileIds != \'{}\''); diff --git a/src/server/api/endpoints/users/recommendation.ts b/src/server/api/endpoints/users/recommendation.ts index 73ac615d4..1b59624aa 100644 --- a/src/server/api/endpoints/users/recommendation.ts +++ b/src/server/api/endpoints/users/recommendation.ts @@ -2,7 +2,7 @@ import * as ms from 'ms'; import $ from 'cafy'; import define from '../../define'; import { Users, Followings } from '../../../../models'; -import { generateMuteQueryForUsers } from '../../common/generate-mute-query'; +import { generateMutedUserQueryForUsers } from '../../common/generate-muted-user-query'; import { generateBlockQueryForUsers } from '../../common/generate-block-query'; export const meta = { @@ -47,7 +47,7 @@ export default define(meta, async (ps, me) => { .andWhere('user.id != :meId', { meId: me.id }) .orderBy('user.followersCount', 'DESC'); - generateMuteQueryForUsers(query, me); + generateMutedUserQueryForUsers(query, me); generateBlockQueryForUsers(query, me); const followingQuery = Followings.createQueryBuilder('following')