mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-04 23:17:34 +08:00
perf: throttle address activity updates (#1104)
* perf: throttle address activity updates * docs: record address activity write throttling * refactor: inline address activity interval * test: cover address activity throttling
This commit is contained in:
@@ -4,7 +4,7 @@ import i18n from "../i18n";
|
||||
import { UserOauth2Settings, UserSettings } from "../models";
|
||||
import { getJsonSetting, getUserRoles } from "../utils"
|
||||
import { CONSTANTS } from "../constants";
|
||||
import { commonGetUserRole } from "../common";
|
||||
import { commonGetUserRole, updateUserAddressesUpdatedAt } from "../common";
|
||||
import { Jwt } from "hono/utils/jwt";
|
||||
|
||||
export default {
|
||||
@@ -64,17 +64,7 @@ export default {
|
||||
exp: Math.floor(Date.now() / 1000) + 30 * 24 * 60 * 60,
|
||||
iat: Math.floor(Date.now() / 1000),
|
||||
}, c.env.JWT_SECRET, "HS256");
|
||||
// update address updated_at asynchronously
|
||||
c.executionCtx.waitUntil((async () => {
|
||||
try {
|
||||
await c.env.DB.prepare(
|
||||
`UPDATE address SET updated_at = datetime('now') where id IN `
|
||||
+ `(SELECT address_id FROM users_address WHERE user_id = ?)`
|
||||
).bind(user.user_id).run();
|
||||
} catch (e) {
|
||||
console.warn("[user_api/settings] updateAddressUpdatedAt failed:", user.user_id, e);
|
||||
}
|
||||
})());
|
||||
updateUserAddressesUpdatedAt(c, user.user_id);
|
||||
return c.json({
|
||||
...user,
|
||||
is_admin: is_admin,
|
||||
|
||||
Reference in New Issue
Block a user