Refactoring, Clean up and bug fixes
This commit is contained in:
@@ -1,26 +1,41 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note, { packMany, INote } from '../../../../models/note';
|
||||
import { ILocalUser } from '../../../../models/user';
|
||||
import getParams from '../../get-params';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
'ja-JP': '指定した投稿の文脈を取得します。',
|
||||
'en-US': 'Show conversation of a note.'
|
||||
},
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 100),
|
||||
default: 10
|
||||
},
|
||||
|
||||
offset: {
|
||||
validator: $.num.optional.min(0),
|
||||
default: 0
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Show conversation of a note
|
||||
*/
|
||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'noteId' parameter
|
||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||
if (noteIdErr) return rej('invalid noteId param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'offset' parameter
|
||||
const [offset = 0, offsetErr] = $.num.optional.min(0).get(params.offset);
|
||||
if (offsetErr) return rej('invalid offset param');
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
// Lookup note
|
||||
const note = await Note.findOne({
|
||||
_id: noteId
|
||||
_id: ps.noteId
|
||||
});
|
||||
|
||||
if (note === null) {
|
||||
@@ -34,11 +49,11 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
||||
i++;
|
||||
const p = await Note.findOne({ _id: id });
|
||||
|
||||
if (i > offset) {
|
||||
if (i > ps.offset) {
|
||||
conversation.push(p);
|
||||
}
|
||||
|
||||
if (conversation.length == limit) {
|
||||
if (conversation.length == ps.limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,6 +66,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
||||
await get(note.replyId);
|
||||
}
|
||||
|
||||
// Serialize
|
||||
res(await packMany(conversation, user));
|
||||
});
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform, transformMany } from '../../../../misc/cafy-id';
|
||||
const ms = require('ms');
|
||||
import Note, { INote, isValidText, isValidCw, pack } from '../../../../models/note';
|
||||
import User, { ILocalUser, IUser } from '../../../../models/user';
|
||||
@@ -24,84 +24,106 @@ export const meta = {
|
||||
kind: 'note-write',
|
||||
|
||||
params: {
|
||||
visibility: $.str.optional.or(['public', 'home', 'followers', 'specified', 'private']).note({
|
||||
visibility: {
|
||||
validator: $.str.optional.or(['public', 'home', 'followers', 'specified', 'private']),
|
||||
default: 'public',
|
||||
desc: {
|
||||
'ja-JP': '投稿の公開範囲'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
visibleUserIds: $.arr($.type(ID)).optional.unique().min(1).note({
|
||||
visibleUserIds: {
|
||||
validator: $.arr($.type(ID)).optional.unique().min(1),
|
||||
transform: transformMany,
|
||||
desc: {
|
||||
'ja-JP': '(投稿の公開範囲が specified の場合)投稿を閲覧できるユーザー'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
text: $.str.optional.nullable.pipe(isValidText).note({
|
||||
default: null,
|
||||
text: {
|
||||
validator: $.str.optional.nullable.pipe(isValidText),
|
||||
default: null as any,
|
||||
desc: {
|
||||
'ja-JP': '投稿内容'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
cw: $.str.optional.nullable.pipe(isValidCw).note({
|
||||
cw: {
|
||||
validator: $.str.optional.nullable.pipe(isValidCw),
|
||||
desc: {
|
||||
'ja-JP': 'コンテンツの警告。このパラメータを指定すると設定したテキストで投稿のコンテンツを隠す事が出来ます。'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
viaMobile: $.bool.optional.note({
|
||||
viaMobile: {
|
||||
validator: $.bool.optional,
|
||||
default: false,
|
||||
desc: {
|
||||
'ja-JP': 'モバイルデバイスからの投稿か否か。'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
geo: $.obj({
|
||||
coordinates: $.arr().length(2)
|
||||
.item(0, $.num.range(-180, 180))
|
||||
.item(1, $.num.range(-90, 90)),
|
||||
altitude: $.num.nullable,
|
||||
accuracy: $.num.nullable,
|
||||
altitudeAccuracy: $.num.nullable,
|
||||
heading: $.num.nullable.range(0, 360),
|
||||
speed: $.num.nullable
|
||||
}).optional.nullable.strict().note({
|
||||
geo: {
|
||||
validator: $.obj({
|
||||
coordinates: $.arr().length(2)
|
||||
.item(0, $.num.range(-180, 180))
|
||||
.item(1, $.num.range(-90, 90)),
|
||||
altitude: $.num.nullable,
|
||||
accuracy: $.num.nullable,
|
||||
altitudeAccuracy: $.num.nullable,
|
||||
heading: $.num.nullable.range(0, 360),
|
||||
speed: $.num.nullable
|
||||
}).optional.nullable.strict(),
|
||||
desc: {
|
||||
'ja-JP': '位置情報'
|
||||
},
|
||||
ref: 'geo'
|
||||
}),
|
||||
},
|
||||
|
||||
fileIds: $.arr($.type(ID)).optional.unique().range(1, 4).note({
|
||||
fileIds: {
|
||||
validator: $.arr($.type(ID)).optional.unique().range(1, 4),
|
||||
transform: transformMany,
|
||||
desc: {
|
||||
'ja-JP': '添付するファイル'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
mediaIds: $.arr($.type(ID)).optional.unique().range(1, 4).note({
|
||||
mediaIds: {
|
||||
validator: $.arr($.type(ID)).optional.unique().range(1, 4),
|
||||
transform: transformMany,
|
||||
desc: {
|
||||
'ja-JP': '添付するファイル (このパラメータは廃止予定です。代わりに fileIds を使ってください。)'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
renoteId: $.type(ID).optional.note({
|
||||
replyId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '返信対象'
|
||||
}
|
||||
},
|
||||
|
||||
renoteId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': 'Renote対象'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
poll: $.obj({
|
||||
choices: $.arr($.str)
|
||||
.unique()
|
||||
.range(2, 10)
|
||||
.each(c => c.length > 0 && c.length < 50)
|
||||
}).optional.strict().note({
|
||||
poll: {
|
||||
validator: $.obj({
|
||||
choices: $.arr($.str)
|
||||
.unique()
|
||||
.range(2, 10)
|
||||
.each(c => c.length > 0 && c.length < 50)
|
||||
}).optional.strict(),
|
||||
desc: {
|
||||
'ja-JP': 'アンケート'
|
||||
},
|
||||
ref: 'poll'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
res: {
|
||||
@@ -117,15 +139,12 @@ export const meta = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a note
|
||||
*/
|
||||
export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
let visibleUsers: IUser[] = [];
|
||||
if (ps.visibleUserIds !== undefined) {
|
||||
if (ps.visibleUserIds) {
|
||||
visibleUsers = await Promise.all(ps.visibleUserIds.map(id => User.findOne({
|
||||
_id: id
|
||||
})));
|
||||
@@ -145,7 +164,7 @@ export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (
|
||||
}
|
||||
|
||||
let renote: INote = null;
|
||||
if (ps.renoteId !== undefined) {
|
||||
if (ps.renoteId != null) {
|
||||
// Fetch renote to note
|
||||
renote = await Note.findOne({
|
||||
_id: ps.renoteId
|
||||
@@ -158,15 +177,11 @@ export default (params: any, user: ILocalUser, app: IApp) => new Promise(async (
|
||||
}
|
||||
}
|
||||
|
||||
// Get 'replyId' parameter
|
||||
const [replyId, replyIdErr] = $.type(ID).optional.get(params.replyId);
|
||||
if (replyIdErr) return rej('invalid replyId');
|
||||
|
||||
let reply: INote = null;
|
||||
if (replyId !== undefined) {
|
||||
if (ps.replyId != null) {
|
||||
// Fetch reply
|
||||
reply = await Note.findOne({
|
||||
_id: replyId
|
||||
_id: ps.replyId
|
||||
});
|
||||
|
||||
if (reply === null) {
|
||||
@@ -188,7 +203,7 @@ 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) {
|
||||
if ((ps.text == null) && files === null && renote === null && ps.poll == null) {
|
||||
return rej('text, fileIds, renoteId or poll is required');
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note from '../../../../models/note';
|
||||
import deleteNote from '../../../../services/note/delete';
|
||||
import User, { ILocalUser } from '../../../../models/user';
|
||||
@@ -17,12 +17,14 @@ export const meta = {
|
||||
kind: 'note-write',
|
||||
|
||||
params: {
|
||||
noteId: $.type(ID).note({
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '対象の投稿のID',
|
||||
'en-US': 'Target note ID.'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
|
||||
import Favorite from '../../../../../models/favorite';
|
||||
import Note from '../../../../../models/note';
|
||||
import { ILocalUser } from '../../../../../models/user';
|
||||
@@ -17,12 +17,14 @@ export const meta = {
|
||||
kind: 'favorite-write',
|
||||
|
||||
params: {
|
||||
noteId: $.type(ID).note({
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '対象の投稿のID',
|
||||
'en-US': 'Target note ID.'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
|
||||
import Favorite from '../../../../../models/favorite';
|
||||
import Note from '../../../../../models/note';
|
||||
import { ILocalUser } from '../../../../../models/user';
|
||||
@@ -17,12 +17,14 @@ export const meta = {
|
||||
kind: 'favorite-write',
|
||||
|
||||
params: {
|
||||
noteId: $.type(ID).note({
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '対象の投稿のID',
|
||||
'en-US': 'Target note ID.'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -13,12 +13,13 @@ export const meta = {
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
limit: $.num.optional.range(1, 30).note({
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 30),
|
||||
default: 10,
|
||||
desc: {
|
||||
'ja-JP': '最大数'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note from '../../../../models/note';
|
||||
import Mute from '../../../../models/mute';
|
||||
import { packMany } from '../../../../models/note';
|
||||
@@ -12,29 +12,42 @@ export const meta = {
|
||||
},
|
||||
|
||||
params: {
|
||||
withFiles: $.bool.optional.note({
|
||||
withFiles: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'ファイルが添付された投稿に限定するか否か'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
mediaOnly: $.bool.optional.note({
|
||||
mediaOnly: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'ファイルが添付された投稿に限定するか否か (このパラメータは廃止予定です。代わりに withFiles を使ってください。)'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
limit: $.num.optional.range(1, 100).note({
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 100),
|
||||
default: 10
|
||||
}),
|
||||
},
|
||||
|
||||
sinceId: $.type(ID).optional.note({}),
|
||||
sinceId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
untilId: $.type(ID).optional.note({}),
|
||||
untilId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
sinceDate: $.num.optional.note({}),
|
||||
sinceDate: {
|
||||
validator: $.num.optional
|
||||
},
|
||||
|
||||
untilDate: $.num.optional.note({}),
|
||||
untilDate: {
|
||||
validator: $.num.optional
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note from '../../../../models/note';
|
||||
import Mute from '../../../../models/mute';
|
||||
import { getFriends } from '../../common/get-friends';
|
||||
@@ -13,69 +13,81 @@ export const meta = {
|
||||
},
|
||||
|
||||
params: {
|
||||
limit: $.num.optional.range(1, 100).note({
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 100),
|
||||
default: 10,
|
||||
desc: {
|
||||
'ja-JP': '最大数'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
sinceId: $.type(ID).optional.note({
|
||||
sinceId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '指定すると、この投稿を基点としてより新しい投稿を取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
untilId: $.type(ID).optional.note({
|
||||
untilId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '指定すると、この投稿を基点としてより古い投稿を取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
sinceDate: $.num.optional.note({
|
||||
sinceDate: {
|
||||
validator: $.num.optional,
|
||||
desc: {
|
||||
'ja-JP': '指定した時間を基点としてより新しい投稿を取得します。数値は、1970年1月1日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
untilDate: $.num.optional.note({
|
||||
untilDate: {
|
||||
validator: $.num.optional,
|
||||
desc: {
|
||||
'ja-JP': '指定した時間を基点としてより古い投稿を取得します。数値は、1970年1月1日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
includeMyRenotes: $.bool.optional.note({
|
||||
includeMyRenotes: {
|
||||
validator: $.bool.optional,
|
||||
default: true,
|
||||
desc: {
|
||||
'ja-JP': '自分の行ったRenoteを含めるかどうか'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
includeRenotedMyNotes: $.bool.optional.note({
|
||||
includeRenotedMyNotes: {
|
||||
validator: $.bool.optional,
|
||||
default: true,
|
||||
desc: {
|
||||
'ja-JP': 'Renoteされた自分の投稿を含めるかどうか'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
includeLocalRenotes: $.bool.optional.note({
|
||||
includeLocalRenotes: {
|
||||
validator: $.bool.optional,
|
||||
default: true,
|
||||
desc: {
|
||||
'ja-JP': 'Renoteされたローカルの投稿を含めるかどうか'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
withFiles: $.bool.optional.note({
|
||||
withFiles: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
mediaOnly: $.bool.optional.note({
|
||||
mediaOnly: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します (このパラメータは廃止予定です。代わりに withFiles を使ってください。)'
|
||||
}
|
||||
}),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note from '../../../../models/note';
|
||||
import Mute from '../../../../models/mute';
|
||||
import { packMany } from '../../../../models/note';
|
||||
@@ -12,42 +12,57 @@ export const meta = {
|
||||
},
|
||||
|
||||
params: {
|
||||
withFiles: $.bool.optional.note({
|
||||
withFiles: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'ファイルが添付された投稿に限定するか否か'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
mediaOnly: $.bool.optional.note({
|
||||
mediaOnly: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'ファイルが添付された投稿に限定するか否か (このパラメータは廃止予定です。代わりに withFiles を使ってください。)'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
fileType: $.arr($.str).optional.note({
|
||||
fileType: {
|
||||
validator: $.arr($.str).optional,
|
||||
desc: {
|
||||
'ja-JP': '指定された種類のファイルが添付された投稿のみを取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
excludeNsfw: $.bool.optional.note({
|
||||
excludeNsfw: {
|
||||
validator: $.bool.optional,
|
||||
default: false,
|
||||
desc: {
|
||||
'ja-JP': 'true にすると、NSFW指定されたファイルを除外します(fileTypeが指定されている場合のみ有効)'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
limit: $.num.optional.range(1, 100).note({
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 100),
|
||||
default: 10
|
||||
}),
|
||||
},
|
||||
|
||||
sinceId: $.type(ID).optional.note({}),
|
||||
sinceId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
untilId: $.type(ID).optional.note({}),
|
||||
untilId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
sinceDate: $.num.optional.note({}),
|
||||
sinceDate: {
|
||||
validator: $.num.optional,
|
||||
},
|
||||
|
||||
untilDate: $.num.optional.note({}),
|
||||
untilDate: {
|
||||
validator: $.num.optional,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note from '../../../../models/note';
|
||||
import { getFriendIds } from '../../common/get-friends';
|
||||
import { packMany } from '../../../../models/note';
|
||||
@@ -15,22 +15,29 @@ export const meta = {
|
||||
requireCredential: true,
|
||||
|
||||
params: {
|
||||
following: $.bool.optional.note({
|
||||
following: {
|
||||
validator: $.bool.optional,
|
||||
default: false
|
||||
}),
|
||||
},
|
||||
|
||||
limit: $.num.optional.range(1, 100).note({
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 100),
|
||||
default: 10
|
||||
}),
|
||||
},
|
||||
|
||||
sinceId: $.type(ID).optional.note({
|
||||
}),
|
||||
sinceId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
untilId: $.type(ID).optional.note({
|
||||
}),
|
||||
untilId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
visibility: $.str.optional.note({
|
||||
}),
|
||||
visibility: {
|
||||
validator: $.str.optional,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
|
||||
import Vote from '../../../../../models/poll-vote';
|
||||
import Note from '../../../../../models/note';
|
||||
import Watching from '../../../../../models/note-watching';
|
||||
@@ -6,6 +6,7 @@ import watch from '../../../../../services/note/watch';
|
||||
import { publishNoteStream } from '../../../../../stream';
|
||||
import notify from '../../../../../notify';
|
||||
import { ILocalUser } from '../../../../../models/user';
|
||||
import getParams from '../../../get-params';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
@@ -15,17 +16,27 @@ export const meta = {
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'vote-write'
|
||||
kind: 'vote-write',
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
choice: {
|
||||
validator: $.num
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'noteId' parameter
|
||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||
if (noteIdErr) return rej('invalid noteId param');
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
// Get votee
|
||||
const note = await Note.findOne({
|
||||
_id: noteId
|
||||
_id: ps.noteId
|
||||
});
|
||||
|
||||
if (note === null) {
|
||||
@@ -36,12 +47,7 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
||||
return rej('poll not found');
|
||||
}
|
||||
|
||||
// Get 'choice' parameter
|
||||
const [choice, choiceError] =
|
||||
$.num
|
||||
.pipe(c => note.poll.choices.some(x => x.id == c))
|
||||
.get(params.choice);
|
||||
if (choiceError) return rej('invalid choice param');
|
||||
if (!note.poll.choices.some(x => x.id == ps.choice)) return rej('invalid choice param');
|
||||
|
||||
// if already voted
|
||||
const exist = await Vote.findOne({
|
||||
@@ -58,14 +64,14 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
||||
createdAt: new Date(),
|
||||
noteId: note._id,
|
||||
userId: user._id,
|
||||
choice: choice
|
||||
choice: ps.choice
|
||||
});
|
||||
|
||||
// Send response
|
||||
res();
|
||||
|
||||
const inc: any = {};
|
||||
inc[`poll.choices.${note.poll.choices.findIndex(c => c.id == choice)}.votes`] = 1;
|
||||
inc[`poll.choices.${note.poll.choices.findIndex(c => c.id == ps.choice)}.votes`] = 1;
|
||||
|
||||
// Increment votes count
|
||||
await Note.update({ _id: note._id }, {
|
||||
@@ -73,14 +79,14 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
||||
});
|
||||
|
||||
publishNoteStream(note._id, 'pollVoted', {
|
||||
choice: choice,
|
||||
choice: ps.choice,
|
||||
userId: user._id.toHexString()
|
||||
});
|
||||
|
||||
// Notify
|
||||
notify(note.userId, user._id, 'poll_vote', {
|
||||
noteId: note._id,
|
||||
choice: choice
|
||||
choice: ps.choice
|
||||
});
|
||||
|
||||
// Fetch watchers
|
||||
@@ -99,7 +105,7 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
||||
watchers.forEach(watcher => {
|
||||
notify(watcher.userId, user._id, 'poll_vote', {
|
||||
noteId: note._id,
|
||||
choice: choice
|
||||
choice: ps.choice
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note from '../../../../models/note';
|
||||
import Reaction, { pack } from '../../../../models/note-reaction';
|
||||
import { ILocalUser } from '../../../../models/user';
|
||||
@@ -13,26 +13,34 @@ export const meta = {
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: $.type(ID).note({
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '対象の投稿のID',
|
||||
'en-US': 'The ID of the target note'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
limit: $.num.optional.range(1, 100).note({
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 100),
|
||||
default: 10
|
||||
}),
|
||||
},
|
||||
|
||||
offset: $.num.optional.note({
|
||||
offset: {
|
||||
validator: $.num.optional,
|
||||
default: 0
|
||||
}),
|
||||
},
|
||||
|
||||
sinceId: $.type(ID).optional.note({
|
||||
}),
|
||||
sinceId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
untilId: $.type(ID).optional.note({
|
||||
}),
|
||||
untilId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
|
||||
import Note from '../../../../../models/note';
|
||||
import create from '../../../../../services/note/reaction/create';
|
||||
import { validateReaction } from '../../../../../models/note-reaction';
|
||||
@@ -18,17 +18,20 @@ export const meta = {
|
||||
kind: 'reaction-write',
|
||||
|
||||
params: {
|
||||
noteId: $.type(ID).note({
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '対象の投稿'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
reaction: $.str.pipe(validateReaction.ok).note({
|
||||
reaction: {
|
||||
validator: $.str.pipe(validateReaction.ok),
|
||||
desc: {
|
||||
'ja-JP': 'リアクションの種類'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import $ from 'cafy'; import ID from '../../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
|
||||
import Reaction from '../../../../../models/note-reaction';
|
||||
import Note from '../../../../../models/note';
|
||||
import { ILocalUser } from '../../../../../models/user';
|
||||
import getParams from '../../../get-params';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
@@ -11,17 +12,23 @@ export const meta = {
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'reaction-write'
|
||||
kind: 'reaction-write',
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'noteId' parameter
|
||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||
if (noteIdErr) return rej('invalid noteId param');
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
// Fetch unreactee
|
||||
const note = await Note.findOne({
|
||||
_id: noteId
|
||||
_id: ps.noteId
|
||||
});
|
||||
|
||||
if (note === null) {
|
||||
@@ -48,7 +55,6 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
|
||||
}
|
||||
});
|
||||
|
||||
// Send response
|
||||
res();
|
||||
|
||||
const dec: any = {};
|
||||
|
81
src/server/api/endpoints/notes/renotes.ts
Normal file
81
src/server/api/endpoints/notes/renotes.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note, { packMany } from '../../../../models/note';
|
||||
import { ILocalUser } from '../../../../models/user';
|
||||
import getParams from '../../get-params';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
'ja-JP': '指定した投稿のRenote一覧を取得します。',
|
||||
'en-US': 'Show a renotes of a note.'
|
||||
},
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 100),
|
||||
default: 10
|
||||
},
|
||||
|
||||
sinceId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
untilId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
// Check if both of sinceId and untilId is specified
|
||||
if (ps.sinceId && ps.untilId) {
|
||||
return rej('cannot set sinceId and untilId');
|
||||
}
|
||||
|
||||
// Lookup note
|
||||
const note = await Note.findOne({
|
||||
_id: ps.noteId
|
||||
});
|
||||
|
||||
if (note === null) {
|
||||
return rej('note not found');
|
||||
}
|
||||
|
||||
const sort = {
|
||||
_id: -1
|
||||
};
|
||||
|
||||
const query = {
|
||||
renoteId: note._id
|
||||
} as any;
|
||||
|
||||
if (ps.sinceId) {
|
||||
sort._id = 1;
|
||||
query._id = {
|
||||
$gt: ps.sinceId
|
||||
};
|
||||
} else if (ps.untilId) {
|
||||
query._id = {
|
||||
$lt: ps.untilId
|
||||
};
|
||||
}
|
||||
|
||||
const renotes = await Note
|
||||
.find(query, {
|
||||
limit: ps.limit,
|
||||
sort: sort
|
||||
});
|
||||
|
||||
res(await packMany(renotes, user));
|
||||
});
|
@@ -1,34 +1,48 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note, { packMany } from '../../../../models/note';
|
||||
import { ILocalUser } from '../../../../models/user';
|
||||
import getParams from '../../get-params';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
'ja-JP': '指定した投稿への返信を取得します。',
|
||||
'en-US': 'Get replies of a note.'
|
||||
},
|
||||
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
},
|
||||
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 100),
|
||||
default: 10
|
||||
},
|
||||
|
||||
offset: {
|
||||
validator: $.num.optional.min(0),
|
||||
default: 0
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get replies of a note
|
||||
*/
|
||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'noteId' parameter
|
||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||
if (noteIdErr) return rej('invalid noteId param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'offset' parameter
|
||||
const [offset = 0, offsetErr] = $.num.optional.min(0).get(params.offset);
|
||||
if (offsetErr) return rej('invalid offset param');
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
// Lookup note
|
||||
const note = await Note.findOne({
|
||||
_id: noteId
|
||||
_id: ps.noteId
|
||||
});
|
||||
|
||||
if (note === null) {
|
||||
return rej('note not found');
|
||||
}
|
||||
|
||||
const ids = (note._replyIds || []).slice(offset, offset + limit);
|
||||
const ids = (note._replyIds || []).slice(ps.offset, ps.offset + ps.limit);
|
||||
|
||||
// Serialize
|
||||
res(await packMany(ids, user));
|
||||
});
|
||||
|
@@ -1,66 +0,0 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import Note, { packMany } from '../../../../models/note';
|
||||
import { ILocalUser } from '../../../../models/user';
|
||||
|
||||
/**
|
||||
* Show a renotes of a note
|
||||
*/
|
||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'noteId' parameter
|
||||
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
||||
if (noteIdErr) return rej('invalid noteId param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'sinceId' parameter
|
||||
const [sinceId, sinceIdErr] = $.type(ID).optional.get(params.sinceId);
|
||||
if (sinceIdErr) return rej('invalid sinceId param');
|
||||
|
||||
// Get 'untilId' parameter
|
||||
const [untilId, untilIdErr] = $.type(ID).optional.get(params.untilId);
|
||||
if (untilIdErr) return rej('invalid untilId param');
|
||||
|
||||
// Check if both of sinceId and untilId is specified
|
||||
if (sinceId && untilId) {
|
||||
return rej('cannot set sinceId and untilId');
|
||||
}
|
||||
|
||||
// Lookup note
|
||||
const note = await Note.findOne({
|
||||
_id: noteId
|
||||
});
|
||||
|
||||
if (note === null) {
|
||||
return rej('note not found');
|
||||
}
|
||||
|
||||
// Construct query
|
||||
const sort = {
|
||||
_id: -1
|
||||
};
|
||||
const query = {
|
||||
renoteId: note._id
|
||||
} as any;
|
||||
if (sinceId) {
|
||||
sort._id = 1;
|
||||
query._id = {
|
||||
$gt: sinceId
|
||||
};
|
||||
} else if (untilId) {
|
||||
query._id = {
|
||||
$lt: untilId
|
||||
};
|
||||
}
|
||||
|
||||
// Issue query
|
||||
const renotes = await Note
|
||||
.find(query, {
|
||||
limit: limit,
|
||||
sort: sort
|
||||
});
|
||||
|
||||
// Serialize
|
||||
res(await packMany(renotes, user));
|
||||
});
|
@@ -1,11 +1,10 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note from '../../../../models/note';
|
||||
import User, { ILocalUser } from '../../../../models/user';
|
||||
import { ILocalUser } from '../../../../models/user';
|
||||
import Mute from '../../../../models/mute';
|
||||
import { getFriendIds } from '../../common/get-friends';
|
||||
import { packMany } from '../../../../models/note';
|
||||
import getParams from '../../get-params';
|
||||
import { erase } from '../../../../prelude/array';
|
||||
|
||||
export const meta = {
|
||||
desc: {
|
||||
@@ -13,99 +12,94 @@ export const meta = {
|
||||
},
|
||||
|
||||
params: {
|
||||
tag: $.str.optional.note({
|
||||
tag: {
|
||||
validator: $.str.optional,
|
||||
desc: {
|
||||
'ja-JP': 'タグ'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
query: $.arr($.arr($.str)).optional.note({
|
||||
query: {
|
||||
validator: $.arr($.arr($.str)).optional,
|
||||
desc: {
|
||||
'ja-JP': 'クエリ'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
includeUserIds: $.arr($.type(ID)).optional.note({
|
||||
default: []
|
||||
}),
|
||||
following: {
|
||||
validator: $.bool.optional.nullable,
|
||||
default: null as any
|
||||
},
|
||||
|
||||
excludeUserIds: $.arr($.type(ID)).optional.note({
|
||||
default: []
|
||||
}),
|
||||
|
||||
includeUserUsernames: $.arr($.str).optional.note({
|
||||
default: []
|
||||
}),
|
||||
|
||||
excludeUserUsernames: $.arr($.str).optional.note({
|
||||
default: []
|
||||
}),
|
||||
|
||||
following: $.bool.optional.nullable.note({
|
||||
default: null
|
||||
}),
|
||||
|
||||
mute: $.str.optional.note({
|
||||
mute: {
|
||||
validator: $.str.optional,
|
||||
default: 'mute_all'
|
||||
}),
|
||||
|
||||
reply: $.bool.optional.nullable.note({
|
||||
default: null,
|
||||
},
|
||||
|
||||
reply: {
|
||||
validator: $.bool.optional.nullable,
|
||||
default: null as any,
|
||||
desc: {
|
||||
'ja-JP': '返信に限定するか否か'
|
||||
}
|
||||
}),
|
||||
|
||||
renote: $.bool.optional.nullable.note({
|
||||
default: null,
|
||||
},
|
||||
|
||||
renote: {
|
||||
validator: $.bool.optional.nullable,
|
||||
default: null as any,
|
||||
desc: {
|
||||
'ja-JP': 'Renoteに限定するか否か'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
withFiles: $.bool.optional.note({
|
||||
withFiles: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します'
|
||||
}
|
||||
}),
|
||||
|
||||
media: $.bool.optional.nullable.note({
|
||||
default: null,
|
||||
},
|
||||
|
||||
media: {
|
||||
validator: $.bool.optional.nullable,
|
||||
default: null as any,
|
||||
desc: {
|
||||
'ja-JP': 'ファイルが添付された投稿に限定するか否か (このパラメータは廃止予定です。代わりに withFiles を使ってください。)'
|
||||
}
|
||||
}),
|
||||
|
||||
poll: $.bool.optional.nullable.note({
|
||||
default: null,
|
||||
},
|
||||
|
||||
poll: {
|
||||
validator: $.bool.optional.nullable,
|
||||
default: null as any,
|
||||
desc: {
|
||||
'ja-JP': 'アンケートが添付された投稿に限定するか否か'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
untilId: $.type(ID).optional.note({
|
||||
untilId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '指定すると、この投稿を基点としてより古い投稿を取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
sinceDate: $.num.optional.note({
|
||||
}),
|
||||
sinceDate: {
|
||||
validator: $.num.optional,
|
||||
},
|
||||
|
||||
untilDate: $.num.optional.note({
|
||||
}),
|
||||
untilDate: {
|
||||
validator: $.num.optional,
|
||||
},
|
||||
|
||||
offset: $.num.optional.min(0).note({
|
||||
offset: {
|
||||
validator: $.num.optional.min(0),
|
||||
default: 0
|
||||
}),
|
||||
},
|
||||
|
||||
limit: $.num.optional.range(1, 30).note({
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 30),
|
||||
default: 10
|
||||
}),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
@@ -113,28 +107,6 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
|
||||
const [ps, psErr] = getParams(meta, params);
|
||||
if (psErr) return rej(psErr);
|
||||
|
||||
if (ps.includeUserUsernames != null) {
|
||||
const ids = erase(null, await Promise.all(ps.includeUserUsernames.map(async (username) => {
|
||||
const _user = await User.findOne({
|
||||
usernameLower: username.toLowerCase()
|
||||
});
|
||||
return _user ? _user._id : null;
|
||||
})));
|
||||
|
||||
ids.forEach(id => ps.includeUserIds.push(id));
|
||||
}
|
||||
|
||||
if (ps.excludeUserUsernames != null) {
|
||||
const ids = erase(null, await Promise.all(ps.excludeUserUsernames.map(async (username) => {
|
||||
const _user = await User.findOne({
|
||||
usernameLower: username.toLowerCase()
|
||||
});
|
||||
return _user ? _user._id : null;
|
||||
})));
|
||||
|
||||
ids.forEach(id => ps.excludeUserIds.push(id));
|
||||
}
|
||||
|
||||
const q: any = {
|
||||
$and: [ps.tag ? {
|
||||
tagsLower: ps.tag.toLowerCase()
|
||||
@@ -150,20 +122,6 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
|
||||
|
||||
const push = (x: any) => q.$and.push(x);
|
||||
|
||||
if (ps.includeUserIds && ps.includeUserIds.length != 0) {
|
||||
push({
|
||||
userId: {
|
||||
$in: ps.includeUserIds
|
||||
}
|
||||
});
|
||||
} else if (ps.excludeUserIds && ps.excludeUserIds.length != 0) {
|
||||
push({
|
||||
userId: {
|
||||
$nin: ps.excludeUserIds
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (ps.following != null && me != null) {
|
||||
const ids = await getFriendIds(me._id, false);
|
||||
push({
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note, { pack } from '../../../../models/note';
|
||||
import { ILocalUser } from '../../../../models/user';
|
||||
import getParams from '../../get-params';
|
||||
@@ -14,12 +14,14 @@ export const meta = {
|
||||
requireCredential: false,
|
||||
|
||||
params: {
|
||||
noteId: $.type(ID).note({
|
||||
noteId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '対象の投稿のID',
|
||||
'en-US': 'Target note ID.'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note from '../../../../models/note';
|
||||
import Mute from '../../../../models/mute';
|
||||
import { getFriends } from '../../common/get-friends';
|
||||
@@ -16,69 +16,81 @@ export const meta = {
|
||||
requireCredential: true,
|
||||
|
||||
params: {
|
||||
limit: $.num.optional.range(1, 100).note({
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 100),
|
||||
default: 10,
|
||||
desc: {
|
||||
'ja-JP': '最大数'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
sinceId: $.type(ID).optional.note({
|
||||
sinceId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '指定すると、この投稿を基点としてより新しい投稿を取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
untilId: $.type(ID).optional.note({
|
||||
untilId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '指定すると、この投稿を基点としてより古い投稿を取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
sinceDate: $.num.optional.note({
|
||||
sinceDate: {
|
||||
validator: $.num.optional,
|
||||
desc: {
|
||||
'ja-JP': '指定した時間を基点としてより新しい投稿を取得します。数値は、1970年1月1日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
untilDate: $.num.optional.note({
|
||||
untilDate: {
|
||||
validator: $.num.optional,
|
||||
desc: {
|
||||
'ja-JP': '指定した時間を基点としてより古い投稿を取得します。数値は、1970年1月1日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
includeMyRenotes: $.bool.optional.note({
|
||||
includeMyRenotes: {
|
||||
validator: $.bool.optional,
|
||||
default: true,
|
||||
desc: {
|
||||
'ja-JP': '自分の行ったRenoteを含めるかどうか'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
includeRenotedMyNotes: $.bool.optional.note({
|
||||
includeRenotedMyNotes: {
|
||||
validator: $.bool.optional,
|
||||
default: true,
|
||||
desc: {
|
||||
'ja-JP': 'Renoteされた自分の投稿を含めるかどうか'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
includeLocalRenotes: $.bool.optional.note({
|
||||
includeLocalRenotes: {
|
||||
validator: $.bool.optional,
|
||||
default: true,
|
||||
desc: {
|
||||
'ja-JP': 'Renoteされたローカルの投稿を含めるかどうか'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
withFiles: $.bool.optional.note({
|
||||
withFiles: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
mediaOnly: $.bool.optional.note({
|
||||
mediaOnly: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します (このパラメータは廃止予定です。代わりに withFiles を使ってください。)'
|
||||
}
|
||||
}),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
|
||||
import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id';
|
||||
import Note from '../../../../models/note';
|
||||
import Mute from '../../../../models/mute';
|
||||
import { packMany } from '../../../../models/note';
|
||||
@@ -15,75 +15,89 @@ export const meta = {
|
||||
requireCredential: true,
|
||||
|
||||
params: {
|
||||
listId: $.type(ID).note({
|
||||
listId: {
|
||||
validator: $.type(ID),
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': 'リストのID'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
limit: $.num.optional.range(1, 100).note({
|
||||
limit: {
|
||||
validator: $.num.optional.range(1, 100),
|
||||
default: 10,
|
||||
desc: {
|
||||
'ja-JP': '最大数'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
sinceId: $.type(ID).optional.note({
|
||||
sinceId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '指定すると、この投稿を基点としてより新しい投稿を取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
untilId: $.type(ID).optional.note({
|
||||
untilId: {
|
||||
validator: $.type(ID).optional,
|
||||
transform: transform,
|
||||
desc: {
|
||||
'ja-JP': '指定すると、この投稿を基点としてより古い投稿を取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
sinceDate: $.num.optional.note({
|
||||
sinceDate: {
|
||||
validator: $.num.optional,
|
||||
desc: {
|
||||
'ja-JP': '指定した時間を基点としてより新しい投稿を取得します。数値は、1970年1月1日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
untilDate: $.num.optional.note({
|
||||
untilDate: {
|
||||
validator: $.num.optional,
|
||||
desc: {
|
||||
'ja-JP': '指定した時間を基点としてより古い投稿を取得します。数値は、1970年1月1日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
includeMyRenotes: $.bool.optional.note({
|
||||
includeMyRenotes: {
|
||||
validator: $.bool.optional,
|
||||
default: true,
|
||||
desc: {
|
||||
'ja-JP': '自分の行ったRenoteを含めるかどうか'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
includeRenotedMyNotes: $.bool.optional.note({
|
||||
includeRenotedMyNotes: {
|
||||
validator: $.bool.optional,
|
||||
default: true,
|
||||
desc: {
|
||||
'ja-JP': 'Renoteされた自分の投稿を含めるかどうか'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
includeLocalRenotes: $.bool.optional.note({
|
||||
includeLocalRenotes: {
|
||||
validator: $.bool.optional,
|
||||
default: true,
|
||||
desc: {
|
||||
'ja-JP': 'Renoteされたローカルの投稿を含めるかどうか'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
withFiles: $.bool.optional.note({
|
||||
withFiles: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します'
|
||||
}
|
||||
}),
|
||||
},
|
||||
|
||||
mediaOnly: $.bool.optional.note({
|
||||
mediaOnly: {
|
||||
validator: $.bool.optional,
|
||||
desc: {
|
||||
'ja-JP': 'true にすると、ファイルが添付された投稿だけ取得します (このパラメータは廃止予定です。代わりに withFiles を使ってください。)'
|
||||
}
|
||||
}),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user