Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,255 @@
|
||||
import { Notes, Memoriets } from "../../../../models/index.js";
|
||||
import { MAX_NOTE_TEXT_LENGTH } from "../../../../const.js";
|
||||
import { noteVisibilities } from "../../../../types.js";
|
||||
import { ApiError } from "../../error.js";
|
||||
import define from "../../define.js";
|
||||
import { HOUR } from "../../../../const.js";
|
||||
import { createNoteFromApiData } from "../../../../services/note/create-from-api.js";
|
||||
import { genId } from "../../../../misc/gen-id.js";
|
||||
export const meta = {
|
||||
tags: [
|
||||
"memoriet"
|
||||
],
|
||||
requireCredential: true,
|
||||
limit: {
|
||||
duration: HOUR,
|
||||
max: 300
|
||||
},
|
||||
kind: "write:notes",
|
||||
res: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
properties: {
|
||||
memoriet: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
properties: {
|
||||
id: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false
|
||||
},
|
||||
expiresAt: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: true
|
||||
},
|
||||
textLayers: {
|
||||
type: "array",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false
|
||||
}
|
||||
},
|
||||
note: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
ref: "Note"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
errors: {
|
||||
cannotExpireToPast: {
|
||||
message: "Expiration time must be in the future.",
|
||||
code: "CANNOT_EXPIRE_TO_PAST",
|
||||
id: "4b86af67-c80f-46ef-a166-440c4e3cf83a"
|
||||
}
|
||||
}
|
||||
};
|
||||
export const paramDef = {
|
||||
type: "object",
|
||||
properties: {
|
||||
visibility: {
|
||||
type: "string",
|
||||
enum: noteVisibilities,
|
||||
default: "home"
|
||||
},
|
||||
visibleUserIds: {
|
||||
type: "array",
|
||||
uniqueItems: true,
|
||||
items: {
|
||||
type: "string",
|
||||
format: "misskey:id"
|
||||
}
|
||||
},
|
||||
text: {
|
||||
type: "string",
|
||||
maxLength: MAX_NOTE_TEXT_LENGTH,
|
||||
nullable: true
|
||||
},
|
||||
cw: {
|
||||
type: "string",
|
||||
nullable: true,
|
||||
maxLength: 100
|
||||
},
|
||||
fileIds: {
|
||||
type: "array",
|
||||
uniqueItems: true,
|
||||
minItems: 1,
|
||||
maxItems: 16,
|
||||
items: {
|
||||
type: "string",
|
||||
format: "misskey:id"
|
||||
}
|
||||
},
|
||||
textLayers: {
|
||||
type: "array",
|
||||
maxItems: 32,
|
||||
default: [],
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: {
|
||||
type: "string",
|
||||
maxLength: 64
|
||||
},
|
||||
text: {
|
||||
type: "string",
|
||||
minLength: 1,
|
||||
maxLength: 200
|
||||
},
|
||||
color: {
|
||||
type: "string",
|
||||
maxLength: 32
|
||||
},
|
||||
backgroundColor: {
|
||||
type: "string",
|
||||
maxLength: 32,
|
||||
nullable: true
|
||||
},
|
||||
backgroundWidth: {
|
||||
type: "number",
|
||||
minimum: 0,
|
||||
maximum: 100,
|
||||
nullable: true
|
||||
},
|
||||
backgroundHeight: {
|
||||
type: "number",
|
||||
minimum: 0,
|
||||
maximum: 100,
|
||||
nullable: true
|
||||
},
|
||||
fontSize: {
|
||||
type: "number",
|
||||
minimum: 8,
|
||||
maximum: 96
|
||||
},
|
||||
x: {
|
||||
type: "number",
|
||||
minimum: 0,
|
||||
maximum: 100
|
||||
},
|
||||
y: {
|
||||
type: "number",
|
||||
minimum: 0,
|
||||
maximum: 100
|
||||
},
|
||||
rotate: {
|
||||
type: "number",
|
||||
minimum: -180,
|
||||
maximum: 180
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"text"
|
||||
],
|
||||
additionalProperties: false
|
||||
}
|
||||
},
|
||||
expiresAt: {
|
||||
type: "integer",
|
||||
nullable: true
|
||||
}
|
||||
},
|
||||
anyOf: [
|
||||
{
|
||||
properties: {
|
||||
text: {
|
||||
type: "string",
|
||||
minLength: 1,
|
||||
maxLength: MAX_NOTE_TEXT_LENGTH,
|
||||
nullable: false
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"text"
|
||||
]
|
||||
},
|
||||
{
|
||||
required: [
|
||||
"fileIds"
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
const colorPattern = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
||||
function clamp(value, min, max, fallback) {
|
||||
const num = typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
||||
return Math.min(max, Math.max(min, num));
|
||||
}
|
||||
function normalizeColor(value, fallback) {
|
||||
return typeof value === "string" && colorPattern.test(value) ? value : fallback;
|
||||
}
|
||||
function normalizeTextLayers(layers) {
|
||||
if (!Array.isArray(layers)) return [];
|
||||
return layers.slice(0, 32).flatMap((layer, index)=>{
|
||||
if (layer == null || typeof layer !== "object") return [];
|
||||
const input = layer;
|
||||
const text = typeof input.text === "string" ? input.text.trim().slice(0, 200) : "";
|
||||
if (text.length === 0) return [];
|
||||
const backgroundColor = input.backgroundColor == null || input.backgroundColor === "transparent" ? null : normalizeColor(input.backgroundColor, "#000000cc");
|
||||
return [
|
||||
{
|
||||
id: typeof input.id === "string" && input.id.length > 0 ? input.id.slice(0, 64) : genId(),
|
||||
text,
|
||||
color: normalizeColor(input.color, "#ffffff"),
|
||||
backgroundColor,
|
||||
backgroundWidth: input.backgroundWidth == null ? null : clamp(input.backgroundWidth, 0, 100, 0),
|
||||
backgroundHeight: input.backgroundHeight == null ? null : clamp(input.backgroundHeight, 0, 100, 0),
|
||||
fontSize: clamp(input.fontSize, 8, 96, 28),
|
||||
x: clamp(input.x, 0, 100, 50),
|
||||
y: clamp(input.y, 0, 100, 50 + index * 6),
|
||||
rotate: clamp(input.rotate, -180, 180, 0)
|
||||
}
|
||||
];
|
||||
});
|
||||
}
|
||||
export default define(meta, paramDef, async (ps, user)=>{
|
||||
const expiresAt = typeof ps.expiresAt === "number" ? new Date(ps.expiresAt) : null;
|
||||
if (expiresAt != null && expiresAt.getTime() <= Date.now()) {
|
||||
throw new ApiError(meta.errors.cannotExpireToPast);
|
||||
}
|
||||
const textLayers = normalizeTextLayers(ps.textLayers);
|
||||
const note = await createNoteFromApiData(user, {
|
||||
text: ps.text ? `${ps.text.trim()}\n#Memoriet` : "#Memoriet",
|
||||
cw: ps.cw,
|
||||
fileIds: ps.fileIds,
|
||||
visibility: ps.visibility,
|
||||
visibleUserIds: ps.visibleUserIds,
|
||||
localOnly: true
|
||||
}, new Date());
|
||||
const memoriet = await Memoriets.save({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
userId: user.id,
|
||||
noteId: note.id,
|
||||
expiresAt,
|
||||
textLayers
|
||||
});
|
||||
return {
|
||||
memoriet: {
|
||||
id: memoriet.id,
|
||||
expiresAt: memoriet.expiresAt?.toISOString() ?? null,
|
||||
textLayers: memoriet.textLayers,
|
||||
note: await Notes.pack(note, user)
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,119 @@
|
||||
import { DriveFiles, MemorietArchives } from "../../../../models/index.js";
|
||||
import define from "../../define.js";
|
||||
export const meta = {
|
||||
tags: [
|
||||
"memoriet"
|
||||
],
|
||||
requireCredential: true,
|
||||
kind: "read:account",
|
||||
res: {
|
||||
type: "array",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
properties: {
|
||||
id: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false
|
||||
},
|
||||
createdAt: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false
|
||||
},
|
||||
deletedAt: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false
|
||||
},
|
||||
text: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: true
|
||||
},
|
||||
cw: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: true
|
||||
},
|
||||
fileIds: {
|
||||
type: "array",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: "string"
|
||||
}
|
||||
},
|
||||
files: {
|
||||
type: "array",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: "object",
|
||||
ref: "DriveFile"
|
||||
}
|
||||
},
|
||||
textLayers: {
|
||||
type: "array",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false
|
||||
}
|
||||
},
|
||||
visibility: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
export const paramDef = {
|
||||
type: "object",
|
||||
properties: {
|
||||
limit: {
|
||||
type: "integer",
|
||||
minimum: 1,
|
||||
maximum: 50,
|
||||
default: 20
|
||||
},
|
||||
offset: {
|
||||
type: "integer",
|
||||
minimum: 0,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
required: []
|
||||
};
|
||||
export default define(meta, paramDef, async (ps, user)=>{
|
||||
const archives = await MemorietArchives.find({
|
||||
where: {
|
||||
userId: user.id
|
||||
},
|
||||
order: {
|
||||
deletedAt: "DESC"
|
||||
},
|
||||
skip: ps.offset,
|
||||
take: ps.limit
|
||||
});
|
||||
const files = await Promise.all(archives.map((archive)=>DriveFiles.packMany(archive.fileIds)));
|
||||
return archives.map((archive, index)=>({
|
||||
id: archive.id,
|
||||
createdAt: archive.createdAt.toISOString(),
|
||||
deletedAt: archive.deletedAt.toISOString(),
|
||||
text: archive.text,
|
||||
cw: archive.cw,
|
||||
fileIds: archive.fileIds,
|
||||
files: files[index],
|
||||
textLayers: archive.textLayers,
|
||||
visibility: archive.visibility
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,124 @@
|
||||
import { Brackets } from "typeorm";
|
||||
import { Notes, MemorietViews } from "../../../../models/index.js";
|
||||
import { genId } from "../../../../misc/gen-id.js";
|
||||
import define from "../../define.js";
|
||||
import { generateMutedUserQuery } from "../../common/generate-muted-user-query.js";
|
||||
import { generateBlockedUserQuery } from "../../common/generate-block-query.js";
|
||||
import { generateVisibilityQuery } from "../../common/generate-visibility-query.js";
|
||||
export const meta = {
|
||||
tags: [
|
||||
"memoriet"
|
||||
],
|
||||
requireCredential: false,
|
||||
requireCredentialPrivateMode: true,
|
||||
res: {
|
||||
type: "array",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
properties: {
|
||||
id: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false
|
||||
},
|
||||
expiresAt: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: true
|
||||
},
|
||||
textLayers: {
|
||||
type: "array",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false
|
||||
}
|
||||
},
|
||||
viewerCount: {
|
||||
type: "number",
|
||||
optional: false,
|
||||
nullable: true
|
||||
},
|
||||
note: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
ref: "Note"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
export const paramDef = {
|
||||
type: "object",
|
||||
properties: {
|
||||
limit: {
|
||||
type: "integer",
|
||||
minimum: 1,
|
||||
maximum: 50,
|
||||
default: 20
|
||||
},
|
||||
offset: {
|
||||
type: "integer",
|
||||
minimum: 0,
|
||||
default: 0
|
||||
},
|
||||
userId: {
|
||||
type: "string",
|
||||
format: "misskey:id",
|
||||
nullable: true
|
||||
}
|
||||
},
|
||||
required: []
|
||||
};
|
||||
export default define(meta, paramDef, async (ps, user)=>{
|
||||
const query = Notes.createQueryBuilder("note").innerJoinAndSelect("note.user", "user").leftJoinAndSelect("note.reply", "reply").leftJoinAndSelect("note.renote", "renote").leftJoinAndSelect("reply.user", "replyUser").leftJoinAndSelect("renote.user", "renoteUser").innerJoin("memoriet", "memoriet", "memoriet.noteId = note.id").addSelect("memoriet.id", "memoriet_id").addSelect("memoriet.userId", "memoriet_userId").addSelect("memoriet.createdAt", "memoriet_createdAt").addSelect("memoriet.expiresAt", "memoriet_expiresAt").addSelect("memoriet.textLayers", "memoriet_textLayers").andWhere(new Brackets((qb)=>{
|
||||
qb.where("memoriet.expiresAt IS NULL").orWhere("memoriet.expiresAt > :now", {
|
||||
now: new Date()
|
||||
});
|
||||
}));
|
||||
if (ps.userId) query.andWhere("note.userId = :userId", {
|
||||
userId: ps.userId
|
||||
});
|
||||
generateVisibilityQuery(query, user);
|
||||
if (user) generateMutedUserQuery(query, user);
|
||||
if (user) generateBlockedUserQuery(query, user);
|
||||
const { entities, raw } = await query.orderBy("memoriet.createdAt", "DESC").skip(ps.offset).take(ps.limit).getRawAndEntities();
|
||||
if (user) {
|
||||
const now = new Date();
|
||||
for (const row of raw){
|
||||
if (row.memoriet_userId === user.id) continue;
|
||||
await MemorietViews.query(`INSERT INTO "memoriet_view" ("id", "createdAt", "viewedAt", "memorietId", "viewerId") VALUES ($1, $2, $3, $4, $5) ON CONFLICT ("memorietId", "viewerId") DO UPDATE SET "viewedAt" = EXCLUDED."viewedAt"`, [
|
||||
genId(),
|
||||
now,
|
||||
now,
|
||||
row.memoriet_id,
|
||||
user.id
|
||||
]);
|
||||
}
|
||||
}
|
||||
const memorietIds = raw.map((row)=>row.memoriet_id);
|
||||
const viewerCounts = new Map();
|
||||
if (user && memorietIds.length > 0) {
|
||||
const counts = await MemorietViews.createQueryBuilder("view").select("view.memorietId", "memorietId").addSelect("COUNT(*)", "count").where("view.memorietId IN (:...memorietIds)", {
|
||||
memorietIds
|
||||
}).groupBy("view.memorietId").getRawMany();
|
||||
for (const count of counts){
|
||||
viewerCounts.set(count.memorietId, Number(count.count));
|
||||
}
|
||||
}
|
||||
const packed = await Notes.packMany(entities, user);
|
||||
return packed.map((note, index)=>({
|
||||
id: raw[index].memoriet_id,
|
||||
expiresAt: raw[index].memoriet_expiresAt?.toISOString?.() ?? raw[index].memoriet_expiresAt ?? null,
|
||||
textLayers: raw[index].memoriet_textLayers ?? [],
|
||||
viewerCount: user && raw[index].memoriet_userId === user.id ? viewerCounts.get(raw[index].memoriet_id) ?? 0 : null,
|
||||
note
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,125 @@
|
||||
import { MemorietArchives, Memoriets, Notes } from "../../../../models/index.js";
|
||||
import { noteVisibilities } from "../../../../types.js";
|
||||
import define from "../../define.js";
|
||||
import { ApiError } from "../../error.js";
|
||||
import { HOUR } from "../../../../const.js";
|
||||
import { createNoteFromApiData } from "../../../../services/note/create-from-api.js";
|
||||
import { genId } from "../../../../misc/gen-id.js";
|
||||
export const meta = {
|
||||
tags: [
|
||||
"memoriet"
|
||||
],
|
||||
requireCredential: true,
|
||||
limit: {
|
||||
duration: HOUR,
|
||||
max: 300
|
||||
},
|
||||
kind: "write:notes",
|
||||
res: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
properties: {
|
||||
memoriet: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
properties: {
|
||||
id: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false
|
||||
},
|
||||
expiresAt: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: true
|
||||
},
|
||||
textLayers: {
|
||||
type: "array",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false
|
||||
}
|
||||
},
|
||||
note: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
ref: "Note"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
errors: {
|
||||
noSuchArchive: {
|
||||
message: "No such Memoriet archive.",
|
||||
code: "NO_SUCH_MEMORIET_ARCHIVE",
|
||||
id: "53e0b18f-4f1d-49c0-ad79-ad2944cbe139",
|
||||
httpStatusCode: 404
|
||||
},
|
||||
cannotExpireToPast: {
|
||||
message: "Expiration time must be in the future.",
|
||||
code: "CANNOT_EXPIRE_TO_PAST",
|
||||
id: "12ff555a-fb0c-40ed-b253-1aa5d6ed2461"
|
||||
}
|
||||
}
|
||||
};
|
||||
export const paramDef = {
|
||||
type: "object",
|
||||
properties: {
|
||||
archiveId: {
|
||||
type: "string",
|
||||
format: "misskey:id"
|
||||
},
|
||||
visibility: {
|
||||
type: "string",
|
||||
enum: noteVisibilities
|
||||
},
|
||||
expiresAt: {
|
||||
type: "integer",
|
||||
nullable: true
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"archiveId"
|
||||
]
|
||||
};
|
||||
export default define(meta, paramDef, async (ps, user)=>{
|
||||
const archive = await MemorietArchives.findOneBy({
|
||||
id: ps.archiveId,
|
||||
userId: user.id
|
||||
});
|
||||
if (!archive) throw new ApiError(meta.errors.noSuchArchive);
|
||||
const expiresAt = typeof ps.expiresAt === "number" ? new Date(ps.expiresAt) : null;
|
||||
if (expiresAt != null && expiresAt.getTime() <= Date.now()) {
|
||||
throw new ApiError(meta.errors.cannotExpireToPast);
|
||||
}
|
||||
const note = await createNoteFromApiData(user, {
|
||||
text: archive.text ? `${archive.text.trim()}\n#Memoriet` : "#Memoriet",
|
||||
cw: archive.cw,
|
||||
fileIds: archive.fileIds,
|
||||
visibility: ps.visibility ?? archive.visibility,
|
||||
localOnly: true
|
||||
}, new Date());
|
||||
const memoriet = await Memoriets.save({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
userId: user.id,
|
||||
noteId: note.id,
|
||||
expiresAt,
|
||||
textLayers: archive.textLayers
|
||||
});
|
||||
return {
|
||||
memoriet: {
|
||||
id: memoriet.id,
|
||||
expiresAt: memoriet.expiresAt?.toISOString() ?? null,
|
||||
textLayers: memoriet.textLayers,
|
||||
note: await Notes.pack(note, user)
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,94 @@
|
||||
import { Memoriets, MemorietViews, Users } from "../../../../models/index.js";
|
||||
import define from "../../define.js";
|
||||
import { ApiError } from "../../error.js";
|
||||
export const meta = {
|
||||
tags: [
|
||||
"memoriet"
|
||||
],
|
||||
requireCredential: true,
|
||||
kind: "read:account",
|
||||
res: {
|
||||
type: "array",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
items: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
properties: {
|
||||
viewedAt: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false
|
||||
},
|
||||
user: {
|
||||
type: "object",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
ref: "User"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
errors: {
|
||||
noSuchMemoriet: {
|
||||
message: "No such Memoriet.",
|
||||
code: "NO_SUCH_MEMORIET",
|
||||
id: "1470626e-d318-4e01-9294-fbfa1260e6c4",
|
||||
httpStatusCode: 404
|
||||
},
|
||||
accessDenied: {
|
||||
message: "You cannot see viewers of this Memoriet.",
|
||||
code: "ACCESS_DENIED",
|
||||
id: "d705b05b-23c0-4b93-a5bb-2c303c66db2b",
|
||||
httpStatusCode: 403
|
||||
}
|
||||
}
|
||||
};
|
||||
export const paramDef = {
|
||||
type: "object",
|
||||
properties: {
|
||||
memorietId: {
|
||||
type: "string",
|
||||
format: "misskey:id"
|
||||
},
|
||||
limit: {
|
||||
type: "integer",
|
||||
minimum: 1,
|
||||
maximum: 100,
|
||||
default: 50
|
||||
},
|
||||
offset: {
|
||||
type: "integer",
|
||||
minimum: 0,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
required: [
|
||||
"memorietId"
|
||||
]
|
||||
};
|
||||
export default define(meta, paramDef, async (ps, user)=>{
|
||||
const memoriet = await Memoriets.findOneBy({
|
||||
id: ps.memorietId
|
||||
});
|
||||
if (!memoriet) throw new ApiError(meta.errors.noSuchMemoriet);
|
||||
if (memoriet.userId !== user.id) throw new ApiError(meta.errors.accessDenied);
|
||||
const views = await MemorietViews.find({
|
||||
where: {
|
||||
memorietId: memoriet.id
|
||||
},
|
||||
order: {
|
||||
viewedAt: "DESC"
|
||||
},
|
||||
skip: ps.offset,
|
||||
take: ps.limit
|
||||
});
|
||||
const users = await Users.packMany(views.map((view)=>view.viewerId), user, {
|
||||
detail: false
|
||||
});
|
||||
return views.map((view, index)=>({
|
||||
viewedAt: view.viewedAt.toISOString(),
|
||||
user: users[index]
|
||||
}));
|
||||
});
|
||||
Reference in New Issue
Block a user