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