From 6010884e623de91c03fffd780d89edfe8aa3c126 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Mon, 2 Jan 2023 21:07:56 +0100 Subject: [PATCH] cleanup: translate japanese, use SECOND constant --- .../src/remote/activitypub/kernel/undo/accept.ts | 2 +- .../endpoints/admin/federation/update-instance.ts | 2 +- .../backend/src/services/add-note-to-antenna.ts | 3 ++- packages/backend/src/services/following/create.ts | 4 ++-- packages/backend/src/services/note/unread.ts | 14 +++++++------- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/backend/src/remote/activitypub/kernel/undo/accept.ts b/packages/backend/src/remote/activitypub/kernel/undo/accept.ts index 9c5174ed6..fa4eea44c 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/accept.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/accept.ts @@ -22,5 +22,5 @@ export default async (actor: CacheableRemoteUser, activity: IAccept): Promise { +export default define(meta, paramDef, async (ps) => { const instanceExists = await Instances.countBy({ host: toPuny(ps.host) }); if (!instanceExists) { diff --git a/packages/backend/src/services/add-note-to-antenna.ts b/packages/backend/src/services/add-note-to-antenna.ts index d502be254..ecb57376c 100644 --- a/packages/backend/src/services/add-note-to-antenna.ts +++ b/packages/backend/src/services/add-note-to-antenna.ts @@ -5,6 +5,7 @@ import { genId } from '@/misc/gen-id.js'; import { isUserRelated } from '@/misc/is-user-related.js'; import { publishAntennaStream, publishMainStream } from '@/services/stream.js'; import { User } from '@/models/entities/user.js'; +import { SECOND } from '@/const.js'; export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: { id: User['id']; }): Promise { // If it's set to not notify the user, or if it's the user's own post, read it. @@ -49,6 +50,6 @@ export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: { if (unread) { publishMainStream(antenna.userId, 'unreadAntenna', antenna); } - }, 2000); + }, 2 * SECOND); } } diff --git a/packages/backend/src/services/following/create.ts b/packages/backend/src/services/following/create.ts index f588379f8..7ad85dd99 100644 --- a/packages/backend/src/services/following/create.ts +++ b/packages/backend/src/services/following/create.ts @@ -166,7 +166,7 @@ export default async function(_follower: { id: User['id'] }, _followee: { id: Us if (followee.isLocked || (followeeProfile.carefulBot && follower.isBot) || (Users.isLocalUser(follower) && Users.isRemoteUser(followee))) { let autoAccept = false; - // 鍵アカウントであっても、既にフォローされていた場合はスルー + // Even for locked accounts, if they are already following, go through immediately. const following = await Followings.countBy({ followerId: follower.id, followeeId: followee.id, @@ -175,7 +175,7 @@ export default async function(_follower: { id: User['id'] }, _followee: { id: Us autoAccept = true; } - // フォローしているユーザーは自動承認オプション + // handle automatic approval for users that follow you, if enabled if (!autoAccept && (Users.isLocalUser(followee) && followeeProfile.autoAcceptFollowed)) { const followed = await Followings.countBy({ followerId: followee.id, diff --git a/packages/backend/src/services/note/unread.ts b/packages/backend/src/services/note/unread.ts index dcd1056e3..4ef257c21 100644 --- a/packages/backend/src/services/note/unread.ts +++ b/packages/backend/src/services/note/unread.ts @@ -3,27 +3,27 @@ import { publishMainStream } from '@/services/stream.js'; import { User } from '@/models/entities/user.js'; import { Mutings, NoteThreadMutings, NoteUnreads } from '@/models/index.js'; import { genId } from '@/misc/gen-id.js'; +import { SECOND } from '@/const.js'; export async function insertNoteUnread(userId: User['id'], note: Note, params: { - // NOTE: isSpecifiedがtrueならisMentionedは必ずfalse + // NOTE: if isSpecified is true, isMentioned is always false isSpecified: boolean; isMentioned: boolean; }): Promise { - //#region ミュートしているなら無視 - // TODO: 現在の仕様ではChannelにミュートは適用されないのでよしなにケアする + //#region ignore if muted + // TODO: The current design does not apply mutes to channels. const muted = await Mutings.countBy({ muterId: userId, muteeId: note.userId, }); if (muted) return; - //#endregion const threadMuted = await NoteThreadMutings.countBy({ - // スレッドミュート userId, threadId: note.threadId || note.id, }); if (threadMuted) return; + //#endregion const unread = { id: genId(), @@ -37,7 +37,7 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: { await NoteUnreads.insert(unread); - // 2秒経っても既読にならなかったら「未読の投稿がありますよ」イベントを発行する + // Issue the events for unread messages if it hasn't been read after 2 seconds. setTimeout(async () => { const exist = await NoteUnreads.countBy({ id: unread.id }); @@ -52,5 +52,5 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: { if (note.channelId) { publishMainStream(userId, 'unreadChannel', note.id); } - }, 2000); + }, 2 * SECOND); }