This commit is contained in:
parent
db943df0c8
commit
a1b82e9723
43 changed files with 167 additions and 196 deletions
|
@ -71,9 +71,15 @@ export const meta = {
|
|||
ref: 'geo'
|
||||
}),
|
||||
|
||||
fileIds: $.arr($.type(ID)).optional.unique().range(1, 4).note({
|
||||
desc: {
|
||||
'ja-JP': '添付するファイル'
|
||||
}
|
||||
}),
|
||||
|
||||
mediaIds: $.arr($.type(ID)).optional.unique().range(1, 4).note({
|
||||
desc: {
|
||||
'ja-JP': '添付するメディア'
|
||||
'ja-JP': '添付するファイル (このパラメータは廃止予定です。代わりに fileIds を使ってください。)'
|
||||
}
|
||||
}),
|
||||
|
||||
|
@ -124,15 +130,16 @@ export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (
|
|||
}
|
||||
|
||||
let files: IDriveFile[] = [];
|
||||
if (ps.mediaIds !== undefined) {
|
||||
const fileIds = ps.fileIds != null ? ps.fileIds : ps.mediaIds != null ? ps.mediaIds : null;
|
||||
if (fileIds != null) {
|
||||
// Fetch files
|
||||
// forEach だと途中でエラーなどがあっても return できないので
|
||||
// 敢えて for を使っています。
|
||||
for (const mediaId of ps.mediaIds) {
|
||||
for (const fileId of fileIds) {
|
||||
// Fetch file
|
||||
// SELECT _id
|
||||
const entity = await DriveFile.findOne({
|
||||
_id: mediaId,
|
||||
_id: fileId,
|
||||
'metadata.userId': user._id
|
||||
});
|
||||
|
||||
|
@ -155,7 +162,7 @@ export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (
|
|||
|
||||
if (renote == null) {
|
||||
return rej('renoteee is not found');
|
||||
} else if (renote.renoteId && !renote.text && !renote.mediaIds) {
|
||||
} else if (renote.renoteId && !renote.text && !renote.fileIds) {
|
||||
return rej('cannot renote to renote');
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +183,7 @@ export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (
|
|||
}
|
||||
|
||||
// 返信対象が引用でないRenoteだったらエラー
|
||||
if (reply.renoteId && !reply.text && !reply.mediaIds) {
|
||||
if (reply.renoteId && !reply.text && !reply.fileIds) {
|
||||
return rej('cannot reply to renote');
|
||||
}
|
||||
}
|
||||
|
@ -191,13 +198,13 @@ export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (
|
|||
|
||||
// テキストが無いかつ添付ファイルが無いかつRenoteも無いかつ投票も無かったらエラー
|
||||
if ((ps.text === undefined || ps.text === null) && files === null && renote === null && ps.poll === undefined) {
|
||||
return rej('text, mediaIds, renoteId or poll is required');
|
||||
return rej('text, fileIds, renoteId or poll is required');
|
||||
}
|
||||
|
||||
// 投稿を作成
|
||||
const note = await create(user, {
|
||||
createdAt: new Date(),
|
||||
media: files,
|
||||
files: files,
|
||||
poll: ps.poll,
|
||||
text: ps.text,
|
||||
reply,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue