refactor(backend): use insert instead of save

This commit is contained in:
syuilo
2022-01-26 00:51:26 +09:00
parent 91c56ceb6e
commit 37a4e5f4fc
6 changed files with 10 additions and 10 deletions

View File

@ -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)) {

View File

@ -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);