mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-09 19:23:08 +02:00
refactor
This commit is contained in:
parent
daa0ca72a7
commit
9f7cdb4bc7
1 changed files with 8 additions and 8 deletions
|
@ -9,6 +9,7 @@ import { Note } from '@/models/entities/note.js';
|
||||||
import { noteVisibilities } from '../../../../types.js';
|
import { noteVisibilities } from '../../../../types.js';
|
||||||
import { Channel } from '@/models/entities/channel.js';
|
import { Channel } from '@/models/entities/channel.js';
|
||||||
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
|
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
|
||||||
|
import { In } from 'typeorm';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['notes'],
|
tags: ['notes'],
|
||||||
|
@ -163,19 +164,18 @@ export const paramDef = {
|
||||||
export default define(meta, paramDef, async (ps, user) => {
|
export default define(meta, paramDef, async (ps, user) => {
|
||||||
let visibleUsers: User[] = [];
|
let visibleUsers: User[] = [];
|
||||||
if (ps.visibleUserIds) {
|
if (ps.visibleUserIds) {
|
||||||
visibleUsers = (await Promise.all(ps.visibleUserIds.map(id => Users.findOneBy({ id }))))
|
visibleUsers = await Users.findBy({
|
||||||
.filter(x => x != null) as User[];
|
id: In(ps.visibleUserIds),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let files: DriveFile[] = [];
|
let files: DriveFile[] = [];
|
||||||
const fileIds = ps.fileIds != null ? ps.fileIds : ps.mediaIds != null ? ps.mediaIds : null;
|
const fileIds = ps.fileIds != null ? ps.fileIds : ps.mediaIds != null ? ps.mediaIds : null;
|
||||||
if (fileIds != null) {
|
if (fileIds != null) {
|
||||||
files = (await Promise.all(fileIds.map(fileId =>
|
files = await DriveFiles.findBy({
|
||||||
DriveFiles.findOneBy({
|
userId: user.id,
|
||||||
id: fileId,
|
id: In(fileIds),
|
||||||
userId: user.id,
|
});
|
||||||
})
|
|
||||||
))).filter(file => file != null) as DriveFile[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let renote: Note | null;
|
let renote: Note | null;
|
||||||
|
|
Loading…
Reference in a new issue