fix (backend): use the exact same time for id and createdAt
This commit is contained in:
parent
4e8f0c2e85
commit
c64119108e
51 changed files with 253 additions and 165 deletions
|
@ -6,7 +6,7 @@ import { downloadTextFile } from "@/misc/download-text-file.js";
|
|||
import { Users, DriveFiles, Mutings } from "@/models/index.js";
|
||||
import type { DbUserImportJobData } from "@/queue/types.js";
|
||||
import type { User } from "@/models/entities/user.js";
|
||||
import { genId, isSelfHost, stringToAcct, toPuny } from "backend-rs";
|
||||
import { genIdAt, isSelfHost, stringToAcct, toPuny } from "backend-rs";
|
||||
import { IsNull } from "typeorm";
|
||||
import { inspect } from "node:util";
|
||||
|
||||
|
@ -80,9 +80,11 @@ export async function importMuting(
|
|||
}
|
||||
|
||||
async function mute(user: User, target: User) {
|
||||
const now = new Date();
|
||||
|
||||
await Mutings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
muterId: user.id,
|
||||
muteeId: target.id,
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
UserLists,
|
||||
UserListJoinings,
|
||||
} from "@/models/index.js";
|
||||
import { genId, isSelfHost, stringToAcct, toPuny } from "backend-rs";
|
||||
import { genIdAt, isSelfHost, stringToAcct, toPuny } from "backend-rs";
|
||||
import type { DbUserImportJobData } from "@/queue/types.js";
|
||||
import { IsNull } from "typeorm";
|
||||
import { inspect } from "node:util";
|
||||
|
@ -54,9 +54,10 @@ export async function importUserLists(
|
|||
});
|
||||
|
||||
if (list == null) {
|
||||
const now = new Date();
|
||||
list = await UserLists.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
name: listName,
|
||||
}).then((x) => UserLists.findOneByOrFail(x.identifiers[0]));
|
||||
|
|
|
@ -4,7 +4,7 @@ import type { IFlag } from "../../type.js";
|
|||
import { getApIds } from "../../type.js";
|
||||
import { AbuseUserReports, Users } from "@/models/index.js";
|
||||
import { In } from "typeorm";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
|
||||
export default async (
|
||||
actor: CacheableRemoteUser,
|
||||
|
@ -23,9 +23,11 @@ export default async (
|
|||
});
|
||||
if (users.length < 1) return "skip";
|
||||
|
||||
const now = new Date();
|
||||
|
||||
await AbuseUserReports.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
targetUserId: users[0].id,
|
||||
targetUserHost: users[0].host,
|
||||
reporterId: actor.id,
|
||||
|
|
|
@ -16,7 +16,7 @@ import type { IRemoteUser, CacheableUser } from "@/models/entities/user.js";
|
|||
import { User } from "@/models/entities/user.js";
|
||||
import type { Emoji } from "@/models/entities/emoji.js";
|
||||
import { UserNotePining } from "@/models/entities/user-note-pining.js";
|
||||
import { genId, isSameOrigin, toPuny } from "backend-rs";
|
||||
import { genId, genIdAt, isSameOrigin, toPuny } from "backend-rs";
|
||||
import { UserPublickey } from "@/models/entities/user-publickey.js";
|
||||
import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js";
|
||||
import { UserProfile } from "@/models/entities/user-profile.js";
|
||||
|
@ -242,16 +242,17 @@ export async function createPerson(
|
|||
|
||||
// Create user
|
||||
let user: IRemoteUser;
|
||||
const now = new Date();
|
||||
try {
|
||||
// Start transaction
|
||||
await db.transaction(async (transactionalEntityManager) => {
|
||||
user = (await transactionalEntityManager.save(
|
||||
new User({
|
||||
id: genId(),
|
||||
id: genIdAt(now),
|
||||
avatarId: null,
|
||||
bannerId: null,
|
||||
createdAt: new Date(),
|
||||
lastFetchedAt: new Date(),
|
||||
createdAt: now,
|
||||
lastFetchedAt: now,
|
||||
name: truncate(person.name, nameLength),
|
||||
isLocked: !!person.manuallyApprovesFollowers,
|
||||
movedToUri: person.movedTo,
|
||||
|
|
|
@ -3,7 +3,7 @@ import type Koa from "koa";
|
|||
import { config } from "@/config.js";
|
||||
import type { ILocalUser } from "@/models/entities/user.js";
|
||||
import { Signins } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { publishMainStream } from "@/services/stream.js";
|
||||
|
||||
export default function (ctx: Koa.Context, user: ILocalUser, redirect = false) {
|
||||
|
@ -29,9 +29,10 @@ export default function (ctx: Koa.Context, user: ILocalUser, redirect = false) {
|
|||
|
||||
(async () => {
|
||||
// Append signin history
|
||||
const now = new Date();
|
||||
const record = await Signins.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
ip: ctx.ip,
|
||||
headers: ctx.headers,
|
||||
|
|
|
@ -3,7 +3,7 @@ import { User } from "@/models/entities/user.js";
|
|||
import { Users, UsedUsernames } from "@/models/index.js";
|
||||
import { UserProfile } from "@/models/entities/user-profile.js";
|
||||
import { IsNull } from "typeorm";
|
||||
import { genId, generateUserToken, hashPassword, toPuny } from "backend-rs";
|
||||
import { genIdAt, generateUserToken, hashPassword, toPuny } from "backend-rs";
|
||||
import { UserKeypair } from "@/models/entities/user-keypair.js";
|
||||
import { UsedUsername } from "@/models/entities/used-username.js";
|
||||
import { db } from "@/db/postgre.js";
|
||||
|
@ -91,10 +91,12 @@ export async function signup(opts: {
|
|||
|
||||
if (exist) throw new Error(" the username is already used");
|
||||
|
||||
const now = new Date();
|
||||
|
||||
account = await transactionalEntityManager.save(
|
||||
new User({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
username: username,
|
||||
usernameLower: username.toLowerCase(),
|
||||
host: host == null ? null : toPuny(host),
|
||||
|
@ -125,7 +127,7 @@ export async function signup(opts: {
|
|||
|
||||
await transactionalEntityManager.save(
|
||||
new UsedUsername({
|
||||
createdAt: new Date(),
|
||||
createdAt: now,
|
||||
username: username.toLowerCase(),
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { Ads } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
|
||||
export const meta = {
|
||||
tags: ["admin"],
|
||||
|
@ -32,9 +32,11 @@ export const paramDef = {
|
|||
} as const;
|
||||
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const now = new Date();
|
||||
|
||||
await Ads.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
expiresAt: new Date(ps.expiresAt),
|
||||
url: ps.url,
|
||||
imageUrl: ps.imageUrl,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { Announcements } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
|
||||
export const meta = {
|
||||
tags: ["admin"],
|
||||
|
@ -74,9 +74,10 @@ export const paramDef = {
|
|||
} as const;
|
||||
|
||||
export default define(meta, paramDef, async (ps) => {
|
||||
const now = new Date();
|
||||
const announcement = await Announcements.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
updatedAt: null,
|
||||
title: ps.title,
|
||||
text: ps.text,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import rndstr from "rndstr";
|
||||
import define from "@/server/api/define.js";
|
||||
import { RegistrationTickets } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
|
||||
export const meta = {
|
||||
tags: ["admin"],
|
||||
|
@ -38,9 +38,11 @@ export default define(meta, paramDef, async () => {
|
|||
chars: "2-9A-HJ-NP-Z", // [0-9A-Z] w/o [01IO] (32 patterns)
|
||||
});
|
||||
|
||||
const now = new Date();
|
||||
|
||||
await RegistrationTickets.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
code,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { fetchMeta, genId } from "backend-rs";
|
||||
import { fetchMeta, genIdAt } from "backend-rs";
|
||||
import { Antennas, UserLists, UserGroupJoinings } from "@/models/index.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { publishInternalEvent } from "@/services/stream.js";
|
||||
|
@ -152,9 +152,11 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
}
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const antenna = await Antennas.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
name: ps.name,
|
||||
src: ps.src,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { Apps } from "@/models/index.js";
|
||||
import { genId, generateSecureRandomString } from "backend-rs";
|
||||
import { genIdAt, generateSecureRandomString } from "backend-rs";
|
||||
import { unique } from "@/prelude/array.js";
|
||||
|
||||
export const meta = {
|
||||
|
@ -48,9 +48,10 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
);
|
||||
|
||||
// Create account
|
||||
const now = new Date();
|
||||
const app = await Apps.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user ? user.id : null,
|
||||
name: ps.name,
|
||||
description: ps.description,
|
||||
|
|
|
@ -3,7 +3,7 @@ import { config } from "@/config.js";
|
|||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { Apps, AuthSessions } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
|
||||
export const meta = {
|
||||
tags: ["auth"],
|
||||
|
@ -60,9 +60,10 @@ export default define(meta, paramDef, async (ps) => {
|
|||
const token = uuid();
|
||||
|
||||
// Create session token document
|
||||
const now = new Date();
|
||||
const doc = await AuthSessions.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
appId: app.id,
|
||||
token: token,
|
||||
}).then((x) => AuthSessions.findOneByOrFail(x.identifiers[0]));
|
||||
|
|
|
@ -2,7 +2,7 @@ import define from "@/server/api/define.js";
|
|||
import { ApiError } from "@/server/api/error.js";
|
||||
import { Channels, DriveFiles } from "@/models/index.js";
|
||||
import type { Channel } from "@/models/entities/channel.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
|
||||
export const meta = {
|
||||
tags: ["channels"],
|
||||
|
@ -55,9 +55,11 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
}
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const channel = await Channels.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
name: ps.name,
|
||||
description: ps.description || null,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { Channels, ChannelFollowings } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { publishUserEvent } from "@/services/stream.js";
|
||||
|
||||
export const meta = {
|
||||
|
@ -37,9 +37,11 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
throw new ApiError(meta.errors.noSuchChannel);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
await ChannelFollowings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
followerId: user.id,
|
||||
followeeId: channel.id,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { Clips } from "@/models/index.js";
|
||||
|
||||
export const meta = {
|
||||
|
@ -33,9 +33,10 @@ export const paramDef = {
|
|||
} as const;
|
||||
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const now = new Date();
|
||||
const clip = await Clips.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
name: ps.name,
|
||||
isPublic: ps.isPublic,
|
||||
|
|
|
@ -2,7 +2,7 @@ import { publishDriveStream } from "@/services/stream.js";
|
|||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { DriveFolders } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
|
||||
export const meta = {
|
||||
tags: ["drive"],
|
||||
|
@ -52,9 +52,10 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
}
|
||||
|
||||
// Create folder
|
||||
const now = new Date();
|
||||
const folder = await DriveFolders.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
name: ps.name,
|
||||
parentId: parent != null ? parent.id : null,
|
||||
userId: user.id,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { DriveFiles, GalleryPosts } from "@/models/index.js";
|
||||
import { HOUR, genId } from "backend-rs";
|
||||
import { HOUR, genIdAt } from "backend-rs";
|
||||
import { GalleryPost } from "@/models/entities/gallery-post.js";
|
||||
import type { DriveFile } from "@/models/entities/drive-file.js";
|
||||
|
||||
|
@ -62,11 +62,13 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
throw new Error();
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const post = await GalleryPosts.insert(
|
||||
new GalleryPost({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
title: ps.title,
|
||||
description: ps.description,
|
||||
userId: user.id,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { GalleryPosts, GalleryLikes } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
|
||||
export const meta = {
|
||||
tags: ["gallery"],
|
||||
|
@ -51,10 +51,12 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
throw new ApiError(meta.errors.alreadyLiked);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Create like
|
||||
await GalleryLikes.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
postId: post.id,
|
||||
userId: user.id,
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ import define from "@/server/api/define.js";
|
|||
import { UserProfiles, AttestationChallenges } from "@/models/index.js";
|
||||
import { promisify } from "node:util";
|
||||
import * as crypto from "node:crypto";
|
||||
import { genId, verifyPassword } from "backend-rs";
|
||||
import { genIdAt, verifyPassword } from "backend-rs";
|
||||
import { hash } from "@/server/api/2fa.js";
|
||||
|
||||
const randomBytes = promisify(crypto.randomBytes);
|
||||
|
@ -39,13 +39,14 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
.replace(/\+/g, "-")
|
||||
.replace(/\//g, "_");
|
||||
|
||||
const challengeId = genId();
|
||||
const now = new Date();
|
||||
const challengeId = genIdAt(now);
|
||||
|
||||
await AttestationChallenges.insert({
|
||||
userId: user.id,
|
||||
id: challengeId,
|
||||
challenge: hash(Buffer.from(challenge, "utf-8")).toString("hex"),
|
||||
createdAt: new Date(),
|
||||
createdAt: now,
|
||||
registrationChallenge: true,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { AnnouncementReads, Announcements, Users } from "@/models/index.js";
|
||||
import { publishMainStream } from "@/services/stream.js";
|
||||
|
||||
|
@ -50,10 +50,12 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Create read
|
||||
await AnnouncementReads.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
announcementId: ps.announcementId,
|
||||
userId: user.id,
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { publishMainStream } from "@/services/stream.js";
|
||||
import define from "@/server/api/define.js";
|
||||
import { RegistryItems } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
|
||||
export const meta = {
|
||||
requireCredential: true,
|
||||
|
@ -41,10 +41,11 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
value: ps.value,
|
||||
});
|
||||
} else {
|
||||
const now = new Date();
|
||||
await RegistryItems.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
userId: user.id,
|
||||
domain: null,
|
||||
scope: ps.scope,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { Webhooks } from "@/models/index.js";
|
||||
import { publishInternalEvent } from "@/services/stream.js";
|
||||
import { webhookEventTypes } from "@/models/entities/webhook.js";
|
||||
|
@ -30,9 +30,10 @@ export const paramDef = {
|
|||
} as const;
|
||||
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const now = new Date();
|
||||
const webhook = await Webhooks.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
name: ps.name,
|
||||
url: ps.url,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { getUser } from "@/server/api/common/getters.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { Mutings, NoteWatchings } from "@/models/index.js";
|
||||
import type { Muting } from "@/models/entities/muting.js";
|
||||
import { publishUserEvent } from "@/services/stream.js";
|
||||
|
@ -79,10 +79,12 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Create mute
|
||||
await Mutings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
expiresAt: ps.expiresAt ? new Date(ps.expiresAt) : null,
|
||||
muterId: muter.id,
|
||||
muteeId: mutee.id,
|
||||
|
|
|
@ -16,7 +16,7 @@ import { config } from "@/config.js";
|
|||
import { noteVisibilities } from "@/types.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import define from "@/server/api/define.js";
|
||||
import { HOUR, genId } from "backend-rs";
|
||||
import { HOUR, genIdAt } from "backend-rs";
|
||||
import { getNote } from "@/server/api/common/getters.js";
|
||||
import { langmap } from "firefish-js";
|
||||
import { createScheduledNoteJob } from "@/queue/index.js";
|
||||
|
@ -310,11 +310,13 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
}
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Create a post
|
||||
const note = await create(
|
||||
user,
|
||||
{
|
||||
createdAt: new Date(),
|
||||
createdAt: now,
|
||||
files: files,
|
||||
poll: ps.poll
|
||||
? {
|
||||
|
@ -347,7 +349,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
delay
|
||||
? async (note) => {
|
||||
await ScheduledNotes.insert({
|
||||
id: genId(),
|
||||
id: genIdAt(now),
|
||||
noteId: note.id,
|
||||
userId: user.id,
|
||||
scheduledAt: new Date(ps.scheduledAt as number),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { NoteFavorites } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { getNote } from "@/server/api/common/getters.js";
|
||||
|
@ -54,10 +54,12 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
throw new ApiError(meta.errors.alreadyFavorited);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Create favorite
|
||||
await NoteFavorites.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
noteId: note.id,
|
||||
userId: user.id,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Notes, NoteThreadMutings } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import readNote from "@/services/note/read.js";
|
||||
import define from "@/server/api/define.js";
|
||||
import { getNote } from "@/server/api/common/getters.js";
|
||||
|
@ -49,9 +49,11 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
|
||||
await readNote(user.id, mutedNotes);
|
||||
|
||||
const now = new Date();
|
||||
|
||||
await NoteThreadMutings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
threadId: note.threadId || note.id,
|
||||
userId: user.id,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Pages, DriveFiles } from "@/models/index.js";
|
||||
import { genId, HOUR } from "backend-rs";
|
||||
import { genIdAt, HOUR } from "backend-rs";
|
||||
import { Page } from "@/models/entities/page.js";
|
||||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
|
@ -97,11 +97,13 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
}
|
||||
});
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const page = await Pages.insert(
|
||||
new Page({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
title: ps.title,
|
||||
name: ps.name,
|
||||
summary: ps.summary,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Pages, PageLikes } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
|
||||
|
@ -51,10 +51,12 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
throw new ApiError(meta.errors.alreadyLiked);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Create like
|
||||
await PageLikes.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
pageId: page.id,
|
||||
userId: user.id,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { PromoReads } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { getNote } from "@/server/api/common/getters.js";
|
||||
|
@ -44,9 +44,11 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
await PromoReads.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
noteId: note.id,
|
||||
userId: user.id,
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { RenoteMutings } from "@/models/index.js";
|
||||
import { RenoteMuting } from "@/models/entities/renote-muting.js";
|
||||
import type { RenoteMuting } from "@/models/entities/renote-muting.js";
|
||||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { getUser } from "@/server/api/common/getters.js";
|
||||
|
@ -58,10 +58,12 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
throw new ApiError(meta.errors.alreadyMuting);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Create mute
|
||||
await RenoteMutings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
muterId: muter.id,
|
||||
muteeId: mutee.id,
|
||||
} as RenoteMuting);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { ReplyMutings } from "@/models/index.js";
|
||||
import { ReplyMuting } from "@/models/entities/reply-muting.js";
|
||||
import type { ReplyMuting } from "@/models/entities/reply-muting.js";
|
||||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { getUser } from "@/server/api/common/getters.js";
|
||||
|
@ -56,10 +56,12 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
throw new ApiError(meta.errors.alreadyMuting);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Create mute
|
||||
await ReplyMutings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
muterId: muter.id,
|
||||
muteeId: mutee.id,
|
||||
} as ReplyMuting);
|
||||
|
|
|
@ -3,7 +3,7 @@ import { IsNull } from "typeorm";
|
|||
import { config } from "@/config.js";
|
||||
import { Users, UserProfiles, PasswordResetRequests } from "@/models/index.js";
|
||||
import { sendEmail } from "@/services/send-email.js";
|
||||
import { HOUR, genId } from "backend-rs";
|
||||
import { HOUR, genIdAt } from "backend-rs";
|
||||
import define from "@/server/api/define.js";
|
||||
|
||||
export const meta = {
|
||||
|
@ -54,10 +54,11 @@ export default define(meta, paramDef, async (ps) => {
|
|||
}
|
||||
|
||||
const token = rndstr("a-z0-9", 64);
|
||||
const now = new Date();
|
||||
|
||||
await PasswordResetRequests.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: profile.userId,
|
||||
token,
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { fetchMeta, genId } from "backend-rs";
|
||||
import { fetchMeta, genIdAt } from "backend-rs";
|
||||
import { SwSubscriptions } from "@/models/index.js";
|
||||
import define from "@/server/api/define.js";
|
||||
|
||||
|
@ -76,9 +76,11 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
};
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
await SwSubscriptions.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: me.id,
|
||||
endpoint: ps.endpoint,
|
||||
auth: ps.auth,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { UserGroups, UserGroupJoinings } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import type { UserGroup } from "@/models/entities/user-group.js";
|
||||
import type { UserGroupJoining } from "@/models/entities/user-group-joining.js";
|
||||
import define from "@/server/api/define.js";
|
||||
|
@ -30,17 +30,19 @@ export const paramDef = {
|
|||
} as const;
|
||||
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const now = new Date();
|
||||
|
||||
const userGroup = await UserGroups.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
name: ps.name,
|
||||
} as UserGroup).then((x) => UserGroups.findOneByOrFail(x.identifiers[0]));
|
||||
|
||||
// Push the owner
|
||||
await UserGroupJoinings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
userGroupId: userGroup.id,
|
||||
} as UserGroupJoining);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { UserGroupJoinings, UserGroupInvitations } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import type { UserGroupJoining } from "@/models/entities/user-group-joining.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import define from "@/server/api/define.js";
|
||||
|
@ -44,10 +44,12 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
throw new ApiError(meta.errors.noSuchInvitation);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Push the user
|
||||
await UserGroupJoinings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
userGroupId: invitation.userGroupId,
|
||||
} as UserGroupJoining);
|
||||
|
|
|
@ -3,7 +3,7 @@ import {
|
|||
UserGroupJoinings,
|
||||
UserGroupInvitations,
|
||||
} from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import type { UserGroupInvitation } from "@/models/entities/user-group-invitation.js";
|
||||
import { createNotification } from "@/services/create-notification.js";
|
||||
import { getUser } from "@/server/api/common/getters.js";
|
||||
|
@ -91,9 +91,11 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
throw new ApiError(meta.errors.alreadyInvited);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const invitation = await UserGroupInvitations.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
userGroupId: userGroup.id,
|
||||
} as UserGroupInvitation).then((x) =>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { UserLists } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import type { UserList } from "@/models/entities/user-list.js";
|
||||
import define from "@/server/api/define.js";
|
||||
|
||||
|
@ -29,9 +29,10 @@ export const paramDef = {
|
|||
} as const;
|
||||
|
||||
export default define(meta, paramDef, async (ps, user) => {
|
||||
const now = new Date();
|
||||
const userList = await UserLists.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
name: ps.name,
|
||||
} as UserList).then((x) => UserLists.findOneByOrFail(x.identifiers[0]));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as mfm from "mfm-js";
|
||||
import sanitizeHtml from "sanitize-html";
|
||||
import { AbuseUserReports, UserProfiles, Users } from "@/models/index.js";
|
||||
import { genId, publishToModerationStream } from "backend-rs";
|
||||
import { genIdAt, publishToModerationStream } from "backend-rs";
|
||||
import { sendEmail } from "@/services/send-email.js";
|
||||
import { getUser } from "@/server/api/common/getters.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
|
@ -61,9 +61,11 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
throw new ApiError(meta.errors.cannotReportAdmin);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const report = await AbuseUserReports.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
targetUserId: user.id,
|
||||
targetUserHost: user.host,
|
||||
reporterId: me.id,
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from "@/models/index.js";
|
||||
import type { ILocalUser } from "@/models/entities/user.js";
|
||||
import {
|
||||
genId,
|
||||
genIdAt,
|
||||
hashPassword,
|
||||
isOldPasswordAlgorithm,
|
||||
verifyPassword,
|
||||
|
@ -101,10 +101,12 @@ export default async (ctx: Koa.Context) => {
|
|||
}
|
||||
|
||||
async function fail(status?: number, failure?: { id: string }) {
|
||||
const now = new Date();
|
||||
|
||||
// Append signin history
|
||||
await Signins.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
ip: ctx.ip,
|
||||
headers: ctx.headers,
|
||||
|
@ -251,13 +253,14 @@ export default async (ctx: Koa.Context) => {
|
|||
.replace(/\+/g, "-")
|
||||
.replace(/\//g, "_");
|
||||
|
||||
const challengeId = genId();
|
||||
const now = new Date();
|
||||
const challengeId = genIdAt(now);
|
||||
|
||||
await AttestationChallenges.insert({
|
||||
userId: user.id,
|
||||
id: challengeId,
|
||||
challenge: hash(Buffer.from(challenge, "utf-8")).toString("hex"),
|
||||
createdAt: new Date(),
|
||||
createdAt: now,
|
||||
registrationChallenge: false,
|
||||
});
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Users, RegistrationTickets, UserPendings } from "@/models/index.js";
|
|||
import { signup } from "@/server/api/common/signup.js";
|
||||
import { config } from "@/config.js";
|
||||
import { sendEmail } from "@/services/send-email.js";
|
||||
import { fetchMeta, genId, hashPassword } from "backend-rs";
|
||||
import { fetchMeta, genIdAt, hashPassword } from "backend-rs";
|
||||
import { validateEmailForAccount } from "@/services/validate-email-for-account.js";
|
||||
|
||||
export default async (ctx: Koa.Context) => {
|
||||
|
@ -84,9 +84,11 @@ export default async (ctx: Koa.Context) => {
|
|||
// Generate hash of password
|
||||
const hash = hashPassword(password);
|
||||
|
||||
const now = new Date();
|
||||
|
||||
await UserPendings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
code,
|
||||
email: emailAddress,
|
||||
username: username,
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
UserListJoinings,
|
||||
UserLists,
|
||||
} from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { getActiveWebhooks } from "@/misc/webhook-cache.js";
|
||||
import { webhookDeliver } from "@/queue/index.js";
|
||||
|
||||
|
@ -28,9 +28,11 @@ export default async function (blocker: User, blockee: User) {
|
|||
removeFromList(blockee, blocker),
|
||||
]);
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const blocking = {
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
blocker,
|
||||
blockerId: blocker.id,
|
||||
blockee,
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
Followings,
|
||||
} from "@/models/index.js";
|
||||
import {
|
||||
genId,
|
||||
genIdAt,
|
||||
isSilencedServer,
|
||||
sendPushNotification,
|
||||
PushNotificationKind,
|
||||
|
@ -61,10 +61,12 @@ export async function createNotification(
|
|||
}
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Create notification
|
||||
const notification = await Notifications.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
notifieeId: notifieeId,
|
||||
type: type,
|
||||
// 相手がこの通知をミュートしているようなら、既読を予めつけておく
|
||||
|
|
|
@ -3,7 +3,7 @@ import { genRsaKeyPair } from "@/misc/gen-key-pair.js";
|
|||
import { User } from "@/models/entities/user.js";
|
||||
import { UserProfile } from "@/models/entities/user-profile.js";
|
||||
import { IsNull } from "typeorm";
|
||||
import { generateUserToken, genId, hashPassword } from "backend-rs";
|
||||
import { generateUserToken, genIdAt, hashPassword } from "backend-rs";
|
||||
import { UserKeypair } from "@/models/entities/user-keypair.js";
|
||||
import { UsedUsername } from "@/models/entities/used-username.js";
|
||||
import { db } from "@/db/postgre.js";
|
||||
|
@ -21,6 +21,8 @@ export async function createSystemUser(username: string) {
|
|||
|
||||
let account!: User;
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Start transaction
|
||||
await db.transaction(async (transactionalEntityManager) => {
|
||||
const exist = await transactionalEntityManager.findOneBy(User, {
|
||||
|
@ -32,8 +34,8 @@ export async function createSystemUser(username: string) {
|
|||
|
||||
account = await transactionalEntityManager
|
||||
.insert(User, {
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
username: username,
|
||||
usernameLower: username.toLowerCase(),
|
||||
host: null,
|
||||
|
@ -60,7 +62,7 @@ export async function createSystemUser(username: string) {
|
|||
});
|
||||
|
||||
await transactionalEntityManager.insert(UsedUsername, {
|
||||
createdAt: new Date(),
|
||||
createdAt: now,
|
||||
username: username.toLowerCase(),
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
Instances,
|
||||
UserProfiles,
|
||||
} from "@/models/index.js";
|
||||
import { genId, isSilencedServer } from "backend-rs";
|
||||
import { genIdAt, isSilencedServer } from "backend-rs";
|
||||
import { createNotification } from "@/services/create-notification.js";
|
||||
import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js";
|
||||
import type { Packed } from "@/misc/schema.js";
|
||||
|
@ -46,9 +46,11 @@ export async function insertFollowingDoc(
|
|||
|
||||
let alreadyFollowed = false;
|
||||
|
||||
const now = new Date();
|
||||
|
||||
await Followings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
followerId: follower.id,
|
||||
followeeId: followee.id,
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import renderFollow from "@/remote/activitypub/renderer/follow.js";
|
|||
import { deliver } from "@/queue/index.js";
|
||||
import type { User } from "@/models/entities/user.js";
|
||||
import { Blockings, FollowRequests, Users } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { createNotification } from "@/services/create-notification.js";
|
||||
import { config } from "@/config.js";
|
||||
|
||||
|
@ -42,9 +42,11 @@ export default async function (
|
|||
if (blocking) throw new Error("blocking");
|
||||
if (blocked) throw new Error("blocked");
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const followRequest = await FollowRequests.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
followerId: follower.id,
|
||||
followeeId: followee.id,
|
||||
requestId,
|
||||
|
|
|
@ -7,7 +7,7 @@ import type { User } from "@/models/entities/user.js";
|
|||
import type { Note } from "@/models/entities/note.js";
|
||||
import { Notes, UserNotePinings, Users } from "@/models/index.js";
|
||||
import type { UserNotePining } from "@/models/entities/user-note-pining.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { deliverToFollowers } from "@/remote/activitypub/deliver-manager.js";
|
||||
import { deliverToRelays } from "@/services/relay.js";
|
||||
|
||||
|
@ -49,9 +49,11 @@ export async function addPinned(
|
|||
);
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
await UserNotePinings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: user.id,
|
||||
noteId: note.id,
|
||||
} as UserNotePining);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ModerationLogs } from "@/models/index.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import type { User } from "@/models/entities/user.js";
|
||||
|
||||
export async function insertModerationLog(
|
||||
|
@ -7,9 +7,10 @@ export async function insertModerationLog(
|
|||
type: string,
|
||||
info?: Record<string, any>,
|
||||
) {
|
||||
const now = new Date();
|
||||
await ModerationLogs.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: moderator.id,
|
||||
type: type,
|
||||
info: info || {},
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
Users,
|
||||
} from "@/models/index.js";
|
||||
import {
|
||||
genId,
|
||||
genIdAt,
|
||||
sendPushNotification,
|
||||
publishToChatStream,
|
||||
publishToGroupChatStream,
|
||||
|
@ -36,9 +36,10 @@ export async function createMessage(
|
|||
file: DriveFile | null,
|
||||
uri?: string,
|
||||
) {
|
||||
const now = new Date();
|
||||
const message = {
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
fileId: file ? file.id : null,
|
||||
recipientId: recipientUser ? recipientUser.id : null,
|
||||
groupId: recipientGroup ? recipientGroup.id : null,
|
||||
|
|
|
@ -3,7 +3,7 @@ import type { CacheableUser } from "@/models/entities/user.js";
|
|||
import type { Note } from "@/models/entities/note.js";
|
||||
import { PollVotes, NoteWatchings, Polls, Blockings } from "@/models/index.js";
|
||||
import { Not } from "typeorm";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { createNotification } from "@/services/create-notification.js";
|
||||
|
||||
export default async function (
|
||||
|
@ -43,10 +43,12 @@ export default async function (
|
|||
throw new Error("already voted");
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Create vote
|
||||
await PollVotes.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
noteId: note.id,
|
||||
userId: user.id,
|
||||
choice: choice,
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
Blockings,
|
||||
} from "@/models/index.js";
|
||||
import { IsNull, Not } from "typeorm";
|
||||
import { decodeReaction, genId, toDbReaction } from "backend-rs";
|
||||
import { decodeReaction, genIdAt, toDbReaction } from "backend-rs";
|
||||
import { createNotification } from "@/services/create-notification.js";
|
||||
import deleteReaction from "./delete.js";
|
||||
import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js";
|
||||
|
@ -47,9 +47,11 @@ export default async (
|
|||
// TODO: cache
|
||||
reaction = await toDbReaction(reaction, user.host);
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const record: NoteReaction = {
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
noteId: note.id,
|
||||
userId: user.id,
|
||||
reaction,
|
||||
|
|
|
@ -3,14 +3,16 @@ import type { User } from "@/models/entities/user.js";
|
|||
import type { UserList } from "@/models/entities/user-list.js";
|
||||
import { UserListJoinings, Users } from "@/models/index.js";
|
||||
import type { UserListJoining } from "@/models/entities/user-list-joining.js";
|
||||
import { genId } from "backend-rs";
|
||||
import { genIdAt } from "backend-rs";
|
||||
import { fetchProxyAccount } from "@/misc/fetch-proxy-account.js";
|
||||
import createFollowing from "@/services/following/create.js";
|
||||
|
||||
export async function pushUserToUserList(target: User, list: UserList) {
|
||||
const now = new Date();
|
||||
|
||||
await UserListJoinings.insert({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
id: genIdAt(now),
|
||||
createdAt: now,
|
||||
userId: target.id,
|
||||
userListId: list.id,
|
||||
} as UserListJoining);
|
||||
|
|
Loading…
Reference in a new issue