From 16726789da8c20d35f127afff9d37f1c25575765 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 17 Jul 2018 04:36:44 +0900 Subject: [PATCH] Update api definitions --- src/server/api/endpoints/app/create.ts | 4 ++++ src/server/api/endpoints/auth/accept.ts | 5 +++++ src/server/api/endpoints/drive.ts | 14 ++++++++++--- src/server/api/endpoints/drive/files.ts | 14 ++++++++++--- .../api/endpoints/drive/files/create.ts | 3 ++- .../api/endpoints/drive/files/delete.ts | 14 ++++++++++--- src/server/api/endpoints/drive/files/find.ts | 9 ++++++--- src/server/api/endpoints/drive/files/show.ts | 14 ++++++++++--- .../api/endpoints/drive/files/update.ts | 14 ++++++++++--- .../endpoints/drive/files/upload_from_url.ts | 19 +++++++++++++++--- src/server/api/endpoints/drive/folders.ts | 14 ++++++++++--- .../api/endpoints/drive/folders/create.ts | 14 ++++++++++--- .../api/endpoints/drive/folders/find.ts | 9 ++++++--- .../api/endpoints/drive/folders/show.ts | 13 +++++++++--- .../api/endpoints/drive/folders/update.ts | 14 ++++++++++--- src/server/api/endpoints/drive/stream.ts | 9 ++++++--- src/server/api/endpoints/following/create.ts | 20 ++++++++++++++++--- src/server/api/endpoints/following/delete.ts | 20 ++++++++++++++++--- .../endpoints/following/requests/accept.ts | 14 ++++++++++--- .../endpoints/following/requests/cancel.ts | 14 ++++++++++--- .../api/endpoints/following/requests/list.ts | 14 ++++++++++--- .../endpoints/following/requests/reject.ts | 14 ++++++++++--- src/server/api/endpoints/following/stalk.ts | 14 ++++++++++--- src/server/api/endpoints/following/unstalk.ts | 14 ++++++++++--- .../api/endpoints/games/reversi/games.ts | 4 ++++ .../endpoints/games/reversi/invitations.ts | 4 ++++ .../api/endpoints/games/reversi/match.ts | 4 ++++ .../endpoints/games/reversi/match/cancel.ts | 4 ++++ src/server/api/endpoints/i/2fa/done.ts | 5 +++++ src/server/api/endpoints/i/2fa/register.ts | 5 +++++ src/server/api/endpoints/i/2fa/unregister.ts | 5 +++++ src/server/api/endpoints/i/authorized_apps.ts | 8 +++++--- src/server/api/endpoints/i/change_password.ts | 8 +++++--- src/server/api/endpoints/i/favorites.ts | 14 ++++++++++--- .../api/endpoints/i/regenerate_token.ts | 8 +++++--- src/server/api/endpoints/i/signin_history.ts | 8 +++++--- src/server/api/endpoints/i/update.ts | 14 ++++++++++--- .../api/endpoints/i/update_client_setting.ts | 8 +++++--- src/server/api/endpoints/i/update_home.ts | 5 +++++ .../api/endpoints/i/update_mobile_home.ts | 5 +++++ src/server/api/endpoints/i/update_widget.ts | 5 +++++ src/server/api/endpoints/messaging/history.ts | 14 ++++++++++--- .../api/endpoints/messaging/messages.ts | 14 ++++++++++--- .../endpoints/messaging/messages/create.ts | 14 ++++++++++--- src/server/api/endpoints/mute/create.ts | 14 ++++++++++--- src/server/api/endpoints/mute/delete.ts | 14 ++++++++++--- src/server/api/endpoints/mute/list.ts | 14 ++++++++++--- src/server/api/endpoints/my/apps.ts | 12 ++++++++--- src/server/api/endpoints/notes/delete.ts | 14 ++++++++++--- .../api/endpoints/notes/favorites/create.ts | 14 ++++++++++--- .../api/endpoints/notes/favorites/delete.ts | 14 ++++++++++--- src/server/api/endpoints/notes/mentions.ts | 12 ++++++++--- .../endpoints/notes/polls/recommendation.ts | 12 ++++++++--- src/server/api/endpoints/notes/polls/vote.ts | 14 ++++++++++--- src/server/api/endpoints/notes/reactions.ts | 15 +++++++++----- .../api/endpoints/notes/reactions/create.ts | 12 +++++------ .../api/endpoints/notes/reactions/delete.ts | 14 ++++++++++--- src/server/api/endpoints/notes/trend.ts | 12 ++++++++--- .../api/endpoints/notes/user-list-timeline.ts | 12 ++++++++--- .../notifications/mark_as_read_all.ts | 11 ++++++++++ src/server/api/endpoints/sw/register.ts | 4 ++++ .../api/endpoints/users/lists/create.ts | 14 ++++++++++--- src/server/api/endpoints/users/lists/list.ts | 13 +++++++++--- src/server/api/endpoints/users/lists/push.ts | 11 ++++++++++ src/server/api/endpoints/users/lists/show.ts | 14 ++++++++++--- .../api/endpoints/users/recommendation.ts | 13 +++++++++--- 66 files changed, 586 insertions(+), 156 deletions(-) diff --git a/src/server/api/endpoints/app/create.ts b/src/server/api/endpoints/app/create.ts index 3b3eafa69..82a2fcb55 100644 --- a/src/server/api/endpoints/app/create.ts +++ b/src/server/api/endpoints/app/create.ts @@ -3,6 +3,10 @@ import $ from 'cafy'; import App, { isValidNameId, pack } from '../../../../models/app'; import { ILocalUser } from '../../../../models/user'; +export const meta = { + requireCredential: true +}; + /** * @swagger * /app/create: diff --git a/src/server/api/endpoints/auth/accept.ts b/src/server/api/endpoints/auth/accept.ts index d14c85341..2638ebc14 100644 --- a/src/server/api/endpoints/auth/accept.ts +++ b/src/server/api/endpoints/auth/accept.ts @@ -6,6 +6,11 @@ import AuthSess from '../../../../models/auth-session'; import AccessToken from '../../../../models/access-token'; import { ILocalUser } from '../../../../models/user'; +export const meta = { + requireCredential: true, + secure: true +}; + /** * @swagger * /auth/accept: diff --git a/src/server/api/endpoints/drive.ts b/src/server/api/endpoints/drive.ts index 66ac30c4c..a98a3a5b8 100644 --- a/src/server/api/endpoints/drive.ts +++ b/src/server/api/endpoints/drive.ts @@ -1,9 +1,17 @@ import DriveFile from '../../../models/drive-file'; import { ILocalUser } from '../../../models/user'; -/** - * Get drive information - */ +export const meta = { + desc: { + ja: 'ドライブの情報を取得します。', + en: 'Get drive information.' + }, + + requireCredential: true, + + kind: 'drive-read' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Calculate drive usage const usage = await DriveFile diff --git a/src/server/api/endpoints/drive/files.ts b/src/server/api/endpoints/drive/files.ts index 000e4dcdd..063b4adde 100644 --- a/src/server/api/endpoints/drive/files.ts +++ b/src/server/api/endpoints/drive/files.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import DriveFile, { pack } from '../../../../models/drive-file'; import { ILocalUser } from '../../../../models/user'; -/** - * Get drive files - */ +export const meta = { + desc: { + ja: 'ドライブのファイル一覧を取得します。', + en: 'Get files of drive.' + }, + + requireCredential: true, + + kind: 'drive-read' +}; + export default async (params: any, user: ILocalUser) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/drive/files/create.ts b/src/server/api/endpoints/drive/files/create.ts index c5eb29e1a..ca12be910 100644 --- a/src/server/api/endpoints/drive/files/create.ts +++ b/src/server/api/endpoints/drive/files/create.ts @@ -8,7 +8,8 @@ import getParams from '../../../get-params'; export const meta = { desc: { - ja: 'ドライブにファイルをアップロードします。' + ja: 'ドライブにファイルをアップロードします。', + en: 'Upload a file to drive.' }, requireCredential: true, diff --git a/src/server/api/endpoints/drive/files/delete.ts b/src/server/api/endpoints/drive/files/delete.ts index 8a63be0e2..02cd96dd8 100644 --- a/src/server/api/endpoints/drive/files/delete.ts +++ b/src/server/api/endpoints/drive/files/delete.ts @@ -4,9 +4,17 @@ import del from '../../../../../services/drive/delete-file'; import { publishDriveStream } from '../../../../../stream'; import { ILocalUser } from '../../../../../models/user'; -/** - * Delete a file - */ +export const meta = { + desc: { + ja: 'ドライブのファイルを削除します。', + en: 'Delete a file of drive.' + }, + + requireCredential: true, + + kind: 'drive-write' +}; + export default async (params: any, user: ILocalUser) => { // Get 'fileId' parameter const [fileId, fileIdErr] = $.type(ID).get(params.fileId); diff --git a/src/server/api/endpoints/drive/files/find.ts b/src/server/api/endpoints/drive/files/find.ts index 8b166e2db..aa44ee688 100644 --- a/src/server/api/endpoints/drive/files/find.ts +++ b/src/server/api/endpoints/drive/files/find.ts @@ -2,9 +2,12 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id'; import DriveFile, { pack } from '../../../../../models/drive-file'; import { ILocalUser } from '../../../../../models/user'; -/** - * Find a file(s) - */ +export const meta = { + requireCredential: true, + + kind: 'drive-read' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'name' parameter const [name, nameErr] = $.str.get(params.name); diff --git a/src/server/api/endpoints/drive/files/show.ts b/src/server/api/endpoints/drive/files/show.ts index 02faa6d5a..6a66c7a27 100644 --- a/src/server/api/endpoints/drive/files/show.ts +++ b/src/server/api/endpoints/drive/files/show.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id'; import DriveFile, { pack } from '../../../../../models/drive-file'; import { ILocalUser } from '../../../../../models/user'; -/** - * Show a file - */ +export const meta = { + desc: { + ja: '指定したドライブのファイルの情報を取得します。', + en: 'Get specified file of drive.' + }, + + requireCredential: true, + + kind: 'drive-read' +}; + export default async (params: any, user: ILocalUser) => { // Get 'fileId' parameter const [fileId, fileIdErr] = $.type(ID).get(params.fileId); diff --git a/src/server/api/endpoints/drive/files/update.ts b/src/server/api/endpoints/drive/files/update.ts index 95dd6c2ac..396bc9769 100644 --- a/src/server/api/endpoints/drive/files/update.ts +++ b/src/server/api/endpoints/drive/files/update.ts @@ -4,9 +4,17 @@ import DriveFile, { validateFileName, pack } from '../../../../../models/drive-f import { publishDriveStream } from '../../../../../stream'; import { ILocalUser } from '../../../../../models/user'; -/** - * Update a file - */ +export const meta = { + desc: { + ja: '指定したドライブのファイルの情報を更新します。', + en: 'Update specified file of drive.' + }, + + requireCredential: true, + + kind: 'drive-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'fileId' parameter const [fileId, fileIdErr] = $.type(ID).get(params.fileId); diff --git a/src/server/api/endpoints/drive/files/upload_from_url.ts b/src/server/api/endpoints/drive/files/upload_from_url.ts index 4af365c39..d634cf46d 100644 --- a/src/server/api/endpoints/drive/files/upload_from_url.ts +++ b/src/server/api/endpoints/drive/files/upload_from_url.ts @@ -1,11 +1,24 @@ -/** - * Module dependencies - */ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id'; +const ms = require('ms'); import { pack } from '../../../../../models/drive-file'; import uploadFromUrl from '../../../../../services/drive/upload-from-url'; import { ILocalUser } from '../../../../../models/user'; +export const meta = { + desc: { + ja: 'ドライブに指定されたURLに存在するファイルをアップロードします。' + }, + + limit: { + duration: ms('1hour'), + max: 10 + }, + + requireCredential: true, + + kind: 'drive-write' +}; + /** * Create a file from a URL */ diff --git a/src/server/api/endpoints/drive/folders.ts b/src/server/api/endpoints/drive/folders.ts index f1817ec42..de398eb72 100644 --- a/src/server/api/endpoints/drive/folders.ts +++ b/src/server/api/endpoints/drive/folders.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import DriveFolder, { pack } from '../../../../models/drive-folder'; import { ILocalUser } from '../../../../models/user'; -/** - * Get drive folders - */ +export const meta = { + desc: { + ja: 'ドライブのフォルダ一覧を取得します。', + en: 'Get folders of drive.' + }, + + requireCredential: true, + + kind: 'drive-read' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/drive/folders/create.ts b/src/server/api/endpoints/drive/folders/create.ts index 6205691e1..03f950477 100644 --- a/src/server/api/endpoints/drive/folders/create.ts +++ b/src/server/api/endpoints/drive/folders/create.ts @@ -3,9 +3,17 @@ import DriveFolder, { isValidFolderName, pack } from '../../../../../models/driv import { publishDriveStream } from '../../../../../stream'; import { ILocalUser } from '../../../../../models/user'; -/** - * Create drive folder - */ +export const meta = { + desc: { + ja: 'ドライブのフォルダを作成します。', + en: 'Create a folder of drive.' + }, + + requireCredential: true, + + kind: 'drive-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'name' parameter const [name = '無題のフォルダー', nameErr] = $.str.optional.pipe(isValidFolderName).get(params.name); diff --git a/src/server/api/endpoints/drive/folders/find.ts b/src/server/api/endpoints/drive/folders/find.ts index 64065d937..ec3c1d2e3 100644 --- a/src/server/api/endpoints/drive/folders/find.ts +++ b/src/server/api/endpoints/drive/folders/find.ts @@ -2,9 +2,12 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id'; import DriveFolder, { pack } from '../../../../../models/drive-folder'; import { ILocalUser } from '../../../../../models/user'; -/** - * Find a folder(s) - */ +export const meta = { + requireCredential: true, + + kind: 'drive-read' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'name' parameter const [name, nameErr] = $.str.get(params.name); diff --git a/src/server/api/endpoints/drive/folders/show.ts b/src/server/api/endpoints/drive/folders/show.ts index 5f5660621..6a6c879a0 100644 --- a/src/server/api/endpoints/drive/folders/show.ts +++ b/src/server/api/endpoints/drive/folders/show.ts @@ -2,9 +2,16 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id'; import DriveFolder, { pack } from '../../../../../models/drive-folder'; import { ILocalUser } from '../../../../../models/user'; -/** - * Show a folder - */ +export const meta = { + desc: { + ja: '指定したドライブのフォルダの情報を取得します。' + }, + + requireCredential: true, + + kind: 'drive-read' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'folderId' parameter const [folderId, folderIdErr] = $.type(ID).get(params.folderId); diff --git a/src/server/api/endpoints/drive/folders/update.ts b/src/server/api/endpoints/drive/folders/update.ts index b83365597..1b449428a 100644 --- a/src/server/api/endpoints/drive/folders/update.ts +++ b/src/server/api/endpoints/drive/folders/update.ts @@ -3,9 +3,17 @@ import DriveFolder, { isValidFolderName, pack } from '../../../../../models/driv import { publishDriveStream } from '../../../../../stream'; import { ILocalUser } from '../../../../../models/user'; -/** - * Update a folder - */ +export const meta = { + desc: { + ja: '指定したドライブのフォルダの情報を更新します。', + en: 'Update specified folder of drive.' + }, + + requireCredential: true, + + kind: 'drive-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'folderId' parameter const [folderId, folderIdErr] = $.type(ID).get(params.folderId); diff --git a/src/server/api/endpoints/drive/stream.ts b/src/server/api/endpoints/drive/stream.ts index 39c878a1f..53f94a263 100644 --- a/src/server/api/endpoints/drive/stream.ts +++ b/src/server/api/endpoints/drive/stream.ts @@ -2,9 +2,12 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import DriveFile, { pack } from '../../../../models/drive-file'; import { ILocalUser } from '../../../../models/user'; -/** - * Get drive stream - */ +export const meta = { + requireCredential: true, + + kind: 'drive-read' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/following/create.ts b/src/server/api/endpoints/following/create.ts index a902af023..ebe319e0c 100644 --- a/src/server/api/endpoints/following/create.ts +++ b/src/server/api/endpoints/following/create.ts @@ -1,11 +1,25 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; +const ms = require('ms'); import User, { pack, ILocalUser } from '../../../../models/user'; import Following from '../../../../models/following'; import create from '../../../../services/following/create'; -/** - * Follow a user - */ +export const meta = { + desc: { + ja: '指定したユーザーをフォローします。', + en: 'Follow a user.' + }, + + limit: { + duration: ms('1hour'), + max: 100 + }, + + requireCredential: true, + + kind: 'following-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const follower = user; diff --git a/src/server/api/endpoints/following/delete.ts b/src/server/api/endpoints/following/delete.ts index f1d29e80b..4806fe4e3 100644 --- a/src/server/api/endpoints/following/delete.ts +++ b/src/server/api/endpoints/following/delete.ts @@ -1,11 +1,25 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; +const ms = require('ms'); import User, { pack, ILocalUser } from '../../../../models/user'; import Following from '../../../../models/following'; import deleteFollowing from '../../../../services/following/delete'; -/** - * Unfollow a user - */ +export const meta = { + desc: { + ja: '指定したユーザーのフォローを解除します。', + en: 'Unfollow a user.' + }, + + limit: { + duration: ms('1hour'), + max: 100 + }, + + requireCredential: true, + + kind: 'following-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const follower = user; diff --git a/src/server/api/endpoints/following/requests/accept.ts b/src/server/api/endpoints/following/requests/accept.ts index 49c29160b..b3bf2dd66 100644 --- a/src/server/api/endpoints/following/requests/accept.ts +++ b/src/server/api/endpoints/following/requests/accept.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id'; import acceptFollowRequest from '../../../../../services/following/requests/accept'; import User, { ILocalUser } from '../../../../../models/user'; -/** - * Accept a follow request - */ +export const meta = { + desc: { + ja: '自分に届いた、指定したフォローリクエストを承認します。', + en: 'Accept a follow request.' + }, + + requireCredential: true, + + kind: 'following-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'userId' parameter const [followerId, followerIdErr] = $.type(ID).get(params.userId); diff --git a/src/server/api/endpoints/following/requests/cancel.ts b/src/server/api/endpoints/following/requests/cancel.ts index 6c3539d75..9bfc40ce6 100644 --- a/src/server/api/endpoints/following/requests/cancel.ts +++ b/src/server/api/endpoints/following/requests/cancel.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id'; import cancelFollowRequest from '../../../../../services/following/requests/cancel'; import User, { pack, ILocalUser } from '../../../../../models/user'; -/** - * Cancel a follow request - */ +export const meta = { + desc: { + ja: '自分が作成した、指定したフォローリクエストをキャンセルします。', + en: 'Cancel a follow request.' + }, + + requireCredential: true, + + kind: 'following-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'userId' parameter const [followeeId, followeeIdErr] = $.type(ID).get(params.userId); diff --git a/src/server/api/endpoints/following/requests/list.ts b/src/server/api/endpoints/following/requests/list.ts index dfe9858f3..b06a158c0 100644 --- a/src/server/api/endpoints/following/requests/list.ts +++ b/src/server/api/endpoints/following/requests/list.ts @@ -2,9 +2,17 @@ import FollowRequest, { pack } from '../../../../../models/follow-request'; import { ILocalUser } from '../../../../../models/user'; -/** - * Get all pending received follow requests - */ +export const meta = { + desc: { + ja: '自分に届いたフォローリクエストの一覧を取得します。', + en: 'Get all pending received follow requests.' + }, + + requireCredential: true, + + kind: 'following-read' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const reqs = await FollowRequest.find({ followeeId: user._id diff --git a/src/server/api/endpoints/following/requests/reject.ts b/src/server/api/endpoints/following/requests/reject.ts index f92ea52d4..a232549bb 100644 --- a/src/server/api/endpoints/following/requests/reject.ts +++ b/src/server/api/endpoints/following/requests/reject.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id'; import rejectFollowRequest from '../../../../../services/following/requests/reject'; import User, { ILocalUser } from '../../../../../models/user'; -/** - * Reject a follow request - */ +export const meta = { + desc: { + ja: '自分に届いた、指定したフォローリクエストを拒否します。', + en: 'Reject a follow request.' + }, + + requireCredential: true, + + kind: 'following-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'userId' parameter const [followerId, followerIdErr] = $.type(ID).get(params.userId); diff --git a/src/server/api/endpoints/following/stalk.ts b/src/server/api/endpoints/following/stalk.ts index eb4afb311..79a3fb976 100644 --- a/src/server/api/endpoints/following/stalk.ts +++ b/src/server/api/endpoints/following/stalk.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import Following from '../../../../models/following'; import { ILocalUser } from '../../../../models/user'; -/** - * Stalk a user - */ +export const meta = { + desc: { + ja: '指定したユーザーをストーキングします。', + en: 'Stalk a user.' + }, + + requireCredential: true, + + kind: 'following-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const follower = user; diff --git a/src/server/api/endpoints/following/unstalk.ts b/src/server/api/endpoints/following/unstalk.ts index b44ef68b9..71a7a97ee 100644 --- a/src/server/api/endpoints/following/unstalk.ts +++ b/src/server/api/endpoints/following/unstalk.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import Following from '../../../../models/following'; import { ILocalUser } from '../../../../models/user'; -/** - * Unstalk a user - */ +export const meta = { + desc: { + ja: '指定したユーザーのストーキングをやめます。', + en: 'Unstalk a user.' + }, + + requireCredential: true, + + kind: 'following-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const follower = user; diff --git a/src/server/api/endpoints/games/reversi/games.ts b/src/server/api/endpoints/games/reversi/games.ts index 50a8faa88..b72af06d2 100644 --- a/src/server/api/endpoints/games/reversi/games.ts +++ b/src/server/api/endpoints/games/reversi/games.ts @@ -2,6 +2,10 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id'; import ReversiGame, { pack } from '../../../../../models/games/reversi/game'; import { ILocalUser } from '../../../../../models/user'; +export const meta = { + requireCredential: true +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'my' parameter const [my = false, myErr] = $.bool.optional.get(params.my); diff --git a/src/server/api/endpoints/games/reversi/invitations.ts b/src/server/api/endpoints/games/reversi/invitations.ts index c6d0ecfa7..396228275 100644 --- a/src/server/api/endpoints/games/reversi/invitations.ts +++ b/src/server/api/endpoints/games/reversi/invitations.ts @@ -1,6 +1,10 @@ import Matching, { pack as packMatching } from '../../../../../models/games/reversi/matching'; import { ILocalUser } from '../../../../../models/user'; +export const meta = { + requireCredential: true +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Find session const invitations = await Matching.find({ diff --git a/src/server/api/endpoints/games/reversi/match.ts b/src/server/api/endpoints/games/reversi/match.ts index 436453151..24746170f 100644 --- a/src/server/api/endpoints/games/reversi/match.ts +++ b/src/server/api/endpoints/games/reversi/match.ts @@ -5,6 +5,10 @@ import User, { ILocalUser } from '../../../../../models/user'; import publishUserStream, { publishReversiStream } from '../../../../../stream'; import { eighteight } from '../../../../../games/reversi/maps'; +export const meta = { + requireCredential: true +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'userId' parameter const [childId, childIdErr] = $.type(ID).get(params.userId); diff --git a/src/server/api/endpoints/games/reversi/match/cancel.ts b/src/server/api/endpoints/games/reversi/match/cancel.ts index 84cd1ff11..d5c186409 100644 --- a/src/server/api/endpoints/games/reversi/match/cancel.ts +++ b/src/server/api/endpoints/games/reversi/match/cancel.ts @@ -1,6 +1,10 @@ import Matching from '../../../../../../models/games/reversi/matching'; import { ILocalUser } from '../../../../../../models/user'; +export const meta = { + requireCredential: true +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { await Matching.remove({ parentId: user._id diff --git a/src/server/api/endpoints/i/2fa/done.ts b/src/server/api/endpoints/i/2fa/done.ts index fef045948..6d38ca1de 100644 --- a/src/server/api/endpoints/i/2fa/done.ts +++ b/src/server/api/endpoints/i/2fa/done.ts @@ -2,6 +2,11 @@ import $ from 'cafy'; import * as speakeasy from 'speakeasy'; import User, { ILocalUser } from '../../../../../models/user'; +export const meta = { + requireCredential: true, + secure: true +}; + export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'token' parameter const [token, tokenErr] = $.str.get(params.token); diff --git a/src/server/api/endpoints/i/2fa/register.ts b/src/server/api/endpoints/i/2fa/register.ts index ac703f5b0..0466a4f36 100644 --- a/src/server/api/endpoints/i/2fa/register.ts +++ b/src/server/api/endpoints/i/2fa/register.ts @@ -5,6 +5,11 @@ import * as QRCode from 'qrcode'; import User, { ILocalUser } from '../../../../../models/user'; import config from '../../../../../config'; +export const meta = { + requireCredential: true, + secure: true +}; + export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'password' parameter const [password, passwordErr] = $.str.get(params.password); diff --git a/src/server/api/endpoints/i/2fa/unregister.ts b/src/server/api/endpoints/i/2fa/unregister.ts index 7d99ee397..accf3ea0f 100644 --- a/src/server/api/endpoints/i/2fa/unregister.ts +++ b/src/server/api/endpoints/i/2fa/unregister.ts @@ -2,6 +2,11 @@ import $ from 'cafy'; import * as bcrypt from 'bcryptjs'; import User, { ILocalUser } from '../../../../../models/user'; +export const meta = { + requireCredential: true, + secure: true +}; + export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'password' parameter const [password, passwordErr] = $.str.get(params.password); diff --git a/src/server/api/endpoints/i/authorized_apps.ts b/src/server/api/endpoints/i/authorized_apps.ts index 24c4b58f7..313bb474f 100644 --- a/src/server/api/endpoints/i/authorized_apps.ts +++ b/src/server/api/endpoints/i/authorized_apps.ts @@ -3,9 +3,11 @@ import AccessToken from '../../../../models/access-token'; import { pack } from '../../../../models/app'; import { ILocalUser } from '../../../../models/user'; -/** - * Get authorized apps of my account - */ +export const meta = { + requireCredential: true, + secure: true +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/i/change_password.ts b/src/server/api/endpoints/i/change_password.ts index 698db5a6e..dc0f060c0 100644 --- a/src/server/api/endpoints/i/change_password.ts +++ b/src/server/api/endpoints/i/change_password.ts @@ -2,9 +2,11 @@ import $ from 'cafy'; import * as bcrypt from 'bcryptjs'; import User, { ILocalUser } from '../../../../models/user'; -/** - * Change password - */ +export const meta = { + requireCredential: true, + secure: true +}; + export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'currentPasword' parameter const [currentPassword, currentPasswordErr] = $.str.get(params.currentPasword); diff --git a/src/server/api/endpoints/i/favorites.ts b/src/server/api/endpoints/i/favorites.ts index d37632822..47c8a87fd 100644 --- a/src/server/api/endpoints/i/favorites.ts +++ b/src/server/api/endpoints/i/favorites.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import Favorite, { pack } from '../../../../models/favorite'; import { ILocalUser } from '../../../../models/user'; -/** - * Get favorited notes - */ +export const meta = { + desc: { + ja: 'お気に入りに登録した投稿一覧を取得します。', + en: 'Get favorited notes' + }, + + requireCredential: true, + + kind: 'favorites-read' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/i/regenerate_token.ts b/src/server/api/endpoints/i/regenerate_token.ts index 5c30c4f49..374861daa 100644 --- a/src/server/api/endpoints/i/regenerate_token.ts +++ b/src/server/api/endpoints/i/regenerate_token.ts @@ -4,9 +4,11 @@ import User, { ILocalUser } from '../../../../models/user'; import event from '../../../../stream'; import generateUserToken from '../../common/generate-native-user-token'; -/** - * Regenerate native token - */ +export const meta = { + requireCredential: true, + secure: true +}; + export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'password' parameter const [password, passwordErr] = $.str.get(params.password); diff --git a/src/server/api/endpoints/i/signin_history.ts b/src/server/api/endpoints/i/signin_history.ts index a99a9e81e..5a3c122f3 100644 --- a/src/server/api/endpoints/i/signin_history.ts +++ b/src/server/api/endpoints/i/signin_history.ts @@ -2,9 +2,11 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import Signin, { pack } from '../../../../models/signin'; import { ILocalUser } from '../../../../models/user'; -/** - * Get signin history of my account - */ +export const meta = { + requireCredential: true, + secure: true +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index 6d6cf3e4c..4002bcdc3 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -5,9 +5,17 @@ import DriveFile from '../../../../models/drive-file'; import acceptAllFollowRequests from '../../../../services/following/requests/accept-all'; import { IApp } from '../../../../models/app'; -/** - * Update myself - */ +export const meta = { + desc: { + ja: 'アカウント情報を更新します。', + en: 'Update myself' + }, + + requireCredential: true, + + kind: 'account-write' +}; + export default async (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => { const isSecure = user != null && app == null; diff --git a/src/server/api/endpoints/i/update_client_setting.ts b/src/server/api/endpoints/i/update_client_setting.ts index affaee37e..9342f5dad 100644 --- a/src/server/api/endpoints/i/update_client_setting.ts +++ b/src/server/api/endpoints/i/update_client_setting.ts @@ -2,9 +2,11 @@ import $ from 'cafy'; import User, { ILocalUser } from '../../../../models/user'; import event from '../../../../stream'; -/** - * Update myself - */ +export const meta = { + requireCredential: true, + secure: true +}; + export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'name' parameter const [name, nameErr] = $.str.get(params.name); diff --git a/src/server/api/endpoints/i/update_home.ts b/src/server/api/endpoints/i/update_home.ts index c41ae7b3e..6f3985429 100644 --- a/src/server/api/endpoints/i/update_home.ts +++ b/src/server/api/endpoints/i/update_home.ts @@ -2,6 +2,11 @@ import $ from 'cafy'; import User, { ILocalUser } from '../../../../models/user'; import event from '../../../../stream'; +export const meta = { + requireCredential: true, + secure: true +}; + export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'home' parameter const [home, homeErr] = $.arr($.obj({ diff --git a/src/server/api/endpoints/i/update_mobile_home.ts b/src/server/api/endpoints/i/update_mobile_home.ts index ca61e5260..1babe409e 100644 --- a/src/server/api/endpoints/i/update_mobile_home.ts +++ b/src/server/api/endpoints/i/update_mobile_home.ts @@ -2,6 +2,11 @@ import $ from 'cafy'; import User, { ILocalUser } from '../../../../models/user'; import event from '../../../../stream'; +export const meta = { + requireCredential: true, + secure: true +}; + export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'home' parameter const [home, homeErr] = $.arr($.obj({ diff --git a/src/server/api/endpoints/i/update_widget.ts b/src/server/api/endpoints/i/update_widget.ts index a413ca7e9..5bf9c2305 100644 --- a/src/server/api/endpoints/i/update_widget.ts +++ b/src/server/api/endpoints/i/update_widget.ts @@ -2,6 +2,11 @@ import $ from 'cafy'; import User, { ILocalUser } from '../../../../models/user'; import event from '../../../../stream'; +export const meta = { + requireCredential: true, + secure: true +}; + export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'id' parameter const [id, idErr] = $.str.get(params.id); diff --git a/src/server/api/endpoints/messaging/history.ts b/src/server/api/endpoints/messaging/history.ts index a1bd01586..66798d50c 100644 --- a/src/server/api/endpoints/messaging/history.ts +++ b/src/server/api/endpoints/messaging/history.ts @@ -4,9 +4,17 @@ import Mute from '../../../../models/mute'; import { pack } from '../../../../models/messaging-message'; import { ILocalUser } from '../../../../models/user'; -/** - * Show messaging history - */ +export const meta = { + desc: { + ja: 'Messagingの履歴を取得します。', + en: 'Show messaging history.' + }, + + requireCredential: true, + + kind: 'messaging-read' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/messaging/messages.ts b/src/server/api/endpoints/messaging/messages.ts index 083fcd83f..84c28dc0c 100644 --- a/src/server/api/endpoints/messaging/messages.ts +++ b/src/server/api/endpoints/messaging/messages.ts @@ -4,9 +4,17 @@ import User, { ILocalUser } from '../../../../models/user'; import { pack } from '../../../../models/messaging-message'; import read from '../../common/read-messaging-message'; -/** - * Get messages - */ +export const meta = { + desc: { + ja: '指定したユーザーとのMessagingのメッセージ一覧を取得します。', + en: 'Get messages of messaging.' + }, + + requireCredential: true, + + kind: 'messaging-read' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'userId' parameter const [recipientId, recipientIdErr] = $.type(ID).get(params.userId); diff --git a/src/server/api/endpoints/messaging/messages/create.ts b/src/server/api/endpoints/messaging/messages/create.ts index c3d9824d6..9b897b45e 100644 --- a/src/server/api/endpoints/messaging/messages/create.ts +++ b/src/server/api/endpoints/messaging/messages/create.ts @@ -11,9 +11,17 @@ import { publishMessagingStream, publishMessagingIndexStream } from '../../../.. import pushSw from '../../../../../push-sw'; import config from '../../../../../config'; -/** - * Create a message - */ +export const meta = { + desc: { + ja: '指定したユーザーへMessagingのメッセージを送信します。', + en: 'Create a message of messaging.' + }, + + requireCredential: true, + + kind: 'messaging-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'userId' parameter const [recipientId, recipientIdErr] = $.type(ID).get(params.userId); diff --git a/src/server/api/endpoints/mute/create.ts b/src/server/api/endpoints/mute/create.ts index 3e766bf17..bd70cd62e 100644 --- a/src/server/api/endpoints/mute/create.ts +++ b/src/server/api/endpoints/mute/create.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import User, { ILocalUser } from '../../../../models/user'; import Mute from '../../../../models/mute'; -/** - * Mute a user - */ +export const meta = { + desc: { + ja: 'ユーザーをミュートします。', + en: 'Mute a user' + }, + + requireCredential: true, + + kind: 'account/write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const muter = user; diff --git a/src/server/api/endpoints/mute/delete.ts b/src/server/api/endpoints/mute/delete.ts index 057baed2b..3187c46f8 100644 --- a/src/server/api/endpoints/mute/delete.ts +++ b/src/server/api/endpoints/mute/delete.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import User, { ILocalUser } from '../../../../models/user'; import Mute from '../../../../models/mute'; -/** - * Unmute a user - */ +export const meta = { + desc: { + ja: 'ユーザーのミュートを解除します。', + en: 'Unmute a user' + }, + + requireCredential: true, + + kind: 'account/write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const muter = user; diff --git a/src/server/api/endpoints/mute/list.ts b/src/server/api/endpoints/mute/list.ts index 54ca84c61..e29760533 100644 --- a/src/server/api/endpoints/mute/list.ts +++ b/src/server/api/endpoints/mute/list.ts @@ -3,9 +3,17 @@ import Mute from '../../../../models/mute'; import { pack, ILocalUser } from '../../../../models/user'; import { getFriendIds } from '../../common/get-friends'; -/** - * Get muted users of a user - */ +export const meta = { + desc: { + ja: 'ミュートしているユーザー一覧を取得します。', + en: 'Get muted users.' + }, + + requireCredential: true, + + kind: 'account/read' +}; + export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => { // Get 'iknow' parameter const [iknow = false, iknowErr] = $.bool.optional.get(params.iknow); diff --git a/src/server/api/endpoints/my/apps.ts b/src/server/api/endpoints/my/apps.ts index 8e946c946..35185db41 100644 --- a/src/server/api/endpoints/my/apps.ts +++ b/src/server/api/endpoints/my/apps.ts @@ -2,9 +2,15 @@ import $ from 'cafy'; import App, { pack } from '../../../../models/app'; import { ILocalUser } from '../../../../models/user'; -/** - * Get my apps - */ +export const meta = { + desc: { + ja: '自分のアプリケーション一覧を取得します。', + en: 'Get my apps' + }, + + requireCredential: true +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/notes/delete.ts b/src/server/api/endpoints/notes/delete.ts index bebf7b203..22c6101e1 100644 --- a/src/server/api/endpoints/notes/delete.ts +++ b/src/server/api/endpoints/notes/delete.ts @@ -3,9 +3,17 @@ import Note from '../../../../models/note'; import deleteNote from '../../../../services/note/delete'; import { ILocalUser } from '../../../../models/user'; -/** - * Delete a note - */ +export const meta = { + desc: { + ja: '指定した投稿を削除します。', + en: 'Delete a note.' + }, + + requireCredential: true, + + kind: 'note-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'noteId' parameter const [noteId, noteIdErr] = $.type(ID).get(params.noteId); diff --git a/src/server/api/endpoints/notes/favorites/create.ts b/src/server/api/endpoints/notes/favorites/create.ts index 280283d34..87f6cf1f0 100644 --- a/src/server/api/endpoints/notes/favorites/create.ts +++ b/src/server/api/endpoints/notes/favorites/create.ts @@ -3,9 +3,17 @@ import Favorite from '../../../../../models/favorite'; import Note from '../../../../../models/note'; import { ILocalUser } from '../../../../../models/user'; -/** - * Favorite a note - */ +export const meta = { + desc: { + ja: '指定した投稿をお気に入りに登録します。', + en: 'Favorite a note.' + }, + + requireCredential: true, + + kind: 'favorite-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'noteId' parameter const [noteId, noteIdErr] = $.type(ID).get(params.noteId); diff --git a/src/server/api/endpoints/notes/favorites/delete.ts b/src/server/api/endpoints/notes/favorites/delete.ts index 2cd00f876..3906fe99b 100644 --- a/src/server/api/endpoints/notes/favorites/delete.ts +++ b/src/server/api/endpoints/notes/favorites/delete.ts @@ -3,9 +3,17 @@ import Favorite from '../../../../../models/favorite'; import Note from '../../../../../models/note'; import { ILocalUser } from '../../../../../models/user'; -/** - * Unfavorite a note - */ +export const meta = { + desc: { + ja: '指定した投稿のお気に入りを解除します。', + en: 'Unfavorite a note.' + }, + + requireCredential: true, + + kind: 'favorite-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'noteId' parameter const [noteId, noteIdErr] = $.type(ID).get(params.noteId); diff --git a/src/server/api/endpoints/notes/mentions.ts b/src/server/api/endpoints/notes/mentions.ts index c4e420602..db91230a8 100644 --- a/src/server/api/endpoints/notes/mentions.ts +++ b/src/server/api/endpoints/notes/mentions.ts @@ -4,9 +4,15 @@ import { getFriendIds } from '../../common/get-friends'; import { pack } from '../../../../models/note'; import { ILocalUser } from '../../../../models/user'; -/** - * Get mentions of myself - */ +export const meta = { + desc: { + ja: '自分に言及している投稿の一覧を取得します。', + en: 'Get mentions of myself.' + }, + + requireCredential: true +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'following' parameter const [following = false, followingError] = diff --git a/src/server/api/endpoints/notes/polls/recommendation.ts b/src/server/api/endpoints/notes/polls/recommendation.ts index f448bb66f..a0469d187 100644 --- a/src/server/api/endpoints/notes/polls/recommendation.ts +++ b/src/server/api/endpoints/notes/polls/recommendation.ts @@ -3,9 +3,15 @@ import Vote from '../../../../../models/poll-vote'; import Note, { pack } from '../../../../../models/note'; import { ILocalUser } from '../../../../../models/user'; -/** - * Get recommended polls - */ +export const meta = { + desc: { + ja: 'おすすめのアンケート一覧を取得します。', + en: 'Get recommended polls.' + }, + + requireCredential: true, +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/notes/polls/vote.ts b/src/server/api/endpoints/notes/polls/vote.ts index 026caa0b4..568c187f8 100644 --- a/src/server/api/endpoints/notes/polls/vote.ts +++ b/src/server/api/endpoints/notes/polls/vote.ts @@ -7,9 +7,17 @@ import { publishNoteStream } from '../../../../../stream'; import notify from '../../../../../notify'; import { ILocalUser } from '../../../../../models/user'; -/** - * Vote poll of a note - */ +export const meta = { + desc: { + ja: '指定した投稿のアンケートに投票します。', + en: 'Vote poll of a note.' + }, + + requireCredential: true, + + kind: 'vote-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'noteId' parameter const [noteId, noteIdErr] = $.type(ID).get(params.noteId); diff --git a/src/server/api/endpoints/notes/reactions.ts b/src/server/api/endpoints/notes/reactions.ts index 938ed6f51..8921c5591 100644 --- a/src/server/api/endpoints/notes/reactions.ts +++ b/src/server/api/endpoints/notes/reactions.ts @@ -3,9 +3,15 @@ import Note from '../../../../models/note'; import Reaction, { pack } from '../../../../models/note-reaction'; import { ILocalUser } from '../../../../models/user'; -/** - * Show reactions of a note - */ +export const meta = { + desc: { + ja: '指定した投稿のリアクション一覧を取得します。', + en: 'Show reactions of a note.' + }, + + requireCredential: true +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'noteId' parameter const [noteId, noteIdErr] = $.type(ID).get(params.noteId); @@ -46,6 +52,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) = }); // Serialize - res(await Promise.all(reactions.map(async reaction => - await pack(reaction, user)))); + res(await Promise.all(reactions.map(reaction => pack(reaction, user)))); }); diff --git a/src/server/api/endpoints/notes/reactions/create.ts b/src/server/api/endpoints/notes/reactions/create.ts index f290ab00b..65e24e7c0 100644 --- a/src/server/api/endpoints/notes/reactions/create.ts +++ b/src/server/api/endpoints/notes/reactions/create.ts @@ -6,12 +6,15 @@ import { ILocalUser } from '../../../../../models/user'; import getParams from '../../../get-params'; export const meta = { - name: 'notes/reactions/create', - desc: { - ja: '投稿にリアクションします。' + ja: '指定した投稿にリアクションします。', + en: 'React to a note.' }, + requireCredential: true, + + kind: 'reaction-write', + params: { noteId: $.type(ID).note({ desc: { @@ -27,9 +30,6 @@ export const meta = { } }; -/** - * React to a note - */ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { const [ps, psErr] = getParams(meta, params); if (psErr) return rej(psErr); diff --git a/src/server/api/endpoints/notes/reactions/delete.ts b/src/server/api/endpoints/notes/reactions/delete.ts index 6f662526d..62af0407b 100644 --- a/src/server/api/endpoints/notes/reactions/delete.ts +++ b/src/server/api/endpoints/notes/reactions/delete.ts @@ -3,9 +3,17 @@ import Reaction from '../../../../../models/note-reaction'; import Note from '../../../../../models/note'; import { ILocalUser } from '../../../../../models/user'; -/** - * Unreact to a note - */ +export const meta = { + desc: { + ja: '指定した投稿へのリアクションを取り消します。', + en: 'Unreact to a note.' + }, + + requireCredential: true, + + kind: 'reaction-write' +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'noteId' parameter const [noteId, noteIdErr] = $.type(ID).get(params.noteId); diff --git a/src/server/api/endpoints/notes/trend.ts b/src/server/api/endpoints/notes/trend.ts index ae66234c0..1cbbfacad 100644 --- a/src/server/api/endpoints/notes/trend.ts +++ b/src/server/api/endpoints/notes/trend.ts @@ -3,9 +3,15 @@ import $ from 'cafy'; import Note, { pack } from '../../../../models/note'; import { ILocalUser } from '../../../../models/user'; -/** - * Get trend notes - */ +export const meta = { + desc: { + ja: '人気の投稿の一覧を取得します。', + en: 'Get trend notes.' + }, + + requireCredential: true +}; + export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/notes/user-list-timeline.ts b/src/server/api/endpoints/notes/user-list-timeline.ts index ef08f69c1..5837a9a30 100644 --- a/src/server/api/endpoints/notes/user-list-timeline.ts +++ b/src/server/api/endpoints/notes/user-list-timeline.ts @@ -5,9 +5,15 @@ import { pack } from '../../../../models/note'; import UserList from '../../../../models/user-list'; import { ILocalUser } from '../../../../models/user'; -/** - * Get timeline of a user list - */ +export const meta = { + desc: { + ja: '指定したユーザーリストのタイムラインを取得します。', + en: 'Get timeline of a user list.' + }, + + requireCredential: true +}; + export default async (params: any, user: ILocalUser) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit); diff --git a/src/server/api/endpoints/notifications/mark_as_read_all.ts b/src/server/api/endpoints/notifications/mark_as_read_all.ts index 5011c72d5..7cf4cd16e 100644 --- a/src/server/api/endpoints/notifications/mark_as_read_all.ts +++ b/src/server/api/endpoints/notifications/mark_as_read_all.ts @@ -2,6 +2,17 @@ import Notification from '../../../../models/notification'; import event from '../../../../stream'; import User, { ILocalUser } from '../../../../models/user'; +export const meta = { + desc: { + ja: '全ての通知を既読にします。', + en: 'Mark as read all notifications.' + }, + + requireCredential: true, + + kind: 'notification-write' +}; + /** * Mark as read all notifications */ diff --git a/src/server/api/endpoints/sw/register.ts b/src/server/api/endpoints/sw/register.ts index c7bf1bfbe..341460004 100644 --- a/src/server/api/endpoints/sw/register.ts +++ b/src/server/api/endpoints/sw/register.ts @@ -2,6 +2,10 @@ import $ from 'cafy'; import Subscription from '../../../../models/sw-subscription'; import { ILocalUser } from '../../../../models/user'; +export const meta = { + requireCredential: true +}; + /** * subscribe service worker */ diff --git a/src/server/api/endpoints/users/lists/create.ts b/src/server/api/endpoints/users/lists/create.ts index f3776afee..d7dc2a5f7 100644 --- a/src/server/api/endpoints/users/lists/create.ts +++ b/src/server/api/endpoints/users/lists/create.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import UserList, { pack } from '../../../../../models/user-list'; import { ILocalUser } from '../../../../../models/user'; -/** - * Create a user list - */ +export const meta = { + desc: { + ja: 'ユーザーリストを作成します。', + en: 'Create a user list' + }, + + requireCredential: true, + + kind: 'account-write' +}; + export default async (params: any, user: ILocalUser) => new Promise(async (res, rej) => { // Get 'title' parameter const [title, titleErr] = $.str.range(1, 100).get(params.title); diff --git a/src/server/api/endpoints/users/lists/list.ts b/src/server/api/endpoints/users/lists/list.ts index 88fa75a11..31fef26bd 100644 --- a/src/server/api/endpoints/users/lists/list.ts +++ b/src/server/api/endpoints/users/lists/list.ts @@ -1,9 +1,16 @@ import UserList, { pack } from '../../../../../models/user-list'; import { ILocalUser } from '../../../../../models/user'; -/** - * Add a user to a user list - */ +export const meta = { + desc: { + ja: '自分の作成したユーザーリスト一覧を取得します。' + }, + + requireCredential: true, + + kind: 'account-read' +}; + export default async (params: any, me: ILocalUser) => new Promise(async (res, rej) => { // Fetch lists const userLists = await UserList.find({ diff --git a/src/server/api/endpoints/users/lists/push.ts b/src/server/api/endpoints/users/lists/push.ts index 9e99d59fc..bd4e201bd 100644 --- a/src/server/api/endpoints/users/lists/push.ts +++ b/src/server/api/endpoints/users/lists/push.ts @@ -6,6 +6,17 @@ import ap from '../../../../../remote/activitypub/renderer'; import renderFollow from '../../../../../remote/activitypub/renderer/follow'; import { deliver } from '../../../../../queue'; +export const meta = { + desc: { + ja: '指定したユーザーリストに指定したユーザーを追加します。', + en: 'Add a user to a user list.' + }, + + requireCredential: true, + + kind: 'account-write' +}; + /** * Add a user to a user list */ diff --git a/src/server/api/endpoints/users/lists/show.ts b/src/server/api/endpoints/users/lists/show.ts index f432cf44f..2fd142a60 100644 --- a/src/server/api/endpoints/users/lists/show.ts +++ b/src/server/api/endpoints/users/lists/show.ts @@ -2,9 +2,17 @@ import $ from 'cafy'; import ID from '../../../../../misc/cafy-id'; import UserList, { pack } from '../../../../../models/user-list'; import { ILocalUser } from '../../../../../models/user'; -/** - * Show a user list - */ +export const meta = { + desc: { + ja: '指定したユーザーリストの情報を取得します。', + en: 'Show a user list.' + }, + + requireCredential: true, + + kind: 'account-read' +}; + export default async (params: any, me: ILocalUser) => new Promise(async (res, rej) => { // Get 'listId' parameter const [listId, listIdErr] = $.type(ID).get(params.listId); diff --git a/src/server/api/endpoints/users/recommendation.ts b/src/server/api/endpoints/users/recommendation.ts index b7402b7fb..13377e6ff 100644 --- a/src/server/api/endpoints/users/recommendation.ts +++ b/src/server/api/endpoints/users/recommendation.ts @@ -4,9 +4,16 @@ import User, { pack, ILocalUser } from '../../../../models/user'; import { getFriendIds } from '../../common/get-friends'; import Mute from '../../../../models/mute'; -/** - * Get recommended users - */ +export const meta = { + desc: { + ja: 'おすすめのユーザー一覧を取得します。' + }, + + requireCredential: true, + + kind: 'account-read' +}; + export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);