1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-10-30 14:51:48 +09:00

Update api definitions

This commit is contained in:
syuilo 2018-07-17 04:36:44 +09:00
parent aacfb5e221
commit 16726789da
66 changed files with 586 additions and 156 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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

View File

@ -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);

View File

@ -8,7 +8,8 @@ import getParams from '../../../get-params';
export const meta = {
desc: {
ja: 'ドライブにファイルをアップロードします。'
ja: 'ドライブにファイルをアップロードします。',
en: 'Upload a file to drive.'
},
requireCredential: true,

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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
*/

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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({

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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({

View File

@ -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({

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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] =

View File

@ -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);

View File

@ -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);

View File

@ -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))));
});

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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);

View File

@ -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({

View File

@ -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
*/

View File

@ -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);

View File

@ -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);