core: oplog: better logging

This commit is contained in:
undefined committed 2021-12-21 21:34:49 +08:00
1 parent 92c1a41585
commit ead0d54a55
8 files changed
+74 -60

No files matched your search

+2 -14
View File
@@ -514,14 +514,8 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
?.filter((i) => files.has(i.name))
?.map((i) => i.size),
) || 0;
await oplog.add({
type: 'bulkDownload',
time: new Date(),
uid: this.user._id,
ip: this.request.ip,
fileType: 'problem',
await oplog.log(this, 'download.problem.bulk', {
target: Array.from(files).map((file) => `problem/${this.pdoc.domainId}/${this.pdoc.docId}/${type}/${file}`),
referer: this.request.referer,
size,
});
for (const file of files) {
@@ -618,14 +612,8 @@ export class ProblemFileDownloadHandler extends ProblemDetailHandler {
}
const target = `problem/${this.pdoc.domainId}/${this.pdoc.docId}/${type}/${filename}`;
const file = await storage.getMeta(target);
await oplog.add({
type: 'download',
time: new Date(),
uid: this.user._id,
ip: this.request.ip,
fileType: 'problem',
await oplog.log(this, 'download.problem.single', {
target,
referer: this.request.referer,
size: file?.size || 0,
});
if (!file) {