clean up など

This commit is contained in:
syuilo
2021-03-20 15:42:02 +09:00
parent 73df95c42d
commit 9bb6dc52b8
5 changed files with 4 additions and 86 deletions

View File

@@ -1,6 +1,5 @@
import define from '../define';
import { RegistryItems, UserProfiles, Users } from '../../../models';
import { genId } from '../../../misc/gen-id';
import { Users } from '../../../models';
export const meta = {
desc: {
@@ -23,28 +22,8 @@ export const meta = {
export default define(meta, async (ps, user, token) => {
const isSecure = token == null;
// TODO: そのうち消
const profile = await UserProfiles.findOneOrFail(user.id);
for (const [k, v] of Object.entries(profile.clientData)) {
await RegistryItems.insert({
id: genId(),
createdAt: new Date(),
updatedAt: new Date(),
userId: user.id,
domain: null,
scope: ['client', 'base'],
key: k,
value: v
});
}
await UserProfiles.createQueryBuilder().update()
.set({
clientData: {},
})
.where('userId = :id', { id: user.id })
.execute();
return await Users.pack(user, user, {
// ここで渡ってきている user はキャッシュされていて古い可能性もあるので id だけ渡
return await Users.pack(user.id, user, {
detail: true,
includeSecrets: isSecure
});