mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 14:28:51 +08:00
@@ -112,9 +112,11 @@ export class DocModel extends BaseModel {
|
||||
},
|
||||
},
|
||||
});
|
||||
this.logger.log(
|
||||
`Deleted ${count} updates for workspace ${workspaceId} doc ${docId}`
|
||||
);
|
||||
if (count > 0) {
|
||||
this.logger.log(
|
||||
`Deleted ${count} updates for workspace ${workspaceId} doc ${docId}`
|
||||
);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export class HistoryModel extends BaseModel {
|
||||
expiredAt: new Date(Date.now() + maxAge),
|
||||
},
|
||||
});
|
||||
this.logger.log(
|
||||
this.logger.debug(
|
||||
`Created history ${row.timestamp} for ${snapshot.docId} in ${snapshot.spaceId}`
|
||||
);
|
||||
return {
|
||||
@@ -163,7 +163,9 @@ export class HistoryModel extends BaseModel {
|
||||
},
|
||||
},
|
||||
});
|
||||
this.logger.log(`Deleted ${count} expired histories`);
|
||||
if (count > 0) {
|
||||
this.logger.log(`Deleted ${count} expired histories`);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ export class NotificationModel extends BaseModel {
|
||||
type: NotificationType.Mention,
|
||||
body: data.body,
|
||||
});
|
||||
this.logger.log(
|
||||
this.logger.debug(
|
||||
`Created mention notification:${row.id} for user:${data.userId} in workspace:${data.body.workspaceId}`
|
||||
);
|
||||
return row as MentionNotification;
|
||||
@@ -154,7 +154,7 @@ export class NotificationModel extends BaseModel {
|
||||
type,
|
||||
body: data.body,
|
||||
});
|
||||
this.logger.log(
|
||||
this.logger.debug(
|
||||
`Created ${type} notification ${row.id} to user ${data.userId} in workspace ${data.body.workspaceId}`
|
||||
);
|
||||
return row as InvitationNotification;
|
||||
@@ -171,7 +171,7 @@ export class NotificationModel extends BaseModel {
|
||||
type,
|
||||
body: data.body,
|
||||
});
|
||||
this.logger.log(
|
||||
this.logger.debug(
|
||||
`Created ${type} notification ${row.id} to user ${data.userId} in workspace ${data.body.workspaceId}`
|
||||
);
|
||||
return row as InvitationReviewDeclinedNotification;
|
||||
@@ -239,7 +239,9 @@ export class NotificationModel extends BaseModel {
|
||||
// delete notifications that are older than one year
|
||||
where: { createdAt: { lte: new Date(Date.now() - ONE_YEAR) } },
|
||||
});
|
||||
this.logger.log(`Deleted ${count} expired notifications`);
|
||||
if (count > 0) {
|
||||
this.logger.log(`Deleted ${count} expired notifications`);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,9 @@ export class SessionModel extends BaseModel {
|
||||
id,
|
||||
},
|
||||
});
|
||||
this.logger.log(`Deleted session success by id: ${id}`);
|
||||
if (count > 0) {
|
||||
this.logger.log(`Deleted session success by id: ${id}`);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -134,20 +136,24 @@ export class SessionModel extends BaseModel {
|
||||
sessionId,
|
||||
},
|
||||
});
|
||||
this.logger.log(
|
||||
`Deleted user sessions success by userId: ${userId} and sessionId: ${sessionId}`
|
||||
);
|
||||
if (count > 0) {
|
||||
this.logger.log(
|
||||
`Deleted user sessions success by userId: ${userId} and sessionId: ${sessionId}`
|
||||
);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
async cleanExpiredUserSessions() {
|
||||
const result = await this.db.userSession.deleteMany({
|
||||
const { count } = await this.db.userSession.deleteMany({
|
||||
where: {
|
||||
expiresAt: {
|
||||
lte: new Date(),
|
||||
},
|
||||
},
|
||||
});
|
||||
this.logger.log(`Cleaned ${result.count} expired user sessions`);
|
||||
if (count > 0) {
|
||||
this.logger.log(`Cleaned ${count} expired user sessions`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,13 +92,15 @@ export class UserDocModel extends BaseModel {
|
||||
* Delete a user doc by userId and docId.
|
||||
*/
|
||||
async delete(userId: string, docId: string) {
|
||||
await this.db.userSnapshot.deleteMany({
|
||||
const { count } = await this.db.userSnapshot.deleteMany({
|
||||
where: {
|
||||
userId,
|
||||
id: docId,
|
||||
},
|
||||
});
|
||||
this.logger.log(`Deleted user ${userId} doc ${docId}`);
|
||||
if (count > 0) {
|
||||
this.logger.log(`Deleted user ${userId} doc ${docId}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +112,9 @@ export class UserDocModel extends BaseModel {
|
||||
userId,
|
||||
},
|
||||
});
|
||||
this.logger.log(`Deleted user ${userId} ${count} docs`);
|
||||
if (count > 0) {
|
||||
this.logger.log(`Deleted user ${userId} ${count} docs`);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export class UserSettingsModel extends BaseModel {
|
||||
payload,
|
||||
},
|
||||
});
|
||||
this.logger.log(`UserSettings updated for user ${userId}`);
|
||||
this.logger.debug(`UserSettings updated for user ${userId}`);
|
||||
return payload;
|
||||
}
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ export class UserModel extends BaseModel {
|
||||
const account = await this.db.connectedAccount.create({
|
||||
data,
|
||||
});
|
||||
this.logger.log(
|
||||
this.logger.debug(
|
||||
`Connected account ${account.provider}:${account.id} created`
|
||||
);
|
||||
return account;
|
||||
|
||||
@@ -122,7 +122,11 @@ export class VerificationTokenModel extends BaseModel {
|
||||
type,
|
||||
},
|
||||
});
|
||||
this.logger.log(`Deleted token success by type ${type} and token ${token}`);
|
||||
if (count > 0) {
|
||||
this.logger.log(
|
||||
`Deleted token success by type ${type} and token ${token}`
|
||||
);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -137,7 +141,9 @@ export class VerificationTokenModel extends BaseModel {
|
||||
},
|
||||
},
|
||||
});
|
||||
this.logger.log(`Cleaned ${count} expired tokens`);
|
||||
if (count > 0) {
|
||||
this.logger.log(`Cleaned ${count} expired tokens`);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user