テーブル分割
This commit is contained in:
parent
9603f3fa4f
commit
626cfb61ac
33 changed files with 267 additions and 232 deletions
|
@ -10,7 +10,9 @@ import extractHashtags from '../../../../misc/extract-hashtags';
|
|||
import * as langmap from 'langmap';
|
||||
import { updateHashtag } from '../../../../services/update-hashtag';
|
||||
import { ApiError } from '../../error';
|
||||
import { Users, DriveFiles } from '../../../../models';
|
||||
import { Users, DriveFiles, UserProfiles } from '../../../../models';
|
||||
import { User } from '../../../../models/entities/user';
|
||||
import { UserProfile } from '../../../../models/entities/user-profile';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
|
@ -154,22 +156,23 @@ export const meta = {
|
|||
export default define(meta, async (ps, user, app) => {
|
||||
const isSecure = user != null && app == null;
|
||||
|
||||
const updates = {} as any;
|
||||
const updates = {} as Partial<User>;
|
||||
const profile = {} as Partial<UserProfile>;
|
||||
|
||||
if (ps.name !== undefined) updates.name = ps.name;
|
||||
if (ps.description !== undefined) updates.description = ps.description;
|
||||
if (ps.lang !== undefined) updates.lang = ps.lang;
|
||||
if (ps.location !== undefined) updates.location = ps.location;
|
||||
if (ps.birthday !== undefined) updates.birthday = ps.birthday;
|
||||
if (ps.description !== undefined) profile.description = ps.description;
|
||||
//if (ps.lang !== undefined) updates.lang = ps.lang;
|
||||
if (ps.location !== undefined) profile.location = ps.location;
|
||||
if (ps.birthday !== undefined) profile.birthday = ps.birthday;
|
||||
if (ps.avatarId !== undefined) updates.avatarId = ps.avatarId;
|
||||
if (ps.bannerId !== undefined) updates.bannerId = ps.bannerId;
|
||||
if (typeof ps.isLocked == 'boolean') updates.isLocked = ps.isLocked;
|
||||
if (typeof ps.isBot == 'boolean') updates.isBot = ps.isBot;
|
||||
if (typeof ps.carefulBot == 'boolean') updates.carefulBot = ps.carefulBot;
|
||||
if (typeof ps.autoAcceptFollowed == 'boolean') updates.autoAcceptFollowed = ps.autoAcceptFollowed;
|
||||
if (typeof ps.carefulBot == 'boolean') profile.carefulBot = ps.carefulBot;
|
||||
if (typeof ps.autoAcceptFollowed == 'boolean') profile.autoAcceptFollowed = ps.autoAcceptFollowed;
|
||||
if (typeof ps.isCat == 'boolean') updates.isCat = ps.isCat;
|
||||
if (typeof ps.autoWatch == 'boolean') updates.autoWatch = ps.autoWatch;
|
||||
if (typeof ps.alwaysMarkNsfw == 'boolean') updates.alwaysMarkNsfw = ps.alwaysMarkNsfw;
|
||||
if (typeof ps.autoWatch == 'boolean') profile.autoWatch = ps.autoWatch;
|
||||
if (typeof ps.alwaysMarkNsfw == 'boolean') profile.alwaysMarkNsfw = ps.alwaysMarkNsfw;
|
||||
|
||||
if (ps.avatarId) {
|
||||
const avatar = await DriveFiles.findOne(ps.avatarId);
|
||||
|
@ -206,8 +209,8 @@ export default define(meta, async (ps, user, app) => {
|
|||
emojis = emojis.concat(extractEmojis(tokens));
|
||||
}
|
||||
|
||||
if (updates.description != null) {
|
||||
const tokens = parse(updates.description);
|
||||
if (profile.description != null) {
|
||||
const tokens = parse(profile.description);
|
||||
emojis = emojis.concat(extractEmojis(tokens));
|
||||
tags = extractHashtags(tokens).map(tag => tag.toLowerCase());
|
||||
}
|
||||
|
@ -221,6 +224,7 @@ export default define(meta, async (ps, user, app) => {
|
|||
//#endregion
|
||||
|
||||
await Users.update(user.id, updates);
|
||||
await UserProfiles.update({ userId: user.id }, profile);
|
||||
|
||||
const iObj = await Users.pack(user.id, user, {
|
||||
detail: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue