Refactor
This commit is contained in:
parent
85959a3b9b
commit
0ede390fef
|
@ -82,7 +82,7 @@ export class UserRepository extends Repository<User> {
|
||||||
|
|
||||||
const relation = meId && (meId !== user.id) && opts.detail ? await this.getRelation(meId, user.id) : null;
|
const relation = meId && (meId !== user.id) && opts.detail ? await this.getRelation(meId, user.id) : null;
|
||||||
const pins = opts.detail ? await UserNotePinings.find({ userId: user.id }) : [];
|
const pins = opts.detail ? await UserNotePinings.find({ userId: user.id }) : [];
|
||||||
const profile = opts.detail ? await UserProfiles.findOne({ userId: user.id }).then(ensure) : null;
|
const profile = opts.detail ? await UserProfiles.findOne(user.id).then(ensure) : null;
|
||||||
|
|
||||||
const falsy = opts.detail ? false : undefined;
|
const falsy = opts.detail ? false : undefined;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ export async function renderPerson(user: ILocalUser) {
|
||||||
const [avatar, banner, profile] = await Promise.all([
|
const [avatar, banner, profile] = await Promise.all([
|
||||||
user.avatarId ? DriveFiles.findOne(user.avatarId) : Promise.resolve(undefined),
|
user.avatarId ? DriveFiles.findOne(user.avatarId) : Promise.resolve(undefined),
|
||||||
user.bannerId ? DriveFiles.findOne(user.bannerId) : Promise.resolve(undefined),
|
user.bannerId ? DriveFiles.findOne(user.bannerId) : Promise.resolve(undefined),
|
||||||
UserProfiles.findOne({ userId: user.id }).then(ensure)
|
UserProfiles.findOne(user.id).then(ensure)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const attachment: {
|
const attachment: {
|
||||||
|
|
|
@ -19,7 +19,7 @@ export const meta = {
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, async (ps, user) => {
|
||||||
const token = ps.token.replace(/\s/g, '');
|
const token = ps.token.replace(/\s/g, '');
|
||||||
|
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
if (profile.twoFactorTempSecret == null) {
|
if (profile.twoFactorTempSecret == null) {
|
||||||
throw new Error('二段階認証の設定が開始されていません');
|
throw new Error('二段階認証の設定が開始されていません');
|
||||||
|
|
|
@ -20,7 +20,7 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, async (ps, user) => {
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
// Compare password
|
// Compare password
|
||||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||||
|
|
|
@ -17,7 +17,7 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, async (ps, user) => {
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
// Compare password
|
// Compare password
|
||||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, async (ps, user) => {
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
// Compare password
|
// Compare password
|
||||||
const same = await bcrypt.compare(ps.currentPassword, profile.password!);
|
const same = await bcrypt.compare(ps.currentPassword, profile.password!);
|
||||||
|
|
|
@ -17,7 +17,7 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, async (ps, user) => {
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
// Compare password
|
// Compare password
|
||||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||||
|
|
|
@ -19,7 +19,7 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, async (ps, user) => {
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
// Compare password
|
// Compare password
|
||||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||||
|
|
|
@ -33,7 +33,7 @@ export const meta = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, async (ps, user) => {
|
export default define(meta, async (ps, user) => {
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
// Compare password
|
// Compare password
|
||||||
const same = await bcrypt.compare(ps.password, profile.password!);
|
const same = await bcrypt.compare(ps.password, profile.password!);
|
||||||
|
|
|
@ -160,7 +160,7 @@ export default define(meta, async (ps, user, app) => {
|
||||||
const updates = {} as Partial<User>;
|
const updates = {} as Partial<User>;
|
||||||
const profileUpdates = {} as Partial<UserProfile>;
|
const profileUpdates = {} as Partial<UserProfile>;
|
||||||
|
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
if (ps.name !== undefined) updates.name = ps.name;
|
if (ps.name !== undefined) updates.name = ps.name;
|
||||||
if (ps.description !== undefined) profileUpdates.description = ps.description;
|
if (ps.description !== undefined) profileUpdates.description = ps.description;
|
||||||
|
|
|
@ -150,7 +150,7 @@ export default define(meta, async (ps, user) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
// この投稿をWatchする
|
// この投稿をWatchする
|
||||||
if (profile.autoWatch !== false) {
|
if (profile.autoWatch !== false) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ export default async (ctx: Koa.BaseContext) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
// Compare password
|
// Compare password
|
||||||
const same = await bcrypt.compare(password, profile.password!);
|
const same = await bcrypt.compare(password, profile.password!);
|
||||||
|
|
|
@ -11,7 +11,7 @@ export default async function(user: User) {
|
||||||
name: user.name || user.username
|
name: user.name || user.username
|
||||||
};
|
};
|
||||||
|
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
const notes = await Notes.find({
|
const notes = await Notes.find({
|
||||||
where: {
|
where: {
|
||||||
|
|
|
@ -372,7 +372,7 @@ export default async function(
|
||||||
propPromises = [calcWh(), calcAvg()];
|
propPromises = [calcWh(), calcAvg()];
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id });
|
const profile = await UserProfiles.findOne(user.id);
|
||||||
|
|
||||||
const [folder] = await Promise.all([fetchFolder(), Promise.all(propPromises)]);
|
const [folder] = await Promise.all([fetchFolder(), Promise.all(propPromises)]);
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
|
||||||
deliverNoteToMentionedRemoteUsers(mentionedUsers, user, noteActivity);
|
deliverNoteToMentionedRemoteUsers(mentionedUsers, user, noteActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id }).then(ensure);
|
const profile = await UserProfiles.findOne(user.id).then(ensure);
|
||||||
|
|
||||||
// If has in reply to note
|
// If has in reply to note
|
||||||
if (data.reply) {
|
if (data.reply) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ export default async function(user: User, note: Note, choice: number) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id });
|
const profile = await UserProfiles.findOne(user.id);
|
||||||
|
|
||||||
// ローカルユーザーが投票した場合この投稿をWatchする
|
// ローカルユーザーが投票した場合この投稿をWatchする
|
||||||
if (Users.isLocalUser(user) && profile!.autoWatch) {
|
if (Users.isLocalUser(user) && profile!.autoWatch) {
|
||||||
|
|
|
@ -80,7 +80,7 @@ export default async (user: User, note: Note, reaction?: string) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const profile = await UserProfiles.findOne({ userId: user.id });
|
const profile = await UserProfiles.findOne(user.id);
|
||||||
|
|
||||||
// ユーザーがローカルユーザーかつ自動ウォッチ設定がオンならばこの投稿をWatchする
|
// ユーザーがローカルユーザーかつ自動ウォッチ設定がオンならばこの投稿をWatchする
|
||||||
if (Users.isLocalUser(user) && profile!.autoWatch) {
|
if (Users.isLocalUser(user) && profile!.autoWatch) {
|
||||||
|
|
Loading…
Reference in New Issue