diff --git a/pkg/api/accounts.go b/pkg/api/accounts.go index 95340b79..c0d99732 100644 --- a/pkg/api/accounts.go +++ b/pkg/api/accounts.go @@ -287,7 +287,7 @@ func (a *AccountsApi) AccountCreateHandler(c *core.WebContext) (any, *errs.Error log.Infof(c, "[accounts.AccountCreateHandler] user \"uid:%d\" has created a new account \"id:%d\" successfully", uid, mainAccount.AccountId) - a.SetSubmissionRemark(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_ACCOUNT, uid, accountCreateReq.ClientSessionId, utils.Int64ToString(mainAccount.AccountId)) + a.SetSubmissionRemarkIfEnable(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_ACCOUNT, uid, accountCreateReq.ClientSessionId, utils.Int64ToString(mainAccount.AccountId)) accountInfoResp := mainAccount.ToAccountInfoResponse() if len(childrenAccounts) > 0 { diff --git a/pkg/api/base.go b/pkg/api/base.go index e29807f0..e5275558 100644 --- a/pkg/api/base.go +++ b/pkg/api/base.go @@ -113,9 +113,11 @@ func (a *ApiUsingDuplicateChecker) GetSubmissionRemark(checkerType duplicatechec return a.container.GetSubmissionRemark(checkerType, uid, identification) } -// SetSubmissionRemark saves the identification and remark to in-memory cache by the current duplicate checker -func (a *ApiUsingDuplicateChecker) SetSubmissionRemark(checkerType duplicatechecker.DuplicateCheckerType, uid int64, identification string, remark string) { - a.container.SetSubmissionRemark(checkerType, uid, identification, remark) +// SetSubmissionRemarkIfEnable saves the identification and remark to in-memory cache by the current duplicate checker if the duplicate submission check is enabled +func (a *ApiUsingDuplicateChecker) SetSubmissionRemarkIfEnable(checkerType duplicatechecker.DuplicateCheckerType, uid int64, identification string, remark string) { + if a.CurrentConfig().EnableDuplicateSubmissionsCheck { + a.container.SetSubmissionRemark(checkerType, uid, identification, remark) + } } // CheckFailureCount returns whether the failure count of the specified IP and user has reached the limit and increases the failure count diff --git a/pkg/api/transaction_categories.go b/pkg/api/transaction_categories.go index 5eeb8585..c379e842 100644 --- a/pkg/api/transaction_categories.go +++ b/pkg/api/transaction_categories.go @@ -164,7 +164,7 @@ func (a *TransactionCategoriesApi) CategoryCreateHandler(c *core.WebContext) (an log.Infof(c, "[transaction_categories.CategoryCreateHandler] user \"uid:%d\" has created a new category \"id:%d\" successfully", uid, category.CategoryId) - a.SetSubmissionRemark(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_CATEGORY, uid, categoryCreateReq.ClientSessionId, utils.Int64ToString(category.CategoryId)) + a.SetSubmissionRemarkIfEnable(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_CATEGORY, uid, categoryCreateReq.ClientSessionId, utils.Int64ToString(category.CategoryId)) categoryResp := category.ToTransactionCategoryInfoResponse() return categoryResp, nil diff --git a/pkg/api/transaction_pictures.go b/pkg/api/transaction_pictures.go index bdfa292a..232c05c0 100644 --- a/pkg/api/transaction_pictures.go +++ b/pkg/api/transaction_pictures.go @@ -115,7 +115,7 @@ func (a *TransactionPicturesApi) TransactionPictureUploadHandler(c *core.WebCont return nil, errs.Or(err, errs.ErrOperationFailed) } - a.SetSubmissionRemark(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_PICTURE, uid, clientSessionId, utils.Int64ToString(pictureInfo.PictureId)) + a.SetSubmissionRemarkIfEnable(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_PICTURE, uid, clientSessionId, utils.Int64ToString(pictureInfo.PictureId)) pictureInfoResp := a.GetTransactionPictureInfoResponse(pictureInfo) return pictureInfoResp, nil diff --git a/pkg/api/transaction_templates.go b/pkg/api/transaction_templates.go index 8a3039f4..659dc15a 100644 --- a/pkg/api/transaction_templates.go +++ b/pkg/api/transaction_templates.go @@ -197,7 +197,7 @@ func (a *TransactionTemplatesApi) TemplateCreateHandler(c *core.WebContext) (any log.Infof(c, "[transaction_templates.TemplateCreateHandler] user \"uid:%d\" has created a new template \"id:%d\" successfully", uid, template.TemplateId) - a.SetSubmissionRemark(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_TEMPLATE, uid, templateCreateReq.ClientSessionId, utils.Int64ToString(template.TemplateId)) + a.SetSubmissionRemarkIfEnable(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_TEMPLATE, uid, templateCreateReq.ClientSessionId, utils.Int64ToString(template.TemplateId)) templateResp := template.ToTransactionTemplateInfoResponse(serverUtcOffset) return templateResp, nil diff --git a/pkg/api/transactions.go b/pkg/api/transactions.go index 90a810fa..493d690b 100644 --- a/pkg/api/transactions.go +++ b/pkg/api/transactions.go @@ -787,7 +787,7 @@ func (a *TransactionsApi) TransactionCreateHandler(c *core.WebContext) (any, *er log.Infof(c, "[transactions.TransactionCreateHandler] user \"uid:%d\" has created a new transaction \"id:%d\" successfully", uid, transaction.TransactionId) - a.SetSubmissionRemark(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_TRANSACTION, uid, transactionCreateReq.ClientSessionId, utils.Int64ToString(transaction.TransactionId)) + a.SetSubmissionRemarkIfEnable(duplicatechecker.DUPLICATE_CHECKER_TYPE_NEW_TRANSACTION, uid, transactionCreateReq.ClientSessionId, utils.Int64ToString(transaction.TransactionId)) transactionResp := transaction.ToTransactionInfoResponse(tagIds, transactionEditable) transactionResp.Pictures = a.GetTransactionPictureInfoResponseList(pictureInfos) @@ -1432,7 +1432,7 @@ func (a *TransactionsApi) TransactionImportHandler(c *core.WebContext) (any, *er log.Infof(c, "[transactions.TransactionImportHandler] user \"uid:%d\" has imported %d transactions successfully", uid, count) - a.SetSubmissionRemark(duplicatechecker.DUPLICATE_CHECKER_TYPE_IMPORT_TRANSACTIONS, uid, transactionImportReq.ClientSessionId, utils.IntToString(count)) + a.SetSubmissionRemarkIfEnable(duplicatechecker.DUPLICATE_CHECKER_TYPE_IMPORT_TRANSACTIONS, uid, transactionImportReq.ClientSessionId, utils.IntToString(count)) return count, nil }