mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 09:57:29 -07:00
refactor(backend): use insert instead of save
This commit is contained in:
parent
9560c899a1
commit
1e31e8d1ca
6 changed files with 10 additions and 10 deletions
|
@ -46,7 +46,7 @@ export default define(meta, async (ps, user) => {
|
|||
const permission = unique(ps.permission.map(v => v.replace(/^(.+)(\/|-)(read|write)$/, '$3:$1')));
|
||||
|
||||
// Create account
|
||||
const app = await Apps.save({
|
||||
const app = await Apps.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
userId: user ? user.id : null,
|
||||
|
@ -55,7 +55,7 @@ export default define(meta, async (ps, user) => {
|
|||
permission,
|
||||
callbackUrl: ps.callbackUrl,
|
||||
secret: secret,
|
||||
});
|
||||
}).then(x => Apps.findOneOrFail(x.identifiers[0]));
|
||||
|
||||
return await Apps.pack(app, null, {
|
||||
detail: true,
|
||||
|
|
|
@ -56,14 +56,14 @@ export default define(meta, async (ps, user) => {
|
|||
}
|
||||
}
|
||||
|
||||
const channel = await Channels.save({
|
||||
const channel = await Channels.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
userId: user.id,
|
||||
name: ps.name,
|
||||
description: ps.description || null,
|
||||
bannerId: banner ? banner.id : null,
|
||||
} as Channel);
|
||||
} as Channel).then(x => Channels.findOneOrFail(x.identifiers[0]));
|
||||
|
||||
return await Channels.pack(channel, user);
|
||||
});
|
||||
|
|
|
@ -130,7 +130,7 @@ export default define(meta, async (ps, user) => {
|
|||
|
||||
const credentialIdString = credentialId.toString('hex');
|
||||
|
||||
await UserSecurityKeys.save({
|
||||
await UserSecurityKeys.insert({
|
||||
userId: user.id,
|
||||
id: credentialIdString,
|
||||
lastUsed: new Date(),
|
||||
|
|
|
@ -45,7 +45,7 @@ export default define(meta, async (ps, user) => {
|
|||
|
||||
const challengeId = genId();
|
||||
|
||||
await AttestationChallenges.save({
|
||||
await AttestationChallenges.insert({
|
||||
userId: user.id,
|
||||
id: challengeId,
|
||||
challenge: hash(Buffer.from(challenge, 'utf-8')).toString('hex'),
|
||||
|
|
|
@ -25,7 +25,7 @@ export default async function(follower: { id: User['id']; host: User['host']; ur
|
|||
if (blocking != null) throw new Error('blocking');
|
||||
if (blocked != null) throw new Error('blocked');
|
||||
|
||||
const followRequest = await FollowRequests.save({
|
||||
const followRequest = await FollowRequests.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
followerId: follower.id,
|
||||
|
@ -39,7 +39,7 @@ export default async function(follower: { id: User['id']; host: User['host']; ur
|
|||
followeeHost: followee.host,
|
||||
followeeInbox: Users.isRemoteUser(followee) ? followee.inbox : undefined,
|
||||
followeeSharedInbox: Users.isRemoteUser(followee) ? followee.sharedInbox : undefined,
|
||||
});
|
||||
}).then(x => FollowRequests.findOneOrFail(x.identifiers[0]));
|
||||
|
||||
// Publish receiveRequest event
|
||||
if (Users.isLocalUser(followee)) {
|
||||
|
|
|
@ -16,12 +16,12 @@ export async function registerOrFetchInstanceDoc(host: string): Promise<Instance
|
|||
const index = await Instances.findOne({ host });
|
||||
|
||||
if (index == null) {
|
||||
const i = await Instances.save({
|
||||
const i = await Instances.insert({
|
||||
id: genId(),
|
||||
host,
|
||||
caughtAt: new Date(),
|
||||
lastCommunicatedAt: new Date(),
|
||||
});
|
||||
}).then(x => Instances.findOneOrFail(x.identifiers[0]));
|
||||
|
||||
federationChart.update(true);
|
||||
|
||||
|
|
Loading…
Reference in a new issue