feature: update dependencies (#682)

This commit is contained in:
Dream Hunter
2025-06-24 18:27:45 +08:00
committed by GitHub
parent 70109785c6
commit 9f535a0a90
12 changed files with 357 additions and 356 deletions

View File

@@ -40,6 +40,23 @@ const getNameRegex = (c: Context<HonoCustomType>): RegExp => {
return DEFAULT_NAME_REGEX;
}
export async function updateAddressUpdatedAt(
c: Context<HonoCustomType>,
address: string | undefined | null
): Promise<void> {
if (!address) {
return;
}
// update address updated_at
try {
await c.env.DB.prepare(
`UPDATE address SET updated_at = datetime('now') where name = ?`
).bind(address).run();
} catch (e) {
console.warn("Failed to update address updated_at", e);
}
}
export const newAddress = async (
c: Context<HonoCustomType>,
{
@@ -108,6 +125,7 @@ export const newAddress = async (
if (!success) {
throw new Error("Failed to create address")
}
await updateAddressUpdatedAt(c, name);
} catch (e) {
const message = (e as Error).message;
if (message && message.includes("UNIQUE")) {

View File

@@ -1,5 +1,5 @@
export const CONSTANTS = {
VERSION: 'v' + '1.0.0',
VERSION: 'v' + '1.0.1',
// DB Version
DB_VERSION_KEY: 'db_version',

View File

@@ -2,7 +2,7 @@ import { Context, Hono } from 'hono'
import i18n from '../i18n';
import { getBooleanValue, getJsonSetting, checkCfTurnstile, getStringValue, getSplitStringListValue } from '../utils';
import { newAddress, handleListQuery, deleteAddressWithData, getAddressPrefix, getAllowDomains } from '../common'
import { newAddress, handleListQuery, deleteAddressWithData, getAddressPrefix, getAllowDomains, updateAddressUpdatedAt } from '../common'
import { CONSTANTS } from '../constants'
import auto_reply from './auto_reply'
import webhook_settings from './webhook_settings';
@@ -20,27 +20,6 @@ api.post('/api/attachment/delete', s3_attachment.deleteKey)
api.post('/api/attachment/put_url', s3_attachment.getSignedPutUrl)
api.post('/api/attachment/get_url', s3_attachment.getSignedGetUrl)
export async function updateAddressUpdatedAt(
c: Context<HonoCustomType>,
address: string | undefined | null
): Promise<void> {
if (!address) {
return;
}
// update address updated_at
try {
if (address) {
await c.env.DB.prepare(
`UPDATE address SET updated_at = datetime('now') where name = ?`
).bind(address).run();
}
} catch (e) {
console.warn("Failed to update address updated_at")
}
}
api.get('/api/mails', async (c) => {
const { address } = c.get("jwtPayload")
if (!address) {

View File

@@ -6,6 +6,7 @@ import { getJsonSetting } from "../utils"
import { CONSTANTS } from "../constants";
import { unbindTelegramByAddress } from '../telegram_api/common';
import i18n from '../i18n';
import { updateAddressUpdatedAt } from '../common';
const UserBindAddressModule = {
bind: async (c: Context<HonoCustomType>) => {
@@ -237,6 +238,7 @@ const UserBindAddressModule = {
if (!newAddressSuccess) {
throw new Error("Failed to create address")
}
await updateAddressUpdatedAt(c, address);
// find new address id
const new_address_id = await c.env.DB.prepare(
`SELECT id FROM address WHERE name = ?`