mirror of
https://git.joinfirefish.org/firefish/firefish.git
synced 2024-05-04 13:11:12 +02:00
chore: replace new Date().getTime()
with Date.now()
959cc8ff37
Co-authored-by: zyoshoka <107108195+zyoshoka@users.noreply.github.com>
This commit is contained in:
parent
fce0e5a218
commit
30619301d3
|
@ -10,7 +10,7 @@ import { LessThan } from "typeorm";
|
|||
export default function () {
|
||||
async function tick() {
|
||||
await AttestationChallenges.delete({
|
||||
createdAt: LessThan(new Date(new Date().getTime() - 5 * 60 * 1000)),
|
||||
createdAt: LessThan(new Date(Date.now() - 5 * 60 * 1000)),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ nativeInitIdGenerator(length, fingerprint);
|
|||
* Ref: https://github.com/paralleldrive/cuid2#parameterized-length
|
||||
*/
|
||||
export function genId(date?: Date): string {
|
||||
return nativeCreateId((date ?? new Date()).getTime());
|
||||
return nativeCreateId(date?.getTime() ?? Date.now());
|
||||
}
|
||||
|
||||
export function getTimestamp(id: string): number {
|
||||
|
|
|
@ -3,7 +3,7 @@ import type { User } from "@/models/entities/user.js";
|
|||
|
||||
export default (object: any, user: { id: User["id"] }) => {
|
||||
const activity = {
|
||||
id: `${config.url}/users/${user.id}#updates/${new Date().getTime()}`,
|
||||
id: `${config.url}/users/${user.id}#updates/${Date.now()}`,
|
||||
actor: `${config.url}/users/${user.id}`,
|
||||
type: "Update",
|
||||
to: ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
|
|
|
@ -117,10 +117,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
});
|
||||
|
||||
// Expired challenge (> 5min old)
|
||||
if (
|
||||
new Date().getTime() - attestationChallenge.createdAt.getTime() >=
|
||||
5 * 60 * 1000
|
||||
) {
|
||||
if (Date.now() - attestationChallenge.createdAt.getTime() >= 5 * 60 * 1000) {
|
||||
throw new Error("expired challenge");
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,7 @@ export default async (ctx: Koa.Context) => {
|
|||
id: body.challengeId,
|
||||
});
|
||||
|
||||
if (new Date().getTime() - challenge.createdAt.getTime() >= 5 * 60 * 1000) {
|
||||
if (Date.now() - challenge.createdAt.getTime() >= 5 * 60 * 1000) {
|
||||
await fail(403, {
|
||||
id: "2715a88a-2125-4013-932f-aa6fe72792da",
|
||||
});
|
||||
|
|
|
@ -158,7 +158,7 @@ mastoRouter.post("/oauth/token", async (ctx) => {
|
|||
access_token: uuid(),
|
||||
token_type: "Bearer",
|
||||
scope: "read",
|
||||
created_at: Math.floor(new Date().getTime() / 1000),
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
};
|
||||
ctx.body = ret;
|
||||
return;
|
||||
|
@ -193,7 +193,7 @@ mastoRouter.post("/oauth/token", async (ctx) => {
|
|||
access_token: atData.accessToken,
|
||||
token_type: "Bearer",
|
||||
scope: body.scope || "read write follow push",
|
||||
created_at: Math.floor(new Date().getTime() / 1000),
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
};
|
||||
serverLogger.info("token-response", ret);
|
||||
ctx.body = ret;
|
||||
|
|
|
@ -92,7 +92,7 @@ export async function pushNotification<T extends keyof pushNotificationsTypes>(
|
|||
? truncateNotification(body as Packed<"Notification">)
|
||||
: body,
|
||||
userId,
|
||||
dateTime: new Date().getTime(),
|
||||
dateTime: Date.now(),
|
||||
}),
|
||||
{
|
||||
proxy: config.proxy,
|
||||
|
|
|
@ -37,7 +37,7 @@ const _time =
|
|||
const invalid = Number.isNaN(_time);
|
||||
const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid;
|
||||
|
||||
const now = ref((props.origin ?? new Date()).getTime());
|
||||
const now = ref(props.origin?.getTime() ?? Date.now());
|
||||
const relative = computed<string>(() => {
|
||||
if (props.mode === "absolute") return ""; // absoluteではrelativeを使わないので計算しない
|
||||
if (invalid) return i18n.ts._ago.invalid;
|
||||
|
@ -77,7 +77,7 @@ const relative = computed<string>(() => {
|
|||
let tickId: number;
|
||||
|
||||
function tick() {
|
||||
const _now = new Date().getTime();
|
||||
const _now = Date.now();
|
||||
const agoPrev = (now.value - _time) / 1000; /* ms */ // 現状のinterval
|
||||
|
||||
now.value = _now;
|
||||
|
|
|
@ -74,9 +74,9 @@ watch(showColon, (v) => {
|
|||
});
|
||||
|
||||
const tick = () => {
|
||||
const now = new Date();
|
||||
ss.value = Math.floor(now.getTime() / 1000).toString();
|
||||
ms.value = Math.floor((now.getTime() % 1000) / 10)
|
||||
const now = Date.now();
|
||||
ss.value = Math.floor(now / 1000).toString();
|
||||
ms.value = Math.floor((now % 1000) / 10)
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
if (ss.value !== prevSec) showColon.value = true;
|
||||
|
|
|
@ -71,8 +71,7 @@ globalThis.addEventListener("push", (ev) => {
|
|||
case "notification":
|
||||
case "unreadAntennaNote":
|
||||
// 1日以上経過している場合は無視
|
||||
if (new Date().getTime() - data.dateTime > 1000 * 60 * 60 * 24)
|
||||
break;
|
||||
if (Date.now() - data.dateTime > 1000 * 60 * 60 * 24) break;
|
||||
|
||||
return createNotification(data);
|
||||
case "readAllNotifications":
|
||||
|
|
Loading…
Reference in a new issue