refactor: resolve #7139
This commit is contained in:
parent
ebadd7fd3f
commit
91172654e4
76 changed files with 107 additions and 221 deletions
|
|
@ -3,7 +3,6 @@ import { Note } from '../models/entities/note';
|
|||
import { AntennaNotes, Mutings, Notes } from '../models';
|
||||
import { genId } from '../misc/gen-id';
|
||||
import { isMutedUserRelated } from '../misc/is-muted-user-related';
|
||||
import { ensure } from '../prelude/ensure';
|
||||
import { publishAntennaStream, publishMainStream } from './stream';
|
||||
import { User } from '../models/entities/user';
|
||||
|
||||
|
|
@ -34,10 +33,10 @@ export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: U
|
|||
};
|
||||
|
||||
if (note.replyId != null) {
|
||||
_note.reply = await Notes.findOne(note.replyId).then(ensure);
|
||||
_note.reply = await Notes.findOneOrFail(note.replyId);
|
||||
}
|
||||
if (note.renoteId != null) {
|
||||
_note.renote = await Notes.findOne(note.renoteId).then(ensure);
|
||||
_note.renote = await Notes.findOneOrFail(note.renoteId);
|
||||
}
|
||||
|
||||
if (isMutedUserRelated(_note, new Set<string>(mutings.map(x => x.muteeId)))) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import { instanceChart, perUserFollowingChart } from '../chart';
|
|||
import { genId } from '../../misc/gen-id';
|
||||
import { createNotification } from '../create-notification';
|
||||
import { isDuplicateKeyValueError } from '../../misc/is-duplicate-key-value-error';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
|
||||
const logger = new Logger('following/create');
|
||||
|
||||
|
|
@ -130,7 +129,7 @@ export default async function(follower: User, followee: User, requestId?: string
|
|||
if (blocked != null) throw new IdentifiableError('3338392a-f764-498d-8855-db939dcf8c48', 'blocked');
|
||||
}
|
||||
|
||||
const followeeProfile = await UserProfiles.findOne(followee.id).then(ensure);
|
||||
const followeeProfile = await UserProfiles.findOneOrFail(followee.id);
|
||||
|
||||
// フォロー対象が鍵アカウントである or
|
||||
// フォロワーがBotであり、フォロー対象がBotからのフォローに慎重である or
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import accept from './accept';
|
||||
import { User } from '../../../models/entities/user';
|
||||
import { FollowRequests, Users } from '../../../models';
|
||||
import { ensure } from '../../../prelude/ensure';
|
||||
|
||||
/**
|
||||
* 指定したユーザー宛てのフォローリクエストをすべて承認
|
||||
|
|
@ -13,7 +12,7 @@ export default async function(user: User) {
|
|||
});
|
||||
|
||||
for (const request of requests) {
|
||||
const follower = await Users.findOne(request.followerId).then(ensure);
|
||||
const follower = await Users.findOneOrFail(request.followerId);
|
||||
accept(user, follower);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import config from '../../config';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { MessagingMessages, Users } from '../../models';
|
||||
import { MessagingMessage } from '../../models/entities/messaging-message';
|
||||
import { publishGroupMessagingStream, publishMessagingStream } from '../stream';
|
||||
|
|
@ -15,8 +14,8 @@ export async function deleteMessage(message: MessagingMessage) {
|
|||
|
||||
async function postDeleteMessage(message: MessagingMessage) {
|
||||
if (message.recipientId) {
|
||||
const user = await Users.findOne(message.userId).then(ensure);
|
||||
const recipient = await Users.findOne(message.recipientId).then(ensure);
|
||||
const user = await Users.findOneOrFail(message.userId);
|
||||
const recipient = await Users.findOneOrFail(message.recipientId);
|
||||
|
||||
if (Users.isLocalUser(user)) publishMessagingStream(message.userId, message.recipientId, 'deleted', message.id);
|
||||
if (Users.isLocalUser(recipient)) publishMessagingStream(message.recipientId, message.userId, 'deleted', message.id);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import { notesChart, perUserNotesChart, activeUsersChart, instanceChart } from '
|
|||
import { Poll, IPoll } from '../../models/entities/poll';
|
||||
import { createNotification } from '../create-notification';
|
||||
import { isDuplicateKeyValueError } from '../../misc/is-duplicate-key-value-error';
|
||||
import { ensure } from '../../prelude/ensure';
|
||||
import { checkHitAntenna } from '../../misc/check-hit-antenna';
|
||||
import { checkWordMute } from '../../misc/check-word-mute';
|
||||
import { addNoteToAntenna } from '../add-note-to-antenna';
|
||||
|
|
@ -200,7 +199,7 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
|
|||
tags = tags.filter(tag => Array.from(tag || '').length <= 128).splice(0, 32);
|
||||
|
||||
if (data.reply && (user.id !== data.reply.userId) && !mentionedUsers.some(u => u.id === data.reply!.userId)) {
|
||||
mentionedUsers.push(await Users.findOne(data.reply.userId).then(ensure));
|
||||
mentionedUsers.push(await Users.findOneOrFail(data.reply.userId));
|
||||
}
|
||||
|
||||
if (data.visibility == 'specified') {
|
||||
|
|
@ -213,7 +212,7 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
|
|||
}
|
||||
|
||||
if (data.reply && !data.visibleUsers.some(x => x.id === data.reply!.userId)) {
|
||||
data.visibleUsers.push(await Users.findOne(data.reply.userId).then(ensure));
|
||||
data.visibleUsers.push(await Users.findOneOrFail(data.reply.userId));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue