diff --git a/docs/config.md b/.config/example.yml similarity index 56% rename from docs/config.md rename to .config/example.yml index 653fff1a7..4772a1f22 100644 --- a/docs/config.md +++ b/.config/example.yml @@ -1,4 +1,3 @@ -``` yaml # サーバーのメンテナ情報 maintainer: # メンテナの名前 @@ -7,16 +6,13 @@ maintainer: # メンテナの連絡先(URLかmailto形式のURL) url: -# プライマリURL +# (Misskeyを動かす)URL url: -# セカンダリURL -secondary_url: - # 待受ポート port: -# TLSの設定(利用しない場合は省略可能) +# TLSの設定(利用しない場合は省略してください) https: # 証明書のパス... key: @@ -49,4 +45,13 @@ sw: # VAPIDの秘密鍵 private_key: -``` +# Google Maps API +google_maps_api_key: + +# Twitterインテグレーションの設定(利用しない場合は省略可能) +twitter: + # インテグレーション用アプリのコンシューマーキー + consumer_key: + + # インテグレーション用アプリのコンシューマーシークレット + consumer_secret: diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..0943cb4b6 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,27 @@ +{ + "parserOptions": { + "parser": "typescript-eslint-parser" + }, + "extends": [ + "eslint:recommended", + "plugin:vue/recommended" + ], + "rules": { + "vue/require-v-for-key": false, + "vue/max-attributes-per-line": false, + "vue/html-indent": false, + "vue/html-self-closing": false, + "vue/no-unused-vars": false, + "vue/attributes-order": false, + "vue/require-prop-types": false, + "vue/require-default-prop": false, + "no-console": 0, + "no-unused-vars": 0, + "no-empty": 0 + }, + "globals": { + "ENV": true, + "VERSION": true, + "API": true + } +} diff --git a/.gitattributes b/.gitattributes index c6c5947ba..952d6cd0e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,3 @@ *.svg -diff -text *.psd -diff -text *.ai -diff -text - -*.tag linguist-language=HTML diff --git a/.gitignore b/.gitignore index a51e70381..326db6fa5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ -/.config +/.config/* +!/.config/example.yml /.vscode /node_modules +/build /built /data npm-debug.log diff --git a/.travis.yml b/.travis.yml index ed53af9e2..d2552bb46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,13 @@ # travis file # https://docs.travis-ci.com/user/customizing-the-build -branches: - except: - - release +notifications: + email: false language: node_js node_js: - - 8.4.0 + - 9.8.0 env: - CXX=g++-4.8 NODE_ENV=production @@ -37,14 +36,8 @@ before_script: # --only=dev オプションを付けてそれらもインストールされるようにする: - npm install --only=dev - # 設定ファイルを設定 - - mkdir ./.config + # 設定ファイルを配置 - cp ./.travis/default.yml ./.config - cp ./.travis/test.yml ./.config - - npm run build - -after_success: - # リリース - - chmod u+x ./.travis/release.sh - - if [ $TRAVIS_BRANCH = "master" ] && [ $TRAVIS_PULL_REQUEST = "false" ]; then ./.travis/release.sh; else echo "Skipping releasing task"; fi + - travis_wait npm run build diff --git a/.travis/.gitignore-release b/.travis/.gitignore-release deleted file mode 100644 index ae1157b33..000000000 --- a/.travis/.gitignore-release +++ /dev/null @@ -1,10 +0,0 @@ -# Realizing whitelist by excluding everything and specifying exceptions. - -/* - -!/built -!/tools -!/elasticsearch -!/package.json -!/.travis.yml -!/appveyor.yml diff --git a/.travis/release.sh b/.travis/release.sh deleted file mode 100644 index 5def2ab03..000000000 --- a/.travis/release.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -echo "Starting releasing task" -openssl aes-256-cbc -K $encrypted_ceda82069128_key -iv $encrypted_ceda82069128_iv -in ./.travis/travis_rsa.enc -out travis_rsa -d -cp travis_rsa ~/.ssh/id_rsa -chmod 600 ~/.ssh/id_rsa -echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config -git checkout -b release -cp -f ./.travis/.gitignore-release .gitignore -node ./.travis/shapeup.js -git add --all -git rm --cached `git ls-files --full-name -i --exclude-standard` -git config --global user.email "AyaMorisawa4869@gmail.com" -git config --global user.name "Aya Morisawa" -git commit -m "Release build for $TRAVIS_COMMIT" -git push -f git@github.com:syuilo/misskey release -echo "Finished releasing task" diff --git a/.travis/shapeup.js b/.travis/shapeup.js deleted file mode 100644 index 9a5d85a18..000000000 --- a/.travis/shapeup.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict' - -const fs = require('fs') -const filename = process.argv[2] || 'package.json' - -fs.readFile(filename, (err, data) => { - if (err) process.exit(2) - const object = JSON.parse(data) - delete object.devDependencies - fs.writeFile(filename, JSON.stringify(object, null, '\t') + '\n', err => { - if (err) process.exit(3) - }) -}) diff --git a/.travis/travis_rsa.enc b/.travis/travis_rsa.enc deleted file mode 100644 index ec45f8a6b..000000000 Binary files a/.travis/travis_rsa.enc and /dev/null differ diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 0a166aa44..000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,413 +0,0 @@ -ChangeLog (Release Notes) -========================= -主に notable な changes を書いていきます - -3230 (2017/11/28) ------------------ -* :v: - -3219 (2017/11/28) ------------------ -* なんか - -3212 (2017/11/27) ------------------ -* なんか - -3201 (2017/11/23) ------------------ -* Twitterログインを実装 (#939) - -3196 (2017/11/23) ------------------ -* バグ修正 - -3194 (2017/11/23) ------------------ -* バグ修正 - -3191 (2017/11/23) ------------------ -* :v: - -3188 (2017/11/22) ------------------ -* バグ修正 - -3180 (2017/11/21) ------------------ -* バグ修正 - -3177 (2017/11/21) ------------------ -* ServiceWorker support - * Misskeyを開いていないときでも通知を受け取れるように(Chromeのみ) - -3165 (2017/11/20) ------------------ -* デスクトップ版でも通知バッジを表示 (#918) -* デザインの調整 -* バグ修正 - -3155 (2017/11/20) ------------------ -* デスクトップ版でユーザーの投稿グラフを見れるように - -3142 (2017/11/18) ------------------ -* バグ修正 - -3140 (2017/11/18) ------------------ -* ウィジェットをスクロールに追従させるように - -3136 (2017/11/17) ------------------ -* バグ修正 -* 通信の最適化 - -3131 (2017/11/17) ------------------ -* バグ修正 -* 通信の最適化 - -3124 (2017/11/16) ------------------ -* バグ修正 - -3121 (2017/11/16) ------------------ -* ブロードキャストウィジェットの強化 -* デザインのグリッチの修正 -* 通信の最適化 - -3113 (2017/11/15) ------------------ -* アクティビティのレンダリングの問題の修正など - -3110 (2017/11/15) ------------------ -* デザインの調整など - -3107 (2017/11/14) ------------------ -* デザインの調整 - -3104 (2017/11/14) ------------------ -* デスクトップ版ユーザーページのデザインの改良 -* バグ修正 - -3099 (2017/11/14) ------------------ -* デスクトップ版ユーザーページの強化 -* バグ修正 - -3093 (2017/11/14) ------------------ -* やった - -3089 (2017/11/14) ------------------ -* なんか - -3069 (2017/11/14) ------------------ -* ドライブウィンドウもポップアウトできるように -* デザインの調整 - -3066 (2017/11/14) ------------------ -* メッセージウィジェット追加 -* アクセスログウィジェット追加 - -3057 (2017/11/13) ------------------ -* グリッチ修正 - -3055 (2017/11/13) ------------------ -* メッセージのウィンドウのポップアウト (#911) - -3050 (2017/11/13) ------------------ -* 通信の最適化 - * これで例えばサーバー情報ウィジェットを5000兆個設置しても利用するコネクションは一つだけになりウィジェットを1つ設置したときと(ネットワーク的な)負荷は変わらなくなる -* デザインの調整 -* ユーザビリティの向上 - -3040 (2017/11/12) ------------------ -* バグ修正 - -3038 (2017/11/12) ------------------ -* 投稿フォームウィジェットの追加 -* タイムライン上部にもウィジェットを配置できるように - -3035 (2017/11/12) ------------------ -* ウィジェットの強化 - -3033 (2017/11/12) ------------------ -* デザインの調整 - -3031 (2017/11/12) ------------------ -* ウィジェットの強化 - -3028 (2017/11/12) ------------------ -* ウィジェットの表示をコンパクトにできるように - -3026 (2017/11/12) ------------------ -* バグ修正 - -3024 (2017/11/12) ------------------ -* いい感じにするなど - -3020 (2017/11/12) ------------------ -* 通信の最適化 - -3017 (2017/11/11) ------------------ -* 誤字修正など - -3012 (2017/11/11) ------------------ -* デザインの調整 - -3010 (2017/11/11) ------------------ -* デザインの調整 - -3008 (2017/11/11) ------------------ -* カレンダー(タイムマシン)ウィジェットの追加 - -3006 (2017/11/11) ------------------ -* デザインの調整 -* など - -2996 (2017/11/10) ------------------ -* デザインの調整 -* など - -2991 (2017/11/09) ------------------ -* デザインの調整 - -2988 (2017/11/09) ------------------ -* チャンネルウィジェットを追加 - -2984 (2017/11/09) ------------------ -* スライドショーウィジェットを追加 - -2974 (2017/11/08) ------------------ -* ホームのカスタマイズを実装するなど - -2971 (2017/11/08) ------------------ -* バグ修正 -* デザインの調整 -* i18n - -2944 (2017/11/07) ------------------ -* パフォーマンスの向上 - * GirdFSになるなどした -* 依存関係の更新 - -2807 (2017/11/02) ------------------ -* いい感じに - -2805 (2017/11/02) ------------------ -* いい感じに - -2801 (2017/11/01) ------------------ -* チャンネルのWatch実装 - -2799 (2017/11/01) ------------------ -* いい感じに - -2795 (2017/11/01) ------------------ -* いい感じに - -2793 (2017/11/01) ------------------ -* なんか - -2783 (2017/11/01) ------------------ -* なんか - -2777 (2017/11/01) ------------------ -* 細かいブラッシュアップ - -2775 (2017/11/01) ------------------ -* Fix: バグ修正 - -2769 (2017/11/01) ------------------ -* New: チャンネルシステム - -2752 (2017/10/30) ------------------ -* New: 未読の通知がある場合アイコンを表示するように - -2747 (2017/10/25) ------------------ -* Fix: 非ログイン状態ですべてのページが致命的な問題を発生させる (#89) - -2742 (2017/10/25) ------------------ -* New: トラブルシューティングを実装するなど - -2735 (2017/10/22) ------------------ -* New: モバイル版からでもクライアントバージョンを確認できるように - -2732 (2017/10/22) ------------------ -* 依存関係の更新など - -2584 (2017/09/08) ------------------ -* New: ユーザーページによく使うドメインを表示 (#771) -* New: よくリプライするユーザーをユーザーページに表示 (#770) - -2566 (2017/09/07) ------------------ -* New: 投稿することの多いキーワードをユーザーページに表示する (#768) -* l10n -* デザインの修正 - -2544 (2017/09/06) ------------------ -* 投稿のカテゴリに関する実験的な実装 -* l10n -* ユーザビリティの向上 - -2520 (2017/08/30) ------------------ -* デザインの調整 - -2518 (2017/08/30) ------------------ -* Fix: モバイル版のタイムラインからリアクションやメニューを開けない -* デザインの調整 - -2515 (2017/08/30) ------------------ -* New: 投稿のピン留め (#746) -* New: モバイル版のユーザーページに知り合いのフォロワーを表示するように -* New: ホームストリームにメッセージを流すことでlast_used_atを更新できるようにする (#745) -* その他細かな修正 - -2508 (2017/08/30) ------------------ -* New: モバイル版のユーザーページのアクティビティチャートを変更 -* New: モバイル版のユーザーページに最終ログイン日時を表示するように -* デザインの調整 - -2503 (2017/08/30) ------------------ -* デザインの調整 - -2502 (2017/08/30) ------------------ -* デザインの修正・調整 - -2501 (2017/08/30) ------------------ -* New: モバイルのユーザーページを刷新 - -2498 (2017/08/29) ------------------ -* Fix: repostのborder-radiusが効いていない (#743) -* テーマカラーを赤に戻してみた -* ユーザビリティの向上 -* デザインの調整 - -2493-2 (2017/08/29) -------------------- -* デザインの修正 - -2493 (2017/08/29) ------------------ -* デザインの変更など - -2491 (2017/08/29) ------------------ -* デザインの修正と調整 - -2489 (2017/08/29) ------------------ -* ユーザビリティの向上 -* デザインの調整 - -2487 (2017/08/29) ------------------ -* New: パスワードを変更する際に新しいパスワードを二度入力させる (#739) -* New: ドナーを表示する (#738) -* Fix: 投稿のリンクが機能していない問題を修正 -* Fix: アカウント作成フォームのユーザーページURLプレビューが正しく機能していなかった問題を修正 -* l10n -* デザインの調整 - -2470 (2017/08/29) ------------------ -* New: トークンを再生成できるように (#497) -* New: パスワードを変更する機能 (#364) - -2461 (2017/08/28) ------------------ -* Fix: モバイル版からアバターとバナーの設定を行えなかった問題を修正 -* デザインの修正 - -2458 (2017/08/28) ------------------ -* New: モバイル版からプロフィールを設定できるように -* New: モバイル版からサインアウトを行えるように -* New: 投稿ページに次の投稿/前の投稿リンクを作成 (#734) -* New: タイムラインの投稿をダブルクリックすることで詳細な情報が見れるように -* Fix: モバイル版でおすすめユーザーをフォローしてもタイムラインが更新されない (#736) -* Fix: モバイル版で設定にアクセスできない -* デザインの調整 -* 依存関係の更新 - -2380 ----- -アプリケーションが作れない問題を修正 - -2367 ----- -Statsのユーザー数グラフに「アカウントが作成された**回数**」(その日時点での「アカウント数」**ではなく**)グラフも併記するようにした - -2364 ----- -デザインの微調整 - -2361 ----- -Statsを実装するなど - -2357 ----- -Statusを実装するなど diff --git a/DONORS.md b/DONATORS.md similarity index 56% rename from DONORS.md rename to DONATORS.md index 9752068b3..6fe5df04b 100644 --- a/DONORS.md +++ b/DONATORS.md @@ -1,8 +1,8 @@ -DONORS -====== +DONATORS +======== The list of people who have sent donation for Misskey. -(no particular order) +(In random order, honorific titles are omitted.) * らふぁ * 俺様 @@ -10,6 +10,13 @@ The list of people who have sent donation for Misskey. * スルメ https://surume.tk/ * 藍 * 音船 https://otofune.me/ +* aqz https://misskey.xyz/aqz +* kotodu "虚無創作中" +* Maya Minatsuki +* Knzk https://knzk.me/@Knzk +* ねじりわさび https://knzk.me/@y +* NCLS https://knzk.me/@imncls] +* こじま @skoji@sandbox.skoji.jp :heart: Thanks for donating, guys! diff --git a/LICENSE b/LICENSE index e3733b396..dba13ed2d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,661 @@ -The MIT License (MIT) + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 -Copyright (c) 2014-2017 syuilo + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: + Preamble -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md index e3c93b749..312441331 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,71 @@ -![Misskey](./assets/title.png) + + +[![Misskey](/assets/title.png)](https://misskey.xyz/) ================================================================ [![][travis-badge]][travis-link] [![][dependencies-badge]][dependencies-link] [![][himawari-badge]][himasaku] [![][sakurako-badge]][himasaku] -[![][mit-badge]][mit] +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) -[Misskey](https://misskey.xyz) is a completely open source, +> Lead Maintainer: [syuilo][syuilo-link] + +**[Misskey](https://misskey.xyz)** is a completely open source, ultimately sophisticated new type of mini-blog based SNS. -![ss](./assets/ss.jpg) +Become a Patron! -Key features +:sparkles: Features ---------------------------------------------------------------- -* Automatically updated timeline +* Reactions +* User lists * Private messages -* Free 1GB storage for each all users -* ServiceWorker support -* Web API for third-party applications -* No ads +* Mute +* Real time contents +* ActivityPub compatible and more! You can touch with your own eyes at https://misskey.xyz/. -Setup and Installation +:package: Create your instance ---------------------------------------------------------------- If you want to run your own instance of Misskey, please see [Setup and installation guide](./docs/setup.en.md). -Contribution +:wrench: Contribute ---------------------------------------------------------------- -Please see [Contribution guide](./CONTRIBUTING.md). +**[PR](https://github.com/syuilo/misskey/pulls)s welcome!** -Release Notes +If you want to translate Misskey, please see [Translation guide](./docs/translate.en.md). + +:heart: Backers & Sponsors ---------------------------------------------------------------- -Please see [ChangeLog](./CHANGELOG.md). +[![Backers][backers-image]][support-url] +[![Sponsors][sponsors-image]][support-url] -Sponsors & Backers +:mortar_board: Notable contributors ---------------------------------------------------------------- -Misskey has no 100+ GitHub stars currently. However, a donation is always welcome! -If you want to donate to Misskey, please get in touch with [@syuilo][syuilo-link]. - -**Note:** When you donate to Misskey, your name will be listed in [donors](./DONORS.md). - -Collaborators ----------------------------------------------------------------- -| ![syuilo][syuilo-icon] | ![Morisawa Aya][ayamorisawa-icon] | ![otofune][otofune-icon] | -|------------------------|-----------------------------------|---------------------------------| -| [syuilo][syuilo-link] | [Aya Morisawa][ayamorisawa-link] | [otofune][otofune-link] | +| ![syuilo][syuilo-icon] | ![Morisawa Aya][ayamorisawa-icon] | ![otofune][otofune-icon] | ![akihikodaki][akihikodaki-icon] | ![tamaina][tamaina-icon] | ![rinsuki][rinsuki-icon] | +|:-:|:-:|:-:|:-:|:-:|:-:| +| [syuilo][syuilo-link]
Owner | [Aya Morisawa][ayamorisawa-link]
Collaborator | [otofune][otofune-link]
Collaborator | [akihikodaki][akihikodaki-link] | [tamaina][tamaina-link] | [rinsuki][rinsuki-link] | [List of all contributors](https://github.com/syuilo/misskey/graphs/contributors) -Copyright ----------------------------------------------------------------- -Misskey is an open-source software licensed under [The MIT License](LICENSE). +### :earth_americas: Translators +| ![][mirro-san-icon] | ![][Conan-kun-icon] | +|:-:|:-:| +| [Mirro][mirro-san-link]
English, French | [Asriel][Conan-kun-link]
English, French | -[mit]: http://opensource.org/licenses/MIT -[mit-badge]: https://img.shields.io/badge/license-MIT-444444.svg?style=flat-square +:four_leaf_clover: Copyright +---------------------------------------------------------------- +> Copyright (c) 2014-2018 syuilo + +Misskey is an open-source software licensed under [GNU AGPLv3](LICENSE). + +[![][agpl-3.0-badge]][AGPL-3.0] + +[agpl-3.0]: https://www.gnu.org/licenses/agpl-3.0.en.html +[agpl-3.0-badge]: https://img.shields.io/badge/license-AGPL--3.0-444444.svg?style=flat-square [travis-link]: https://travis-ci.org/syuilo/misskey [travis-badge]: http://img.shields.io/travis/syuilo/misskey/master.svg?style=flat-square [dependencies-link]: https://david-dm.org/syuilo/misskey @@ -65,10 +74,30 @@ Misskey is an open-source software licensed under [The MIT License](LICENSE). [himawari-badge]: https://img.shields.io/badge/%E5%8F%A4%E8%B0%B7-%E5%90%91%E6%97%A5%E8%91%B5-1684c5.svg?style=flat-square [sakurako-badge]: https://img.shields.io/badge/%E5%A4%A7%E5%AE%A4-%E6%AB%BB%E5%AD%90-efb02a.svg?style=flat-square - +[backer-url]: #backers +[backer-badge]: https://opencollective.com/misskey/backers/badge.svg +[backers-image]: https://opencollective.com/misskey/backers.svg +[sponsor-url]: #sponsors +[sponsor-badge]: https://opencollective.com/misskey/sponsors/badge.svg +[sponsors-image]: https://opencollective.com/misskey/sponsors.svg +[support-url]: https://opencollective.com/misskey#support + + [syuilo-link]: https://syuilo.com [syuilo-icon]: https://avatars2.githubusercontent.com/u/4439005?v=3&s=70 [ayamorisawa-link]: https://github.com/ayamorisawa [ayamorisawa-icon]: https://avatars0.githubusercontent.com/u/10798641?v=3&s=70 [otofune-link]: https://github.com/otofune [otofune-icon]: https://avatars0.githubusercontent.com/u/15062473?v=3&s=70 +[akihikodaki-link]: https://github.com/akihikodaki +[akihikodaki-icon]: https://avatars2.githubusercontent.com/u/17036990?s=70&v=4 +[rinsuki-link]: https://github.com/rinsuki +[rinsuki-icon]: https://avatars0.githubusercontent.com/u/6533808?s=70&v=4 +[tamaina-link]: https://github.com/tamaina +[tamaina-icon]: https://avatars1.githubusercontent.com/u/7973572?s=70&v=4 + +[mirro-san-link]: https://github.com/mirro-san +[mirro-san-icon]: https://avatars1.githubusercontent.com/u/17948612?s=70&v=4 +[Conan-kun-link]: https://github.com/Conan-kun +[Conan-kun-icon]: https://avatars3.githubusercontent.com/u/30003708?s=70&v=4 + diff --git a/assets/apple-touch-icon.png b/assets/apple-touch-icon.png index 623cf6bb9..b3c4be42a 100644 Binary files a/assets/apple-touch-icon.png and b/assets/apple-touch-icon.png differ diff --git a/assets/favicon.ico b/assets/favicon.ico new file mode 100644 index 000000000..d63c68b01 Binary files /dev/null and b/assets/favicon.ico differ diff --git a/assets/favicon/128.png b/assets/favicon/128.png index 16e8dfb5b..1ccaaeee1 100644 Binary files a/assets/favicon/128.png and b/assets/favicon/128.png differ diff --git a/assets/favicon/128.svg b/assets/favicon/128.svg new file mode 100644 index 000000000..34888557b Binary files /dev/null and b/assets/favicon/128.svg differ diff --git a/assets/favicon/16.png b/assets/favicon/16.png index 7e36d1cda..a1d3e1be7 100644 Binary files a/assets/favicon/16.png and b/assets/favicon/16.png differ diff --git a/assets/favicon/16.svg b/assets/favicon/16.svg new file mode 100644 index 000000000..03aa8bc6b Binary files /dev/null and b/assets/favicon/16.svg differ diff --git a/assets/favicon/256.png b/assets/favicon/256.png index 623cf6bb9..b3c4be42a 100644 Binary files a/assets/favicon/256.png and b/assets/favicon/256.png differ diff --git a/assets/favicon/256.svg b/assets/favicon/256.svg new file mode 100644 index 000000000..5ecee9e0b Binary files /dev/null and b/assets/favicon/256.svg differ diff --git a/assets/favicon/32.png b/assets/favicon/32.png index f13ebb147..f0466cce9 100644 Binary files a/assets/favicon/32.png and b/assets/favicon/32.png differ diff --git a/assets/favicon/32.svg b/assets/favicon/32.svg new file mode 100644 index 000000000..4dfcc6860 Binary files /dev/null and b/assets/favicon/32.svg differ diff --git a/assets/favicon/64.png b/assets/favicon/64.png index 72751fe77..9710052ae 100644 Binary files a/assets/favicon/64.png and b/assets/favicon/64.png differ diff --git a/assets/favicon/64.svg b/assets/favicon/64.svg new file mode 100644 index 000000000..e2378791a Binary files /dev/null and b/assets/favicon/64.svg differ diff --git a/assets/icon.ai b/assets/icon.ai deleted file mode 100644 index c2d5219c7..000000000 Binary files a/assets/icon.ai and /dev/null differ diff --git a/assets/mi.svg b/assets/mi.svg new file mode 100644 index 000000000..d4f7cf7e9 Binary files /dev/null and b/assets/mi.svg differ diff --git a/assets/ss.jpg b/assets/ss.jpg deleted file mode 100644 index a337b3fa7..000000000 Binary files a/assets/ss.jpg and /dev/null differ diff --git a/assets/title.png b/assets/title.png index 05658c877..cacbb248d 100644 Binary files a/assets/title.png and b/assets/title.png differ diff --git a/assets/title.svg b/assets/title.svg index ad8290fe9..95ad11c39 100644 Binary files a/assets/title.svg and b/assets/title.svg differ diff --git a/binding.gyp b/binding.gyp new file mode 100644 index 000000000..0349526d5 --- /dev/null +++ b/binding.gyp @@ -0,0 +1,9 @@ +{ + 'targets': [ + { + 'target_name': 'crypto_key', + 'sources': ['src/crypto_key.cc'], + 'include_dirs': [' new Promise(async (res, rej) => { + const file = await DriveFile.findOne(prev ? { + _id: { $gt: prev._id } + } : {}, { + sort: { + _id: 1 + } + }); + + prev = file; + + console.log(`scanning ${file._id}`); + + const attachingUsersCount = await User.count({ + $or: [{ + avatarId: file._id + }, { + bannerId: file._id + }] + }, { limit: 1 }); + if (attachingUsersCount !== 0) return res(); + + const attachingNotesCount = await Note.count({ + mediaIds: file._id + }, { limit: 1 }); + if (attachingNotesCount !== 0) return res(); + + const attachingMessagesCount = await MessagingMessage.count({ + fileId: file._id + }, { limit: 1 }); + if (attachingMessagesCount !== 0) return res(); + + console.log(`deleting ${file._id}`); + + deleteDriveFile(file).then(res).catch(rej); + })); + } + + return await sequential(promiseGens); +} + +main().then(console.dir).catch(console.error); diff --git a/cli/del-usr.js b/cli/del-usr.js new file mode 100644 index 000000000..08e97845e --- /dev/null +++ b/cli/del-usr.js @@ -0,0 +1,13 @@ +const deleteUser = require('../built/models/user').deleteUser; + +const args = process.argv.slice(2); + +const userId = args[0]; + +console.log(`deleting ${userId}...`); + +deleteUser(userId).then(() => { + console.log('done'); +}, e => { + console.error(e); +}); diff --git a/cli/delete-invalid-users.js b/cli/delete-invalid-users.js new file mode 100644 index 000000000..41bbc2bab --- /dev/null +++ b/cli/delete-invalid-users.js @@ -0,0 +1,40 @@ +const { default: User, deleteUser } = require('../built/models/user'); +const { default: zip } = require('@prezzemolo/zip') + +const migrate = async (user) => { + try { + await deleteUser(user._id); + return true; + } catch (e) { + return false; + } +} + +async function main() { + const count = await User.count({ + uri: /#/ + }); + + const dop = 1 + const idop = ((count - (count % dop)) / dop) + 1 + + return zip( + 1, + async (time) => { + console.log(`${time} / ${idop}`) + const doc = await User.find({ + uri: /#/ + }, { + limit: dop, skip: time * dop + }) + return Promise.all(doc.map(migrate)) + }, + idop + ).then(a => { + const rv = [] + a.forEach(e => rv.push(...e)) + return rv + }) +} + +main().then(console.dir).catch(console.error) diff --git a/cli/init.js b/cli/init.js new file mode 100644 index 000000000..96160b0b8 --- /dev/null +++ b/cli/init.js @@ -0,0 +1,164 @@ +const fs = require('fs'); +const path = require('path'); +const yaml = require('js-yaml'); +const inquirer = require('inquirer'); +const chalk = require('chalk'); + +const configDirPath = `${__dirname}/../.config`; +const configPath = `${configDirPath}/default.yml`; + +const form = [{ + type: 'input', + name: 'maintainerName', + message: 'Your name:' +}, { + type: 'input', + name: 'maintainerUrl', + message: 'Your home page URL or your mailto URL:' +}, { + type: 'input', + name: 'url', + message: 'URL you want to run Misskey:' +}, { + type: 'input', + name: 'port', + message: 'Listen port (e.g. 443):' +}, { + type: 'confirm', + name: 'https', + message: 'Use TLS?', + default: false +}, { + type: 'input', + name: 'https_key', + message: 'Path of tls key:', + when: ctx => ctx.https +}, { + type: 'input', + name: 'https_cert', + message: 'Path of tls cert:', + when: ctx => ctx.https +}, { + type: 'input', + name: 'https_ca', + message: 'Path of tls ca:', + when: ctx => ctx.https +}, { + type: 'input', + name: 'mongo_host', + message: 'MongoDB\'s host:', + default: 'localhost' +}, { + type: 'input', + name: 'mongo_port', + message: 'MongoDB\'s port:', + default: '27017' +}, { + type: 'input', + name: 'mongo_db', + message: 'MongoDB\'s db:', + default: 'misskey' +}, { + type: 'input', + name: 'mongo_user', + message: 'MongoDB\'s user:' +}, { + type: 'password', + name: 'mongo_pass', + message: 'MongoDB\'s password:' +}, { + type: 'input', + name: 'redis_host', + message: 'Redis\'s host:', + default: 'localhost' +}, { + type: 'input', + name: 'redis_port', + message: 'Redis\'s port:', + default: '6379' +}, { + type: 'password', + name: 'redis_pass', + message: 'Redis\'s password:' +}, { + type: 'confirm', + name: 'elasticsearch', + message: 'Use Elasticsearch?', + default: false +}, { + type: 'input', + name: 'es_host', + message: 'Elasticsearch\'s host:', + default: 'localhost', + when: ctx => ctx.elasticsearch +}, { + type: 'input', + name: 'es_port', + message: 'Elasticsearch\'s port:', + default: '9200', + when: ctx => ctx.elasticsearch +}, { + type: 'password', + name: 'es_pass', + message: 'Elasticsearch\'s password:', + when: ctx => ctx.elasticsearch +}, { + type: 'input', + name: 'recaptcha_site', + message: 'reCAPTCHA\'s site key:' +}, { + type: 'input', + name: 'recaptcha_secret', + message: 'reCAPTCHA\'s secret key:' +}]; + +inquirer.prompt(form).then(as => { + // Mapping answers + const conf = { + maintainer: { + name: as['maintainerName'], + url: as['maintainerUrl'] + }, + url: as['url'], + port: parseInt(as['port'], 10), + mongodb: { + host: as['mongo_host'], + port: parseInt(as['mongo_port'], 10), + db: as['mongo_db'], + user: as['mongo_user'], + pass: as['mongo_pass'] + }, + redis: { + host: as['redis_host'], + port: parseInt(as['redis_port'], 10), + pass: as['redis_pass'] + }, + elasticsearch: { + enable: as['elasticsearch'], + host: as['es_host'] || null, + port: parseInt(as['es_port'], 10) || null, + pass: as['es_pass'] || null + }, + recaptcha: { + site_key: as['recaptcha_site'], + secret_key: as['recaptcha_secret'] + } + }; + + if (as['https']) { + conf.https = { + key: as['https_key'] || null, + cert: as['https_cert'] || null, + ca: as['https_ca'] || null + }; + } + + console.log(`Thanks. Writing the configuration to ${chalk.bold(path.resolve(configPath))}`); + + try { + fs.writeFileSync(configPath, yaml.dump(conf)); + console.log(chalk.green('Well done.')); + } catch (e) { + console.error(e); + } +}); diff --git a/cli/suspend.js b/cli/suspend.js new file mode 100644 index 000000000..0f22bba47 --- /dev/null +++ b/cli/suspend.js @@ -0,0 +1,18 @@ +const mongo = require('mongodb'); +const User = require('../built/models/user').default; + +const args = process.argv.slice(2); + +const userId = new mongo.ObjectID(args[0]); + +console.log(`Suspending ${userId}...`); + +User.update({ _id: userId }, { + $set: { + isSuspended: true + } +}).then(() => { + console.log(`Suspended ${userId}`); +}, e => { + console.error(e); +}); diff --git a/docker/Dockerfile b/docker/Dockerfile index ef04fc9e2..7cee650de 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,7 +14,7 @@ RUN pacman -S --noconfirm pacman RUN pacman-db-upgrade RUN pacman -S --noconfirm archlinux-keyring RUN pacman -Syyu --noconfirm -RUN pacman -S --noconfirm git nodejs npm mongodb redis graphicsmagick +RUN pacman -S --noconfirm git nodejs npm mongodb redis imagemagick COPY misskey.sh /root/misskey.sh RUN chmod u+x /root/misskey.sh diff --git a/docs/backup.md b/docs/backup.md index 484564b31..74ec2678e 100644 --- a/docs/backup.md +++ b/docs/backup.md @@ -7,7 +7,7 @@ Make sure **mongodb-tools** installed. In your shell: ``` shell -$ mongodump --archive=db-backup +$ mongodump --archive=db-backup -u -p ``` For details, plese see [mongodump docs](https://docs.mongodb.com/manual/reference/program/mongodump/). diff --git a/docs/donate.ja.md b/docs/donate.ja.md new file mode 100644 index 000000000..b19d7bc37 --- /dev/null +++ b/docs/donate.ja.md @@ -0,0 +1,26 @@ +# Misskeyにカンパする方法 +Misskeyのサポートにご興味をお持ちいただきありがとうございます! +Misskeyにカンパをしていただくと、貴方のお名前と好きなURLなどをMisskeyのリポジトリに刻む権利がもらえます。 + +Misskeyにカンパして開発・運営をサポートするには、次のいくつかの方法があります: + +## ConoHaカードを購入する +(本家)Misskeyは、ConoHaというVPSサービスを利用しています。ConoHaカードを購入して、 +カードに記載されているクーポンコードを syuilotan@yahoo.co.jp までお送りいただければ、 +そのクーポンをチャージしてサーバーの運営費に充てることができます。 + +ConoHaカードについてはこちらをご覧ください: https://www.conoha.jp/conohacard/ + +Amazonでも買えます: https://www.amazon.co.jp/dp/B01N9E3416 + +## Amazonギフトカード +これは間接的な方法です。 + +## 銀行振込 +syuilotan@yahoo.co.jp までお問い合わせください。 + +## 手渡し +オフ会を行ったときなどに行使できる方法です。 + +## その他 +なにかいいアイデアがあればお教えください。 diff --git a/docs/manage.ja.md b/docs/manage.ja.md new file mode 100644 index 000000000..d56ed4c19 --- /dev/null +++ b/docs/manage.ja.md @@ -0,0 +1,13 @@ +# 運営ガイド + +## ジョブキューの状態を調べる +Misskeyのディレクトリで: +``` shell +node_modules/kue/bin/kue-dashboard -p 3050 +``` +ポート3050にアクセスするとUIが表示されます + +## ユーザーを凍結する +``` shell +node cli/suspend (ユーザーID) +``` diff --git a/docs/setup.en.md b/docs/setup.en.md index 9c31e4f17..b858a4a2a 100644 --- a/docs/setup.en.md +++ b/docs/setup.en.md @@ -8,30 +8,7 @@ This guide describes how to install and setup Misskey. ---------------------------------------------------------------- -If you can use Docker, please see [Setup with Docker](./docker.en.md). - -*1.* Domains ----------------------------------------------------------------- -Misskey requires two domains called the primary domain and the secondary domain. - -* The primary domain is used to provide main service of Misskey. -* The secondary domain is used to avoid vulnerabilities such as XSS. - -**Ensure that the secondary domain is not a subdomain of the primary domain.** - -### Subdomains -Note that Misskey uses following subdomains: - -* **api**.*{primary domain}* -* **auth**.*{primary domain}* -* **about**.*{primary domain}* -* **ch**.*{primary domain}* -* **stats**.*{primary domain}* -* **status**.*{primary domain}* -* **dev**.*{primary domain}* -* **file**.*{secondary domain}* - -*2.* reCAPTCHA tokens +*1.* reCAPTCHA tokens ---------------------------------------------------------------- Misskey requires reCAPTCHA tokens. Please visit https://www.google.com/recaptcha/intro/ and generate keys. @@ -45,7 +22,7 @@ npm install web-push -g web-push generate-vapid-keys ``` -*3.* Install dependencies +*2.* Install dependencies ---------------------------------------------------------------- Please install and setup these softwares: @@ -53,34 +30,44 @@ Please install and setup these softwares: * *Node.js* and *npm* * **[MongoDB](https://www.mongodb.com/)** * **[Redis](https://redis.io/)** -* **[GraphicsMagick](http://www.graphicsmagick.org/)** +* **[ImageMagick](http://www.imagemagick.org/script/index.php)** >= 7.0 ##### Optional * [Elasticsearch](https://www.elastic.co/) - used to provide searching feature instead of MongoDB -*4.* Install Misskey +*3.* Install Misskey ---------------------------------------------------------------- - 1. `git clone -b master git://github.com/syuilo/misskey.git` 2. `cd misskey` 3. `npm install` + +*4.* Prepare configuration +---------------------------------------------------------------- +1. Copy `example.yml` of `.config` directory +2. Rename it to `default.yml` +3. Edit it + +--- + +Or you can generate config file via `npm run config` command. + +*5.* Build Misskey +---------------------------------------------------------------- +We need to use `node-gyp` to build the `crypto` module. + +1. `npm install -g node-gyp` +2. `node-gyp configure` +3. `node-gyp build` 4. `npm run build` -#### Update -1. `git pull origin master` -2. `npm install` -3. `npm run build` - -*5.* That is it. +*6.* That is it. ---------------------------------------------------------------- Well done! Now, you have an environment that run to Misskey. ### Launch Just `sudo npm start`. GLHF! -### Testing -Run `npm test` after building - -### Debugging :bug: -#### Show debug messages -Misskey uses [debug](https://github.com/visionmedia/debug) and the namespace is `misskey:*`. +### Way to Update to latest version of your Misskey +1. `git reset --hard && git pull origin master` +2. `npm install` +3. `npm run build` diff --git a/docs/setup.ja.md b/docs/setup.ja.md index 1e8bb553f..a46c38cb2 100644 --- a/docs/setup.ja.md +++ b/docs/setup.ja.md @@ -8,31 +8,7 @@ Misskeyサーバーの構築にご関心をお寄せいただきありがとう ---------------------------------------------------------------- -Dockerを利用してMisskeyを構築することもできます: [Setup with Docker](./docker.en.md)。 -その場合、*3番目*以降の手順はスキップできます。 - -*1.* ドメインの用意 ----------------------------------------------------------------- -Misskeyはプライマリ ドメインとセカンダリ ドメインを必要とします。 - -* プライマリ ドメインはMisskeyの主要な部分を提供するために使われます。 -* セカンダリ ドメインはXSSといった脆弱性の対策に使われます。 - -**セカンダリ ドメインがプライマリ ドメインのサブドメインであってはなりません。** - -### サブドメイン -Misskeyは以下のサブドメインを使います: - -* **api**.*{primary domain}* -* **auth**.*{primary domain}* -* **about**.*{primary domain}* -* **ch**.*{primary domain}* -* **stats**.*{primary domain}* -* **status**.*{primary domain}* -* **dev**.*{primary domain}* -* **file**.*{secondary domain}* - -*2.* reCAPTCHAトークンの用意 +*1.* reCAPTCHAトークンの用意 ---------------------------------------------------------------- MisskeyはreCAPTCHAトークンを必要とします。 https://www.google.com/recaptcha/intro/ にアクセスしてトークンを生成してください。 @@ -46,7 +22,7 @@ npm install web-push -g web-push generate-vapid-keys ``` -*3.* 依存関係をインストールする +*2.* 依存関係をインストールする ---------------------------------------------------------------- これらのソフトウェアをインストール・設定してください: @@ -54,34 +30,40 @@ web-push generate-vapid-keys * *Node.js* と *npm* * **[MongoDB](https://www.mongodb.com/)** * **[Redis](https://redis.io/)** -* **[GraphicsMagick](http://www.graphicsmagick.org/)** +* **[ImageMagick](http://www.imagemagick.org/script/index.php)** ##### オプション * [Elasticsearch](https://www.elastic.co/) - 検索機能を向上させるために用います。 -*4.* Misskeyのインストール +*3.* Misskeyのインストール ---------------------------------------------------------------- - 1. `git clone -b master git://github.com/syuilo/misskey.git` 2. `cd misskey` 3. `npm install` -4. `npm run build` -#### アップデートするには: -1. `git pull origin master` -2. `npm install` -3. `npm run build` +*4.* 設定ファイルを用意する +---------------------------------------------------------------- +1. `.config`ディレクトリ内の`example.yml`をコピー +2. `default.yml`にリネーム +3. 編集する -*5.* 以上です! +--- + +または、`npm run config`コマンドを利用して、ガイドに従って情報を +入力して設定ファイルを生成することもできます。 + +*5.* Misskeyのビルド +---------------------------------------------------------------- +1. `npm run build` + +*6.* 以上です! ---------------------------------------------------------------- お疲れ様でした。これでMisskeyを動かす準備は整いました。 ### 起動 `sudo npm start`するだけです。GLHF! -### テスト -(ビルドされている状態で)`npm test` - -### デバッグ :bug: -#### デバッグメッセージを表示するようにする -Misskeyは[debug](https://github.com/visionmedia/debug)モジュールを利用しており、ネームスペースは`misskey:*`となっています。 +### Misskeyを最新バージョンにアップデートする方法: +1. `git reset --hard && git pull origin master` +2. `npm install` +3. `npm run build` diff --git a/docs/translate.en.md b/docs/translate.en.md new file mode 100644 index 000000000..a80f472a3 --- /dev/null +++ b/docs/translate.en.md @@ -0,0 +1,27 @@ +Misskey's Translation - English version +============ + +How to add a new language? +---------------------- +Copy a language file to `/locales` and rename it after the language you wish to add. + +If you find an untranslated part on Misskey: +------------------------------- + +1. Look for untranslated parts in the miskey's source code. + - For instance, if you find an untranslated part in: `src/client/app/mobile/views/pages/home.vue`. + +2. Replace the untranslated portion with a character string of the form `%i18n:@foo%`. + - In fact, `foo` should be a word that is appropriate for the situation and is easy to understand in English. + - For example, if the untranslated portion is the following "タイムライン" you must write: `%i18n:@timeline%`. + +3. Open each language file in /locales, check whether the file name (path) found in step 1 exists, if not, create it. + - Do not put the beginning of the path `src/client/app/` in the locale file. + - For example, in this case we want to modify untranslated parts of `src/client/app/mobile/views/pages/home.vue`, so the key is `mobile/views/pages/home.vue`. + +4. Add the translated text property using the `foo` keyword below the path that you found or created in step 2. Make sure to type your text in quotation marks. Text should always be inside of quotes. + - For example, in this case we add timeline: `timeline: "Timeline"` to `locales/en.yml`, and `timeline: "タイムライン"` to `locales/ja.yml`. + +5. And done! + +For more details, please refer to this [commit](https://github.com/syuilo/misskey/commit/10f6d5980fa7692ccb45fbc5f843458b69b7607c). diff --git a/docs/translate.fr.md b/docs/translate.fr.md new file mode 100644 index 000000000..8350bcb36 --- /dev/null +++ b/docs/translate.fr.md @@ -0,0 +1,27 @@ +Traduction de Misskey - Version Française +============ + +Comment ajouter une nouvelle langue ? +---------------------- +Veuillez copier un fichier de langue dans /locales puis renommez-le du nom de la langue que vous voulez ajouter et modifier. + +Si vous trouvez un segment non-traduit sur Misskey : +------------------------------- + +1. Veuillez chercher des parties non-traduites dans le code source de Misskey. + - Par exemple, supposons que vous trouviez un segment non-traduit dans : `src/client/app/mobile/views/pages/home.vue`. + +2. Remplacez la portion non-traduite par une chaîne de caractères de type `%i18n:@foo%`. + - En fait, `foo` doit être un mot approprié à la situation et facile à comprendre en français. + - Par exemple, si le segment non-traduit est「タイムライン」on peut écrire : `%i18n:@timeline%`. + +3. Ouvrez chaque fichier linguistique dans /locales, vérifiez si le nom du fichier (chemin) trouvé dans l'étape 1 existe, sinon créez-le. + - Ne mettez pas le début du chemin `src/client/app/` dans les fichiers /locales. + - Par exemple, dans ce cas de figure, nous voulons modifier le segment non-traduit de : `src/client/app/mobile/views/pages/home.vue`donc il faut juste écrire : `mobile/views/pages/home.vue` dans les fichiers linguistiques. + +4. Ajoutez la propriété du texte traduit grâce à la clef `foo`, en-dessous du chemin correspondant à votre modification que vous avez trouvé ou créé dans l'étape 2. À côté, veuillez indiquer entre "guillemets" la valeur de votre traduction. + - Par exemple, dans ce cas de figure, nous ajoutons la propriété et la traduction `timeline: "Timeline"` à `locales/fr.yml`, mais aussi la propriété et la version originale `timeline: "タイムライン"` à `locales/ja.yml`. + +5. Vous avez réussi à traduire une portion de misskey ! + +Pour plus de détails, veuillez vous référer à ce [commit](https://github.com/syuilo/misskey/commit/10f6d5980fa7692ccb45fbc5f843458b69b7607c). diff --git a/docs/translate.ja.md b/docs/translate.ja.md new file mode 100644 index 000000000..22172b12e --- /dev/null +++ b/docs/translate.ja.md @@ -0,0 +1,27 @@ +Misskeyの翻訳 +============ + +新たな言語を追加するには +---------------------- +/locales 内に既にある何らかの言語ファイルをコピーして、追加したい言語名にリネームして編集してください。 + +Misskey内の未翻訳箇所を見つけたら +------------------------------- + +1. Misskeyのソースコード内から未翻訳箇所を探してください。 + - 例えば`src/client/app/mobile/views/pages/home.vue`で未翻訳箇所を見つけたとします。 + +2. 未翻訳箇所を`%i18n:@foo%`のような形式の文字列に置換してください。 + - `foo`は実際にはその場に適したわかりやすい(英語の)名前にしてください。 + - 例えば未翻訳箇所が「タイムライン」というテキストだった場合、`%i18n:@timeline%`のようにします。 + +3. /locales 内にあるそれぞれの言語ファイルを開き、1.で見つけたファイル名(パス)のキーが存在するか確認し、無ければ作成してください。 + - パスの`src/client/app/`は省略してください。 + - 例えば、今回の例では`src/client/app/mobile/views/pages/home.vue`の未翻訳箇所を修正したいので、キーは`mobile/views/pages/home.vue`になります。 + +4. そのキーの直下に2.で置換した`foo`の部分をキーとし、翻訳後のテキストを値とするプロパティを追加します。 + - 例えば、今回の例で言うと`locales/ja.yml`に`timeline: "タイムライン"`、`locales/en.yml`に`timeline: "Timeline"`を追加します。 + +5. 完了です! + +詳しくは、[このコミット](https://github.com/syuilo/misskey/commit/10f6d5980fa7692ccb45fbc5f843458b69b7607c)などを参考にしてください。 diff --git a/gulpfile.ts b/gulpfile.ts index 93002cbf3..df355e33e 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -2,13 +2,12 @@ * Gulp tasks */ -import * as childProcess from 'child_process'; -import * as Path from 'path'; +import * as fs from 'fs'; import * as gulp from 'gulp'; import * as gutil from 'gulp-util'; import * as ts from 'gulp-typescript'; +const sourcemaps = require('gulp-sourcemaps'); import tslint from 'gulp-tslint'; -import * as es from 'event-stream'; import cssnano = require('gulp-cssnano'); import * as uglifyComposer from 'gulp-uglify/composer'; import pug = require('gulp-pug'); @@ -20,11 +19,14 @@ import * as mocha from 'gulp-mocha'; import * as replace from 'gulp-replace'; import * as htmlmin from 'gulp-htmlmin'; const uglifyes = require('uglify-es'); -import version from './src/version'; + +import { fa } from './src/build/fa'; +const client = require('./built/client/meta.json'); +import config from './src/config'; const uglify = uglifyComposer(uglifyes, console); -const env = process.env.NODE_ENV; +const env = process.env.NODE_ENV || 'development'; const isProduction = env === 'production'; const isDebug = !isProduction; @@ -35,40 +37,34 @@ if (isDebug) { const constants = require('./src/const.json'); +require('./src/client/docs/gulpfile.ts'); + gulp.task('build', [ - 'build:js', 'build:ts', 'build:copy', - 'build:client' + 'build:client', + 'doc' ]); gulp.task('rebuild', ['clean', 'build']); -gulp.task('build:js', () => - gulp.src(['./src/**/*.js', '!./src/web/**/*.js']) - .pipe(gulp.dest('./built/')) -); - gulp.task('build:ts', () => { - const tsProject = ts.createProject('./src/tsconfig.json'); + const tsProject = ts.createProject('./tsconfig.json'); return tsProject .src() + .pipe(sourcemaps.init()) .pipe(tsProject()) + .pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: '../built' })) .pipe(gulp.dest('./built/')); }); gulp.task('build:copy', () => - es.merge( - gulp.src([ - './src/**/assets/**/*', - '!./src/web/app/**/assets/**/*' - ]).pipe(gulp.dest('./built/')) as any, - gulp.src([ - './src/web/about/**/*', - '!./src/web/about/**/*.pug' - ]).pipe(gulp.dest('./built/web/about/')) as any - ) + gulp.src([ + './build/Release/crypto_key.node', + './src/**/assets/**/*', + '!./src/client/app/**/assets/**/*' + ]).pipe(gulp.dest('./built/')) ); gulp.task('test', ['lint', 'mocha']); @@ -93,8 +89,8 @@ gulp.src('./src/**/*.ts') gulp.task('mocha', () => gulp.src([]) .pipe(mocha({ - exit: true - //compilers: 'ts:ts-node/register' + exit: true, + compilers: 'ts:ts-node/register' } as any)) ); @@ -110,55 +106,43 @@ gulp.task('default', ['build']); gulp.task('build:client', [ 'build:ts', - 'build:js', - 'webpack', 'build:client:script', 'build:client:pug', 'copy:client' ]); -gulp.task('webpack', done => { - const webpack = childProcess.spawn( - Path.join('.', 'node_modules', '.bin', 'webpack'), - ['--config', './webpack/webpack.config.ts'], { - shell: true, - stdio: 'inherit' - }); - - webpack.on('exit', done); -}); - gulp.task('build:client:script', () => - gulp.src(['./src/web/app/boot.js', './src/web/app/safe.js']) - .pipe(replace('VERSION', JSON.stringify(version))) + gulp.src(['./src/client/app/boot.js', './src/client/app/safe.js']) + .pipe(replace('VERSION', JSON.stringify(client.version))) + .pipe(replace('API', JSON.stringify(config.api_url))) + .pipe(replace('ENV', JSON.stringify(env))) .pipe(isProduction ? uglify({ toplevel: true } as any) : gutil.noop()) - .pipe(gulp.dest('./built/web/assets/')) as any + .pipe(gulp.dest('./built/client/assets/')) as any ); gulp.task('build:client:styles', () => - gulp.src('./src/web/app/init.css') + gulp.src('./src/client/app/init.css') .pipe(isProduction ? (cssnano as any)() : gutil.noop()) - .pipe(gulp.dest('./built/web/assets/')) + .pipe(gulp.dest('./built/client/assets/')) ); gulp.task('copy:client', [ - 'build:client:script', - 'webpack' + 'build:client:script' ], () => gulp.src([ './assets/**/*', - './src/web/assets/**/*', - './src/web/app/*/assets/**/*' + './src/client/assets/**/*', + './src/client/app/*/assets/**/*' ]) .pipe(isProduction ? (imagemin as any)() : gutil.noop()) .pipe(rename(path => { path.dirname = path.dirname.replace('assets', '.'); })) - .pipe(gulp.dest('./built/web/assets/')) + .pipe(gulp.dest('./built/client/assets/')) ); gulp.task('build:client:pug', [ @@ -166,10 +150,13 @@ gulp.task('build:client:pug', [ 'build:client:script', 'build:client:styles' ], () => - gulp.src('./src/web/app/base.pug') + gulp.src('./src/client/app/base.pug') .pipe(pug({ locals: { - themeColor: constants.themeColor + themeColor: constants.themeColor, + facss: fa.dom.css(), + //hljscss: fs.readFileSync('./node_modules/highlight.js/styles/default.css', 'utf8') + hljscss: fs.readFileSync('./src/client/assets/code-highlight.css', 'utf8') } })) .pipe(htmlmin({ @@ -199,7 +186,10 @@ gulp.task('build:client:pug', [ // 属性の値がデフォルトと同じなら省略する e.g. // to // - removeRedundantAttributes: true + removeRedundantAttributes: true, + + // CSSも圧縮する + minifyCSS: true })) - .pipe(gulp.dest('./built/web/app/')) + .pipe(gulp.dest('./built/client/app/')) ); diff --git a/locales/en.yml b/locales/en.yml index 9a54eed67..4ef12432b 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -1,5 +1,5 @@ common: - misskey: "Note everything and share it others using Misskey." + misskey: "Share everything with others using Misskey." time: unknown: "unknown" @@ -33,613 +33,617 @@ common: confused: "Confused" pudding: "Pudding" - post_categories: - music: "Music" - game: "Video Game" - anime: "Anime" - it: "IT" - gadgets: "Gadgets" - photography: "Photography" - - input-message-here: "Enter message here" - send: "Send" delete: "Delete" loading: "Loading" ok: "OK" - update-available: "New version of Misskey is now available({newer}, current is {current}). Reload page to apply update." - my-token-regenerated: "Your token is just regenerated, so you will signout." - - tags: - mk-nav-links: - about: "About" - stats: "Stats" - status: "Status" - wiki: "Wiki" - donors: "Donors" - repository: "Repository" - develop: "Developers" - - mk-messaging-form: - attach-from-local: "Attach file from your pc" - attach-from-drive: "Attach file from the drive" - - mk-messaging: - search-user: "Find a user" - you: "You" - no-history: "No history" - - mk-messaging-message: - is-read: "Read" - deleted: "This message has been deleted" - - mk-messaging-room: - empty: "No conversations" - more: "More" - no-history: "There is no more history" - resize-form: "Drag to resize" - new-message: "New message" - - mk-authorized-apps: - no-apps: "No apps" - - mk-error: - title: "Unable to connect to the server" - description: "There is a problem with Internet connection, or the server may be down or maintaining. Please {try again} later." - thanks: "Thank you for using Misskey." - troubleshoot: "Troubleshoot" - - troubleshooter: - title: "TroubleShooting" - network: "Network connection" - checking-network: "Checking network connection" - internet: "Internet connection" - checking-internet: "Checking internet connection" - server: "Server connection" - checking-server: "Checking server connection" - finding: "Finding a problem" - no-network: "There is no Network connection" - no-network-desc: "Please make sure you are connected to the Network." - no-internet: "There is no Internet connection" - no-internet-desc: "Please make sure you are connected to the Internet." - no-server: "Unable to connect to the server" - no-server-desc: "The network connection of your PC is normal, but you could not connect to Misskey's server. There is a possibility that the server is down or maintaining, please try to access it again after a while." - success: "Successfully connect to the Misskey's server" - success-desc: "It seems to be able to connect normally. Please reload the page." - - mk-forkit: - open-github-link: "View source on Github" - - mk-poll-editor: - no-only-one-choice: "You need to enter two or more choice." - choice-n: "Choice {}" - remove: "Remove this choice" - add: "+ Add a choice" - destroy: "Destroy this poll" - - mk-poll: - vote-to: "Vote to 「{}」" - vote-count: "{} votes" - total-users: "{} users voted" - vote: "Vote" - show-result: "Show result" - voted: "Voted" - - mk-post-menu: - pin: "Pin" - pinned: "Pinned" - select: "Select category" - categorize: "Accept" - categorized: "Category reported. Thank you!" - - mk-reaction-picker: - choose-reaction: "Pick your reaction" - - mk-signin: - username: "Username" - password: "Password" - signing-in: "Signing in..." - signin: "Sign in" - - mk-signup: - username: "Username" - checking: "Checking..." - available: "Available" - unavailable: "Unavailable" - error: "Network error" - invalid-format: "Only use letters, numbers and -." - too-short: "Please enter at least 3 letters!" - too-long: "Please enter within 20 letters." - password: "Password" - password-placeholder: "We recommend more than 8 letters." - weak-password: "Weak" - normal-password: "So so" - strong-password: "Strong" - retype: "Type again" - retype-placeholder: "Confirm your password" - password-matched: "OK" - password-not-matched: "Not matched" - recaptcha: "Verify" - create: "Create an Account" - some-error: "Account creation failed for some reason. Please try again." - - mk-special-message: - new-year: "Happy New Year!" - christmas: "Merry Christmas!" - - mk-stream-indicator: - connecting: "Connecting" - reconnecting: "Reconnecting" - connected: "Connected" - - mk-twitter-setting: - description: "お使いのTwitterアカウントをお使いのMisskeyアカウントに接続しておくと、プロフィールでTwitterアカウント情報が表示されるようになったり、Twitterを用いた便利なサインインを利用できるようになります。" - connected-to: "You to connected this Twitter account" - detail: "Detail..." - reconnect: "Reconnect" - connect: "Connect to Twitter" - disconnect: "Disconnect" - - mk-uploader: - waiting: "Waiting" - -ch: - tags: - mk-index: - new: "Create new channel" - channel-title: "Channel title" - - mk-channel-form: - textarea: "Write here" - upload: "Upload" - drive: "Drive" - post: "Do" - posting: "Doing" - -desktop: - tags: - mk-api-info: - regenerate-token: "Please enter the password" - - mk-drive-browser-base-contextmenu: - create-folder: "Create a folder" - upload: "Upload a file" - url-upload: "Upload from a URL" - - mk-drive-browser-window: - used: "used" - drive: "Drive" - - mk-drive-browser: - search: "Search" - load-more: "Load more" - empty-draghover: "Drop Welcome!" - empty-drive: "Your drive is empty" - empty-drive-description: "右クリックして「ファイルをアップロード」を選んだり、ファイルをドラッグ&ドロップすることでもアップロードできます。" - empty-folder: "This folder is empty" - unable-to-process: "操作を完了できません" - circular-reference-detected: "移動先のフォルダーは、移動するフォルダーのサブフォルダーです。" - unhandled-error: "Unknown error" - url-upload: "Upload from a URL" - url-of-file: "URL of file you want to upload" - url-upload-requested: "Upload requested" - may-take-time: "アップロードが完了するまで時間がかかる場合があります。" - create-folder: "Create a folder" - folder-name: "Folder name" - - mk-drive-browser-file-contextmenu: - rename: "Rename" - copy-url: "Copy URL" - download: "Download" - else-files: "その他..." - set-as-avatar: "Set as avatar" - set-as-banner: "Set as banner" - open-in-app: "Open in app" - add-app: "Add app" - rename-file: "Rename file" - input-new-file-name: "Enter new name" - copied: "Copied" - copied-url-to-clipboard: "Copied URL to clipboard" - - mk-drive-browser-file: - avatar: "Avatar" - banner: "Banner" - - mk-drive-browser-folder-contextmenu: - move-to-this-folder: "Move to this folder" - show-in-new-window: "Open in new window" - rename: "Rename" - rename-folder: "Rename folder" - input-new-folder-name: "Enter new name" - - mk-drive-browser-folder: - unable-to-process: "操作を完了できません" - circular-reference-detected: "移動先のフォルダーは、移動するフォルダーのサブフォルダーです。" - unhandled-error: "Unknown error" - - mk-drive-browser-nav-folder: - drive: "Drive" - - mk-selectdrive-page: - title: "Choose a file(s)" - ok: "OK" - cancel: "Cancel" - upload: "Upload a file(s) from you PC" - - mk-ui-header-nav: - home: "Home" - messaging: "Messages" - ch: "Channels" - info: "News" - - mk-ui-header-search: - placeholder: "Search" - - mk-ui-header-account: - profile: "Your profile" - drive: "Drive" - mentions: "Mentions" - settings: "Settings" - signout: "Sign out" - - mk-ui-header-post-button: - post: "Compose new Post" - - mk-ui-header-notifications: - title: "Notifications" - - mk-password-setting: - reset: "Change your password" - enter-current-password: "Enter the current password" - enter-new-password: "Enter the new password" - enter-new-password-again: "Enter the new password again" - not-match: "New password not matched" - changed: "Password updated successfully" - - mk-post-form: - post-placeholder: "What's happening?" - reply-placeholder: "Reply to this post..." - quote-placeholder: "Quote this post..." - post: "Post" - reply: "Reply" - repost: "Repost" - posted: "Posted!" - replied: "Replied!" - reposted: "Reposted!" - post-failed: "Failed to post" - reply-failed: "Failed to reply" - repost-failed: "Failed to repost" - posting: "Posting" - attach-media-from-local: "Attach media from your pc" - attach-media-from-drive: "Attach media from the drive" - attach-cancel: "Cancel attachment" - insert-a-kao: "v(‘ω’)v" - create-poll: "Create a poll" - text-remain: "{} chars remaining" - - mk-post-form-window: - post: "New post" - reply: "Reply" - attaches: "{} media attached" - uploading-media: "Uploading {} media" - - mk-post-page: - prev: "Previous post" - next: "Next post" - - mk-settings: - password: "Password" - - mk-timeline-post: - reposted-by: "Reposted by {}" - reply: "Reply" - repost: "Repost" - add-reaction: "Add your reaction" - detail: "Show detail" - - mk-notifications: - more: "More" - - mk-notifications-home-widget: - title: "Notifications" - settings: "Notification settings" - - mk-server-home-widget: - title: "Server info" - toggle: "Toggle views" - - mk-activity-widget: - title: "Activity" - toggle: "Toggle views" - - mk-user-recommendation-home-widget: - title: "Recommended users" - refresh: "Show others" - no-one: "No one" - - mk-recommended-polls-home-widget: - title: "Polls" - refresh: "Show others" - nothing: "Nothing" - - mk-trends-home-widget: - title: "Trend" - refresh: "Show others" - nothing: "Nothing" - - mk-photo-stream-home-widget: - title: "Photostream" - no-photos: "No photos" - - mk-donation-home-widget: - title: "Donation" - text: "To manage Misskey we spend money for our domain server etc.. There's no incomes for us so we need your tip. If you're interested contact {}. Thank you for your contribution!" - - mk-channel-home-widget: - title: "Channel" - settings: "Widget settings" - get-started: "Please click the cog in the upper right to specify the channel to receive" - - mk-calendar-widget: - title: "{1} / {2}" - prev: "Previous month" - next: "Next month" - go: "Click to travel" - - mk-post-form-home-widget: - title: "Post" - post: "Post" - placeholder: "What's happening?" - - mk-access-log-home-widget: - title: "Access log" - - mk-messaging-home-widget: - title: "Messaging" - - mk-broadcast-home-widget: - fetching: "Fetching" - no-broadcasts: "No broadcasts" - have-a-nice-day: "Have a nice day!" - next: "Next" - - mk-repost-form: - quote: "Quote..." - cancel: "Cancel" - repost: "Repost" - reposting: "Reposting..." - success: "Reposted!" - failure: "Failed to Repost" - - mk-repost-form-window: - title: "Are you sure you want to repost this post?" - - mk-user: - last-used-at: "Last used at" - - photos: - title: "Photos" - loading: "Loading" - no-photos: "No photos" - - frequently-replied-users: - title: "Frequently replied" - loading: "Loading" - no-users: "No users" - - followers-you-know: - title: "Followers you know" - loading: "Loading" - no-users: "No users" - -mobile: - tags: - mk-selectdrive-page: - select-file: "Select file(s)" - - mk-drive-file-viewer: - download: "Download" - rename: "Rename" - move: "Move" - hash: "Hash (md5)" - - mk-entrance-signin: - signup: "Sign up" - about: "About Misskey" - - mk-entrance-signup: - cancel: "Cancel" - - mk-authorized-apps-page: - application: "Applications" - - mk-signin-history-page: - signin-history: "Sign in history" - - mk-twitter-setting-page: - twitter-integration: "Twitter integration" - - mk-drive-page: - drive: "Drive" - - mk-home: - home: "Home" - - mk-messaging-room-page: - message: "Messaging" - - mk-messaging-page: - message: "Messaging" - - mk-notifications-page: - notifications: "Notifications" - read-all: "Are you sure you want to mark all unread notifications as read?" - - mk-post-page: - title: "Post" - prev: "Previous post" - next: "Next post" - - mk-search-page: - search: "Search" - - mk-settings: - signed-in-as: "Signed in as {}" - - mk-settings-page: - profile: "Profile" - applications: "Applications" - twitter-integration: "Twitter integration" - signin-history: "Sign in history" - api: "API" - link: "MisskeyLink" - settings: "Settings" - signout: "Sign out" - - mk-profile-setting-page: - title: "Profile Settings" - - mk-profile-setting: - will-be-published: "These profiles will be published." + update-available: "A new version of Misskey is now available({newer}, current is {current}). Reload the page to apply the update." + my-token-regenerated: "Your token has been generated. You will now get logged out." + +common/views/components/connect-failed.vue: + title: "Unable to connect to the server" + description: "There is a problem either with your internet connection, or the server may be down or under maintenance. Please {try again} later." + thanks: "Thank you for using Misskey." + troubleshoot: "Troubleshoot" + +common/views/components/connect-failed.troubleshooter.vue: + title: "Troubleshooting" + network: "Network connection" + checking-network: "Checking network connection" + internet: "Internet connection" + checking-internet: "Checking internet connection" + server: "Server connection" + checking-server: "Checking server connection" + finding: "Finding a problem" + no-network: "There is no Network connection" + no-network-desc: "Please make sure you are connected to the Network." + no-internet: "There is no Internet connection" + no-internet-desc: "Please make sure you are connected to the Internet." + no-server: "Unable to connect to the server" + no-server-desc: "The network connection of your PC is normal, but you could not connect to Misskey's server. There is a possibility that the server is either down or under maintenance, please try again later." + success: "Successfully connected to Misskey's server" + success-desc: "It seems to be able to connect. Please reload the page." + flush: "Clean cache" + set-version: "Specify version" + +common/views/components/messaging.vue: + search-user: "Find an user" + you: "You" + no-history: "No history" + +common/views/components/messaging-room.vue: + empty: "No conversations" + more: "More" + no-history: "There is no more history" + resize-form: "Drag to resize" + new-message: "New message" + +common/views/components/messaging-room.form.vue: + input-message-here: "Enter message here" + send: "Send" + attach-from-local: "Attach files from your pc" + attach-from-drive: "Attach files from your Drive" + +common/views/components/messaging-room.message.vue: + is-read: "Read" + deleted: "This message has been deleted" + +common/views/components/nav.vue: + about: "About" + stats: "Stats" + status: "Status" + wiki: "Wiki" + donors: "Donators" + repository: "Repository" + develop: "Developers" + feedback: "Feedback" + +common/views/components/note-menu.vue: + favorite: "Favorite this note" + pin: "Pin to profile page" + remote: "Show on origin" + +common/views/components/poll.vue: + vote-to: "Vote for '{}'" + vote-count: "{} votes" + total-users: "{} users voted" + vote: "Vote" + show-result: "Show results" + voted: "Voted" + +common/views/components/poll-editor.vue: + no-only-one-choice: "You need to enter two or more choices." + choice-n: "Choice {}" + remove: "Remove this choice" + add: "+ Add a choice" + destroy: "Destroy this poll" + +common/views/components/reaction-picker.vue: + choose-reaction: "Choose a reaction" + +common/views/components/signin.vue: + username: "Username" + password: "Password" + token: "Token" + signing-in: "Signing in..." + signin: "Sign in" + +common/views/components/signup.vue: + username: "Username" + checking: "Checking..." + available: "Available" + unavailable: "Unavailable" + error: "Network error" + invalid-format: "Only use letters, numbers and -." + too-short: "Please enter at least 1 character!" + too-long: "Please enter up to 20 characters." + password: "Password" + password-placeholder: "We recommend more than 8 characters." + weak-password: "Weak" + normal-password: "So so" + strong-password: "Strong" + retype: "Type again" + retype-placeholder: "Confirm your password" + password-matched: "OK" + password-not-matched: "Doesn't match" + recaptcha: "Verify" + create: "Create an Account" + some-error: "Account creation failed for some reason. Please try again." + +common/views/components/special-message.vue: + new-year: "Happy New Year!" + christmas: "Merry Christmas!" + +common/views/components/stream-indicator.vue: + connecting: "Connecting" + reconnecting: "Reconnecting" + connected: "Connected" + +common/views/components/twitter-setting.vue: + description: "If you connect your Twitter account to your Misskey account, you will be able to see your Twitter account information on your profile and you can sign-in using Twitter." + connected-to: "You are connected to this Twitter account" + detail: "Detail..." + reconnect: "Reconnect" + connect: "Link your twitter account" + disconnect: "Disconnect" + +common/views/components/uploader.vue: + waiting: "Waiting" + +common/views/widgets/broadcast.vue: + fetching: "Fetching" + no-broadcasts: "No broadcasts" + have-a-nice-day: "Have a nice day!" + next: "Next" + +common/views/widgets/donation.vue: + title: "Donation" + text: "To keep Misskey up and running we spend money for our domain name, servers and so on.. We don't get any money from it, and we would really appreciate it if you could donate. If you're interested contact {}. Thank you for your contribution!" + +common/views/widgets/photo-stream.vue: + title: "Photostream" + no-photos: "No photos" + +common/views/widgets/server.vue: + title: "Server info" + toggle: "Toggle views" + +desktop/views/components/activity.vue: + title: "Activity" + toggle: "Toggle views" + +desktop/views/components/calendar.vue: + title: "{1} / {2}" + prev: "Previous month" + next: "Next month" + go: "Click to naviguate" + +desktop/views/components/drive-window.vue: + used: "used" + drive: "Drive" + +desktop/views/components/drive.file.vue: + avatar: "Avatar" + banner: "Banner" + contextmenu: + rename: "Rename" + copy-url: "Copy URL" + download: "Download" + else-files: "Others" + set-as-avatar: "Set as avatar" + set-as-banner: "Set as banner" + open-in-app: "Open in app" + add-app: "Add app" + rename-file: "Rename file" + input-new-file-name: "Enter new name" + copied: "Copied" + copied-url-to-clipboard: "Copied URL to clipboard" + +desktop/views/components/drive.folder.vue: + unable-to-process: "The operation could not be completed." + circular-reference-detected: "The destination folder is a subfolder of the folder you wish to move." + unhandled-error: "Unknown error" + contextmenu: + move-to-this-folder: "Move to this folder" + show-in-new-window: "Open in new window" + rename: "Rename" + rename-folder: "Rename folder" + input-new-folder-name: "Enter new name" + +desktop/views/components/drive.nav-folder.vue: + drive: "Drive" + +desktop/views/components/drive.vue: + search: "Search" + load-more: "Load more" + empty-draghover: "Drop Welcome!" + empty-drive: "Your drive is empty" + empty-drive-description: "You can also upload by right clicking and selecting \"Upload file\" or you can drag and drop a file onto the window." + empty-folder: "This folder is empty" + unable-to-process: "The operation could not be completed." + circular-reference-detected: "The destination folder is a subfolder of the folder you wish to move." + unhandled-error: "Unknown error" + url-upload: "Upload from a URL" + url-of-file: "URL of file you want to upload" + url-upload-requested: "Upload requested" + may-take-time: "It may take some time for the upload to complete." + create-folder: "Create a folder" + folder-name: "Folder name" + contextmenu: + create-folder: "Create a folder" + upload: "Upload a file" + url-upload: "Upload from a URL" + +desktop/views/components/messaging-window.vue: + title: "Messaging" + +desktop/views/components/notes.note.vue: + reposted-by: "Reposted by {}" + reply: "Reply" + renote: "Renote" + add-reaction: "Add a reaction" + detail: "Show detail" + +desktop/views/components/notifications.vue: + more: "More" + empty: "No notifications" + +desktop/views/components/post-form.vue: + note-placeholder: "What's happening?" + reply-placeholder: "Reply to this note..." + quote-placeholder: "Quote this note..." + note: "Post" + reply: "Reply" + renote: "Renote" + posted: "Posted!" + replied: "Replied!" + reposted: "Reposted!" + note-failed: "Failed to note" + reply-failed: "Failed to reply" + renote-failed: "Failed to renote" + posting: "Posting" + attach-media-from-local: "Attach media from your pc" + attach-media-from-drive: "Attach media from your Drive" + attach-cancel: "Cancel attachment" + insert-a-kao: "v(‘ω’)v" + create-poll: "Create a poll" + text-remain: "{} chars remaining" + +desktop/views/components/post-form-window.vue: + note: "New note" + reply: "Reply" + attaches: "{} media attached" + uploading-media: "Uploading {} media" + +desktop/views/components/renote-form.vue: + quote: "Quote..." + cancel: "Cancel" + renote: "Renote" + reposting: "Reposting..." + success: "Reposted!" + failure: "Failed to Renote" + +desktop/views/components/renote-form-window.vue: + title: "Are you sure you want to renote this note?" + +desktop/views/components/settings.vue: + profile: "Profile" + notification: "Notification" + apps: "Apps" + mute: "Mute" + drive: "Drive" + security: "Security" + password: "Password" + 2fa: "Two-factor authentication" + other: "Other" + license: "License" + +desktop/views/components/settings.2fa.vue: + intro: "If you set up 2-step verification, you will need not only a password at sign-in but also a pre-registered physical device (such as your smartphone), which will improve security. " + detail: "See details..." + url: "https://www.google.com/landing/2step/" + caution: "If you lose access to your device, you won't be able to connect to Misskey anymore!" + register: "Register a device" + already-registered: "A device is already registered" + unregister: "Disable" + unregistered: "Two-step authentication has been disabled." + enter-password: "Enter the password" + authenticator: "First, you need install Google Authenticator on your device:" + howtoinstall: "How to install" + scan: "And then, scan the QR code:" + done: "Please enter the token displaying on your device:" + submit: "Submit" + success: "Setup completed successfully!" + failed: "Failed to setup. please ensure that the token is correct." + info: "From now on, enter the token that is displayed on your device in addition to your password when signing-in to Misskey." + +desktop/views/components/settings.api.vue: + intro: "APIを利用するには、上記のトークンを「i」というキーでパラメータに付加してリクエストします。" + caution: "Please do not show this token to third parties (do not enter it somewhere else other than here) otherwise your account could get compromised." + regeneration-of-token: "In the unlikely event that this token leaks out you can regenerate it." + regenerate-token: "Regenerate the token" + enter-password: "Please enter the password" + +desktop/views/components/settings.app.vue: + no-apps: "No authorized apps" + +desktop/views/components/settings.mute.vue: + no-users: "No muted users" + +desktop/views/components/settings.password.vue: + reset: "Change your password" + enter-current-password: "Enter the current password" + enter-new-password: "Enter the new password" + enter-new-password-again: "Enter the new password again" + not-match: "New password doesn't match" + changed: "Password updated successfully" + +desktop/views/components/settings.profile.vue: + avatar: "Avatar" + choice-avatar: "Choose an image" + name: "Name" + location: "Location" + description: "Description" + birthday: "Birthday" + save: "Update profile" + +desktop/views/components/ui.header.account.vue: + profile: "Your profile" + drive: "Drive" + favorites: "Favorites" + lists: "Lists" + customize: "Customize" + settings: "Settings" + signout: "Sign out" + dark: "Fall in dark" + +desktop/views/components/ui.header.nav.vue: + home: "Home" + messaging: "Messages" + game: "Game" + +desktop/views/components/ui.header.notifications.vue: + title: "Notifications" + +desktop/views/components/ui.header.post.vue: + post: "Compose new Post" + +desktop/views/components/ui.header.search.vue: + placeholder: "Search" + +desktop/views/pages/note.vue: + prev: "Previous note" + next: "Next note" + +desktop/views/pages/selectdrive.vue: + title: "Choose file(s)" + ok: "OK" + cancel: "Cancel" + upload: "Upload files from you PC" + +desktop/views/pages/user/user.followers-you-know.vue: + title: "Followers you know" + loading: "Loading" + no-users: "No users" + +desktop/views/pages/user/user.friends.vue: + title: "Frequently replied" + loading: "Loading" + no-users: "No users" + +desktop/views/pages/user/user.header.vue: + is-suspended: "This account has been suspended." + is-remote: "This user is a remote user, so the information is not accurate. " + view-remote: "See accurate information" + +desktop/views/pages/user/user.home.vue: + last-used-at: "Last active: " + +desktop/views/pages/user/user.photos.vue: + title: "Photos" + loading: "Loading" + no-photos: "No photos" + +desktop/views/pages/user/user.profile.vue: + follows-you: "Follows you" + stalk: "Stalk" + stalking: "Stalking" + unstalk: "Unstalk" + mute: "Mute" + muted: "Muting" + unmute: "Unmute" + +desktop/views/widgets/messaging.vue: + title: "Messaging" + +desktop/views/widgets/notifications.vue: + title: "Notifications" + settings: "Settings" + +desktop/views/widgets/polls.vue: + title: "Polls" + refresh: "Show others" + nothing: "Nothing" + +desktop/views/widgets/post-form.vue: + title: "Post" + note: "Post" + placeholder: "What's happening?" + +desktop/views/widgets/trends.vue: + title: "Trend" + refresh: "Show others" + nothing: "Nothing" + +desktop/views/widgets/users.vue: + title: "Recommended users" + refresh: "Show others" + no-one: "No one" + +desktop/views/widgets/channel.vue: + title: "Channel" + settings: "Widget settings" + get-started: "Please click the cog in the upper right corner to specify a channel" + +mobile/views/components/drive.vue: + drive: "Drive" + used: "used" + folder-count: "Folder(s)" + count-separator: ", " + file-count: "File(s)" + load-more: "Load more" + nothing-in-drive: "Nothing" + folder-is-empty: "This folder is empty" + +mobile/views/components/drive-file-chooser.vue: + select-file: "Choose a file" + +mobile/views/components/drive-folder-chooser.vue: + select-folder: "Choose a folder" + +mobile/views/components/drive.file-detail.vue: + download: "Download" + rename: "Rename" + move: "Move" + hash: "Hash (md5)" + exif: "EXIF" + +mobile/views/components/follow-button.vue: + follow: "Follow" + unfollow: "Unfollow" + +mobile/views/components/note.vue: + reposted-by: "Renoted by {}" + +mobile/views/components/note-detail.vue: + reply: "Reply" + reaction: "Reaction" + +mobile/views/components/notifications.vue: + more: "More" + empty: "No notifications" + +mobile/views/components/post-form.vue: + submit: "Post" + reply-placeholder: "Reply to this note..." + note-placeholder: "What's happening?" + +mobile/views/components/sub-note-content.vue: + media-count: "{} media" + poll: "Poll" + +mobile/views/components/timeline.vue: + empty: "No notes" + load-more: "More" + +mobile/views/components/ui.nav.vue: + home: "Home" + notifications: "Notifications" + messaging: "Messages" + drive: "Drive" + settings: "Settings" + about: "About Misskey" + search: "Search" + +mobile/views/components/user-timeline.vue: + no-notes: "It seems this user hasn't posted yet" + no-notes-with-media: "There is no notes with attached media" + load-more: "More" + +mobile/views/components/users-list.vue: + all: "All" + known: "You know" + load-more: "More" + +mobile/views/pages/drive.vue: + drive: "Drive" + +mobile/views/pages/followers.vue: + followers-of: "Followers of {}" + +mobile/views/pages/following.vue: + following-of: "Following of {}" + +mobile/views/pages/home.vue: + timeline: "Timeline" + +mobile/views/pages/messaging.vue: + messaging: "Messaging" + +mobile/views/pages/messaging-room.vue: + messaging: "Messaging" + +mobile/views/pages/note.vue: + title: "Post" + prev: "Previous note" + next: "Next note" + +mobile/views/pages/notifications.vue: + notifications: "Notifications" + read-all: "Are you sure you want to mark all unread notifications as read?" + +mobile/views/pages/profile-setting.vue: + title: "Profile settings" + will-be-published: "These profile settings will be updated." + name: "Name" + location: "Location" + description: "Description" + birthday: "Birthday" + avatar: "Avatar" + banner: "Banner" + avatar-saved: "Avatar updated successfully" + banner-saved: "Banner updated successfully" + set-avatar: "Choose an avatar" + set-banner: "Choose a banner" + save: "Save" + saved: "Profile updated successfully" + +mobile/views/pages/search.vue: + search: "Search" + empty: "No posts were found for '{}'" + +mobile/views/pages/selectdrive.vue: + select-file: "Choose a file" + +mobile/views/pages/settings.vue: + signed-in-as: "Signed in as {}" + profile: "Profile" + twitter-integration: "Twitter integration" + signin-history: "Sign in history" + settings: "Settings" + signout: "Sign out" + +mobile/views/pages/user.vue: + follows-you: "Follows you" + following: "Following" + followers: "Followers" + notes: "Posts" + overview: "Overview" + timeline: "Timeline" + media: "Media" + is-suspended: "This account has been suspended." + is-remote: "This user is a remote user, so the information is not accurate. " + view-remote: "See accurate information" + +mobile/views/pages/user/home.vue: + recent-notes: "Recent notes" + images: "Images" + activity: "Activity" + keywords: "Keywords" + domains: "Domains" + frequently-replied-users: "Frequently talking users" + followers-you-know: "Followers you know" + last-used-at: "Last active:" + +mobile/views/pages/user/home.followers-you-know.vue: + loading: "Loading" + no-users: "No users" + +mobile/views/pages/user/home.friends.vue: + loading: "Loading" + no-users: "No users" + +mobile/views/pages/user/home.notes.vue: + loading: "Loading" + no-notes: "No notes" + +mobile/views/pages/user/home.photos.vue: + loading: "Loading" + no-photos: "No photos" + +docs: + edit-this-page-on-github: "Did you find an error or do you want to contribute to the documentation? " + edit-this-page-on-github-link: "Edit this page on Github!" + + api: + entities: + properties: "Properties" + endpoints: + params: "Parameters" + res: "Response" + props: name: "Name" - location: "Location" + type: "Type" + optional: "Optional" description: "Description" - birthday: "Birthday" - avatar: "Avatar" - banner: "Banner" - avatar-saved: "Avatar updated successfully" - banner-saved: "Banner updated successfully" - set-avatar: "Choose an avatar" - set-banner: "Choose a banner" - save: "Save" - saved: "Profile updated successfully" - - mk-user-followers-page: - followers-of: "Followers of {}" - - mk-user-following-page: - following-of: "Following of {}" - - mk-drive-folder-selector: - select-folder: "Choose a folder" - - mk-drive-selector: - select-file: "Choose a file" - - mk-drive: - drive: "Drive" - used: "used" - folder-count: "Folder(s)" - count-separator: ", " - file-count: "File(s)" - load-more: "Load more" - nothing-in-drive: "Nothing" - folder-is-empty: "This folder is empty" - - mk-follow-button: - follow: "Follow" - unfollow: "Unfollow" - - mk-home-timeline: - empty-timeline: "There is no posts" - - mk-notifications: - more: "More" - empty: "No notifications" - - mk-post-detail: - reply: "Reply" - reaction: "Reaction" - - mk-post-form: - submit: "Post" - reply-placeholder: "Reply to this post..." - post-placeholder: "What's happening?" - attach-media-from-local: "Attach media from your device" - - mk-search-posts: - empty: "There is no post related to the 「{}」" - - mk-sub-post-content: - media-count: "{} media" - poll: "Poll" - - mk-timeline-post: - reposted-by: "Reposted by {}" - - mk-timeline: - empty: "No posts" - load-more: "More" - - mk-ui-nav: - home: "Home" - notifications: "Notifications" - messaging: "Messages" - ch: "Channels" - drive: "Drive" - settings: "Settings" - about: "About Misskey" - search: "Search" - - mk-user-followers: - no-users: "No followers." - - mk-user-following: - no-users: "No following." - - mk-user-timeline: - no-posts: "This user seems never post" - no-posts-with-media: "There is no posts with media" - - mk-user: - follows-you: "Follows you" - following: "Following" - followers: "Followers" - posts: "Posts" - overview: "Overview" - timeline: "Timeline" - media: "Media" - - mk-user-overview: - recent-posts: "Recent posts" - images: "Images" - activity: "Activity" - keywords: "Keywords" - domains: "Domains" - frequently-replied-users: "Frequently talking users" - followers-you-know: "Followers you know" - last-used-at: "Last used at" - - mk-user-overview-posts: - loading: "Loading" - no-posts: "No posts" - - mk-user-overview-photos: - loading: "Loading" - no-photos: "No photos" - - mk-user-overview-keywords: - no-keywords: "No keywords" - - mk-user-overview-domains: - no-domains: "No domains" - - mk-user-overview-frequently-replied-users: - loading: "Loading" - no-users: "No users" - - mk-user-overview-followers-you-know: - loading: "Loading" - no-users: "No users" - - mk-users-list: - all: "All" - known: "You know" - load-more: "More" - -stats: - posts-count: "Number of all posts" - users-count: "Number of all users" - -status: - all-systems-maybe-operational: "All systems maybe operational" - what-is-this-site: "" + yes: "Yes" + no: "No" diff --git a/locales/fr.yml b/locales/fr.yml new file mode 100644 index 000000000..80b1ed13d --- /dev/null +++ b/locales/fr.yml @@ -0,0 +1,649 @@ +common: + misskey: "Partagez avec les autres en utilisant Misskey" + + time: + unknown: "inconnu" + future: "future" + just_now: "maintenant" + seconds_ago: "Il y a {}seconde(s)" + minutes_ago: "Il y a {}minute(s)" + hours_ago: "Il y a {}heure(s)" + days_ago: "Il y a {}jour(s)" + weeks_ago: "Il y a{}semaines(s)" + months_ago: "Il y a {}mois" + years_ago: "Il y a {}an(s)" + + weekday-short: + sunday: "D" + monday: "L" + tuesday: "M" + wednesday: "M" + thursday: "J" + friday: "V" + satruday: "S" + + reactions: + like: "Aime" + love: "Adore" + laugh: "Rire" + hmm: "Hmm...?" + surprise: "Wow" + congrats: "Félicitations!" + angry: "En Colère" + confused: "Confus" + pudding: "Pudding" + + delete: "Supprimer" + loading: "Chargement" + ok: "OK" + update-available: "Une nouvelle version de Misskey est disponible({newer}, version actuelle: {current}). Recharger la page pour appliquer la mise à jour." + my-token-regenerated: "Votre token vient d'être généré, vous allez maintenant être déconnecté." + +common/views/components/connect-failed.vue: + title: "Impossible de se connecter au server." + description: "Il y a soit un problème avec votre connexion internet, soit le serveur est hors-ligne ou en maintenance. Veuillez {ressayer} plus tard." + thanks: "On vous remercie d'utiliser Misskey." + troubleshoot: "dépanner" + +common/views/components/connect-failed.troubleshooter.vue: + title: "Dépannage" + network: "Connexion au réseau" + checking-network: "Vérification de la connexion au réseau" + internet: "Connexion Internet" + checking-internet: "Vérification de la connexion internet" + server: "Connexion au server" + checking-server: "Vérification de la connexion au serveur" + finding: "Recherche d'un problème" + no-network: "Aucune connexion au réseau" + no-network-desc: "Veuillez vérifier que vous êtes bien connecté au réseau." + no-internet: "Aucune connexion internet." + no-internet-desc: "Veuillez vérifier que vous êtes bien connecté à internet." + no-server: "Impossible de se connecter au serveur" + no-server-desc: "Votre connexion est OK, mais il a été impossible de vous connecter au serveur de Misskey. Il y a des chances que le serveur soit hors-ligne ou en maintenance, veuillez ressayer plus tard." + success: "Connexion au serveur de Misskey reussie!" + success-desc: "La connexion au serveur a été reussie. Veuillez recharger la page." + flush: "キャッシュの削除" + set-version: "バージョン指定" + +common/views/components/messaging.vue: + search-user: "Trouver un utilisateur" + you: "Vous" + no-history: "Pas d'historique" + +common/views/components/messaging-room.vue: + empty: "Pas de conversations" + more: "Voir Plus" + no-history: "Il n'y a pas plus d'historique" + resize-form: "Faites glisser pour redimensionner" + new-message: "Nouveau message" + +common/views/components/messaging-room.form.vue: + input-message-here: "Tapez ici votre message" + send: "Envoyer" + attach-from-local: "Joindre un fichier depuis votre PC" + attach-from-drive: "Joindre un fichier depuis votre Drive" + +common/views/components/messaging-room.message.vue: + is-read: "Lu" + deleted: "Ce message a été supprimé" + +common/views/components/nav.vue: + about: "À propos" + stats: "Stats" + status: "Status" + wiki: "Wiki" + donors: "Donateurs" + repository: "Repo" + develop: "Développeurs" + feedback: "フィードバック" + +common/views/components/note-menu.vue: + favorite: "Favorite this note" + pin: "Épingler sur votre profile" + remote: "投稿元で見る" + +common/views/components/poll.vue: + vote-to: "Voter pour '{}'" + vote-count: "{} votes" + total-users: "{} utilisateurs ont voté" + vote: "Vote" + show-result: "Montrer les résultats" + voted: "Voté" + +common/views/components/poll-editor.vue: + no-only-one-choice: "Vous devez entrer au moins deux choix" + choice-n: "Choix {}" + remove: "Supprimer ce choix" + add: "+ Ajouter un choix" + destroy: "Supprimer ce sondage" + +common/views/components/reaction-picker.vue: + choose-reaction: "Choisissez votre réaction" + +common/views/components/signin.vue: + username: "Nom d'utilisateur" + password: "Mot de passe" + token: "Token" + signing-in: "Connexion...." + signin: "Se connecter" + +common/views/components/signup.vue: + username: "Nom d'utilisateur" + checking: "Vérification" + available: "Disponible" + unavailable: "Non disponible" + error: "Erreur de réseau" + invalid-format: "Utilisez seulement des lettres, nombres et/ou -." + too-short: "Veuillez taper au moins un charactère!" + too-long: "Veuillez entrer au maximum 20 charactères." + password: "Mot de Passe" + password-placeholder: "Nous recommendons au moins 8 charactères." + weak-password: "Faible" + normal-password: "Moyen" + strong-password: "Fort" + retype: "Retapez" + retype-placeholder: "Confirmez votre mot de passe" + password-matched: "OK" + password-not-matched: "Les mots de passes ne correspondent pas." + recaptcha: "Vérifier" + create: "Créer un compte" + some-error: "La création de compte a échoué. Veuillez ressayer." + +common/views/components/special-message.vue: + new-year: "Bonne année!" + christmas: "Joyeux Noël!" + +common/views/components/stream-indicator.vue: + connecting: "Connexion en cours" + reconnecting: "Re-connexion en cours" + connected: "Connecté" + +common/views/components/twitter-setting.vue: + description: "Si vous liez votre compte Twitter à votre compte Misskey, vous verrez ensuite votre compte Twitter s'afficher sur votre profile, vous aurez aussi la possibilité de vous connecter à Misskey en utilisant votre compte Twitter." + connected-to: "Vous êtes connecté à ce compte" + detail: "Detail..." + reconnect: "Reconnecter" + connect: "Lier votre compte Twitter" + disconnect: "Deconnecter" + +common/views/components/uploader.vue: + waiting: "En attente" + +common/views/widgets/broadcast.vue: + fetching: "Récuperation" + no-broadcasts: "No broadcasts" + have-a-nice-day: "Passez une bonne journée!" + next: "Suivant" + +common/views/widgets/donation.vue: + title: "Dons" + text: "Toutes les depences pour couvrir les frais de Misskey sortent directement de notre poche. Nous ne recevons pas d'argent, si vous pouvez nous faire dons d'argent, on vous serait eternellement reconnaissant. Si vous êtes intéressés veuilles contacter {}. Merci pour votre contribution!" + +common/views/widgets/photo-stream.vue: + title: "Flux de photo" + no-photos: "Pas de photos" + +common/views/widgets/server.vue: + title: "Info sur le serveur" + toggle: "Afficher les vues" + +desktop/views/components/activity.vue: + title: "Activitié" + toggle: "Afficher les vues" + +desktop/views/components/calendar.vue: + title: "{1} / {2}" + prev: "Mois dernier" + next: "Mois prochain" + go: "Cliquer pour naviguer" + +desktop/views/components/drive-window.vue: + used: "utilisé" + drive: "Drive" + +desktop/views/components/drive.file.vue: + avatar: "Avatar" + banner: "Bannière" + contextmenu: + rename: "Renommer" + copy-url: "Copier l'URL" + download: "Télécharger" + else-files: "Autres..." + set-as-avatar: "Utiliser en tant qu'avatar" + set-as-banner: "Utiliser en tant que bannière" + open-in-app: "Ouvrir dans l'application" + add-app: "Ajouter une application" + rename-file: "Renommer le ficher" + input-new-file-name: "Entrer un nouveau nom" + copied: "Copied" + copied-url-to-clipboard: "L'URL a été copié dans le presse-papier" + +desktop/views/components/drive.folder.vue: + unable-to-process: "L'opération n'a pas pu être complétée" + circular-reference-detected: "Le dossier de destination est un sous-dossier du dossier que vous souhaitez déplacer." + unhandled-error: "Erreur inconnue" + contextmenu: + move-to-this-folder: "Bouger dans ce dossier" + show-in-new-window: "Ouvrir dans une nouvelle fenêtre" + rename: "Renommer" + rename-folder: "Renommer le dossier" + input-new-folder-name: "Entrer un nouveau nom" + +desktop/views/components/drive.nav-folder.vue: + drive: "Drive" + +desktop/views/components/drive.vue: + search: "Rechercher" + load-more: "Afficher plus" + empty-draghover: "Drop Welcome!" + empty-drive: "Votre Drive est vide" + empty-drive-description: "Vous pouvez également uploader le fichier en faisant un clic droit et en choisissant 'Uploader' ou tout simplement en faisant glisser votre fichier." + empty-folder: "Ce dossier est vide" + unable-to-process: "L'opération n'a pas pu être complétée" + circular-reference-detected: "Le dossier de destination est un sous-dossier du dossier que vous souhaitez déplacer." + unhandled-error: "Erreur inconnue" + url-upload: "Uploader d'un URL" + url-of-file: "URL de l'image que vous souhaitez uploader." + url-upload-requested: "Upload requested" + may-take-time: "L'upload de votre fichier peut prendre un certain temps." + create-folder: "Créer un dossier" + folder-name: "Nom du dossier" + contextmenu: + create-folder: "Créer un dossier" + upload: "Uploader un fichier" + url-upload: "Uploader d'un URL" + +desktop/views/components/messaging-window.vue: + title: "Messagerie" + +desktop/views/components/notes.note.vue: + reposted-by: "Reposté par {}" + reply: "Répondre" + renote: "Renote" + add-reaction: "Ajouter votre reaction" + detail: "Afficher les détails" + +desktop/views/components/notifications.vue: + more: "Plus" + empty: "Pas de notifications" + +desktop/views/components/post-form.vue: + note-placeholder: "Qu'est-ce qui se passe?" + reply-placeholder: "Répondre à cette note" + quote-placeholder: "Citer cette note" + note: "Poster" + reply: "Répondre" + renote: "Renote" + posted: "Posté!" + replied: "Répondu!" + reposted: "Reposté!" + note-failed: "La note à échoué" + reply-failed: "La réponse à échoué" + renote-failed: "La renote à échoué" + posting: "Publication..." + attach-media-from-local: "Joindre un media depuis votre PC" + attach-media-from-drive: "Joindre un media depuis votre Drive" + attach-cancel: "Annuler la jointure de fichier" + insert-a-kao: "v(‘ω’)v" + create-poll: "Créer un sondage" + text-remain: "{} charactères restants" + +desktop/views/components/post-form-window.vue: + note: "Nouvelle note" + reply: "Répondre" + attaches: "{} media joint(s)" + uploading-media: "Upload du media {}" + +desktop/views/components/renote-form.vue: + quote: "Citer..." + cancel: "Annuler" + renote: "Renote" + reposting: "Repost en cours..." + success: "Reposté!" + failure: "La renote a échoué" + +desktop/views/components/renote-form-window.vue: + title: "Êtes vous sûr de vouloir renote cette note?" + +desktop/views/components/settings.vue: + profile: "Profil" + notification: "Notification" + apps: "Applications" + mute: "Mettre en sourdine" + drive: "Drive" + security: "Sécurité" + password: "Mot de Passe" + 2fa: "Vérification en deux étapes" + other: "Autres" + license: "License" + +desktop/views/components/settings.2fa.vue: + intro: "Si vous configurez la vérication en deux étapes vous aurez non seulement besoin de votre mot de passe mais aussi un appareil déjà pré-enregistré(tel que votre smartphone) ce qui ameliora grandement la sécurité de votre compte." + detail: "Voir les détails..." + url: "https://www.google.com/landing/2step/" + caution: "Activer la vérification en deux étapes vient aussi avec des contraintes, si vous perdez votre appareil ou ne pouvez tout simplement plus y accèder vous ne serez plus en mesure de vous connecter à Misskey." + register: "Enregistrer un appareil" + already-registered: "Cette étape à déjà été complétée" + unregister: "Désactiver" + unregistered: "La vérication en deux étapes a été desactivée" + enter-password: "Entrez un mot de passe" + authenticator: "Tout d'abord vous devez installer Google Authenticator sur votre appareil" + howtoinstall: "Comment installer" + scan: "Ensuite scannez le QR code afficher sur votre écran:" + done: "Veuillez entrer le token qui s'affiche sur votre appareil:" + submit: "Envoyer" + success: "L'operation a été complétée avec succès!" + failed: "L'operation a échoué. Veuillez vous assurer que le token a été entrer correctement." + info: "À partir de maintenant, à chaque fois que vous vous connecter entrez votre mot de passe ainsi que le token généré sur votre appareil." + +desktop/views/components/settings.api.vue: + intro: "APIを利用するには、上記のトークンを「i」というキーでパラメータに付加してリクエストします。" + caution: "アカウントを不正利用される可能性があるため、このトークンは第三者に教えないでください(アプリなどにも入力しないでください)。" + regeneration-of-token: "万が一このトークンが漏れたりその可能性がある場合はトークンを再生成できます。" + regenerate-token: "Regenerer le token" + enter-password: "Veuillez entrer le mot de passe" + +desktop/views/components/settings.app.vue: + no-apps: "Aucune application authorisée" + +desktop/views/components/settings.mute.vue: + no-users: "Aucun utilisateurs mis en sourdine" + +desktop/views/components/settings.password.vue: + reset: "Changer votre mot de passe" + enter-current-password: "Entrez votre mot de passe actuel" + enter-new-password: "Entrez votre nouveau mot de passe" + enter-new-password-again: "Entrez à nouveau le nouveau mot de passe" + not-match: "Le nouveau mot de passe ne correspond pas." + changed: "Mot de passe modifié avec succès" + +desktop/views/components/settings.profile.vue: + avatar: "Avatar" + choice-avatar: "Choose an image" + name: "Nom" + location: "Localisation" + description: "Description" + birthday: "Date de naissance" + save: "Mettre à jour le profil" + +desktop/views/components/ui.header.account.vue: + profile: "Votre profil" + drive: "Drive" + favorites: "Favorites" + lists: "リスト" + customize: "Modifications" + settings: "Réglages" + signout: "Déconnexion" + dark: "Fall in dark" + +desktop/views/components/ui.header.nav.vue: + home: "Accueil" + messaging: "Messages" + game: "Jeux" + +desktop/views/components/ui.header.notifications.vue: + title: "Notifications" + +desktop/views/components/ui.header.post.vue: + post: "Composer un nouveau post" + +desktop/views/components/ui.header.search.vue: + placeholder: "Chercher" + +desktop/views/pages/note.vue: + prev: "Note précédente" + next: "Note suivante" + +desktop/views/pages/selectdrive.vue: + title: "Choisir fichier(s)" + ok: "OK" + cancel: "Annuler" + upload: "Uploader un ou plusieurs fichier(s) depuis votre PC" + +desktop/views/pages/user/user.followers-you-know.vue: + title: "Abonnés que vous connaissez" + loading: "Chargement en cours" + no-users: "Pas d'utilisateurs" + +desktop/views/pages/user/user.friends.vue: + title: "Personnes qui répondent le plus" + loading: "Chargement en cours" + no-users: "Pas d'utilisateurs" + +desktop/views/pages/user/user.header.vue: + is-suspended: "This account has been suspended." + is-remote: "Cet utilisateur n'est pas un utilisateur de Misskey. Certaines informations peuvent être erronées " + view-remote: "Voir les informations détaillées" + +desktop/views/pages/user/user.home.vue: + last-used-at: "Last used at" + +desktop/views/pages/user/user.photos.vue: + title: "Photos" + loading: "Chargement en cours" + no-photos: "Pas de photos" + +desktop/views/pages/user/user.profile.vue: + follows-you: "Vous suis" + stalk: "ストークする" + stalking: "ストーキングしています" + unstalk: "ストーク解除" + mute: "Mettre en sourdine" + muted: "Muting" + unmute: "Enlever la sourdine" + +desktop/views/widgets/messaging.vue: + title: "Messagerie" + +desktop/views/widgets/notifications.vue: + title: "Notifications" + settings: "Réglages" + +desktop/views/widgets/polls.vue: + title: "Sondages" + refresh: "Afficher d'autres" + nothing: "Rien" + +desktop/views/widgets/post-form.vue: + title: "Post" + note: "Post" + placeholder: "Qu'est-ce qu'il se passe?" + +desktop/views/widgets/trends.vue: + title: "Tendances" + refresh: "Afficher d'autres" + nothing: "Rien" + +desktop/views/widgets/users.vue: + title: "Utilisateurs" + refresh: "Afficher d'autres" + no-one: "Personne" + +desktop/views/widgets/channel.vue: + title: "Cannal" + settings: "Réglages des widgets" + get-started: "Veuillez cliquer sur la dent en haute à droite pour choisir un channel" + +mobile/views/components/drive.vue: + drive: "Drive" + used: "utilisé" + folder-count: "Dossier(s)" + count-separator: ", " + file-count: "Fichiers(s)" + load-more: "Charger plus" + nothing-in-drive: "Rien" + folder-is-empty: "Ce dossier est vide" + +mobile/views/components/drive-file-chooser.vue: + select-file: "Choisissez un fichier" + +mobile/views/components/drive-folder-chooser.vue: + select-folder: "Choisissez un dossier" + +mobile/views/components/drive.file-detail.vue: + download: "Télécharger" + rename: "Renommer" + move: "Déplacer" + hash: "Hash (md5)" + exif: "EXIF" + +mobile/views/components/follow-button.vue: + follow: "Suivre" + unfollow: "Ne plus suivre" + +mobile/views/components/note.vue: + reposted-by: "Renoté par {}" + +mobile/views/components/note-detail.vue: + reply: "Répondre" + reaction: "Réaction" + +mobile/views/components/notifications.vue: + more: "Plus" + empty: "Pas de notifications" + +mobile/views/components/post-form.vue: + submit: "Poster" + reply-placeholder: "Répondre à cette note" + note-placeholder: "Qu'est-ce qu'il se passe?" + +mobile/views/components/sub-note-content.vue: + media-count: "{} media" + poll: "Sondage" + +mobile/views/components/timeline.vue: + empty: "Pas de notes" + load-more: "Afficher plus" + +mobile/views/components/ui.nav.vue: + home: "Accueil" + notifications: "Notifications" + messaging: "Messages" + drive: "Drive" + settings: "Réglages" + about: "À propose de Misskey" + search: "Rechercher" + +mobile/views/components/user-timeline.vue: + no-notes: "Cette utilisateur semble n'avoir rien poster pour le moment" + no-notes-with-media: "Aucune notes avec des médias" + load-more: "Afficher Plus" + +mobile/views/components/users-list.vue: + all: "Tout" + known: "Vous connaissez" + load-more: "Afficher plus" + +mobile/views/pages/drive.vue: + drive: "Drive" + +mobile/views/pages/followers.vue: + followers-of: "Abonnés de {}" + +mobile/views/pages/following.vue: + following-of: "Abonnements de {}" + +mobile/views/pages/home.vue: + timeline: "Fil d'actualité" + +mobile/views/pages/messaging.vue: + messaging: "Messagerie" + +mobile/views/pages/messaging-room.vue: + messaging: "Messagerie" + +mobile/views/pages/note.vue: + title: "Post" + prev: "Note précedante" + next: "Note suivante" + +mobile/views/pages/notifications.vue: + notifications: "Notifications" + read-all: "Êtes vous sûr de vouloir marqués toutes les notifications non-lus en tant que lus?" + +mobile/views/pages/profile-setting.vue: + title: "Réglages du profiles" + will-be-published: "Ces profiles vont être publier" + name: "Nom" + location: "Localisation" + description: "Description" + birthday: "Anniversaire" + avatar: "Avatar" + banner: "Bannière" + avatar-saved: "Avatar mis à jour avec succès!" + banner-saved: "Bannière mise à jour avec succès!" + set-avatar: "Choisir un avatar" + set-banner: "Choisir une bannière" + save: "Sauvegarder" + saved: "Profil mis à jour avec succès" + +mobile/views/pages/search.vue: + search: "Chercher" + empty: "Aucun message trouvé pour '{}' " + +mobile/views/pages/selectdrive.vue: + select-file: "Choisissez un fichier" + +mobile/views/pages/settings.vue: + signed-in-as: "Connecté en tant que {}" + profile: "Profile" + twitter-integration: "Twitter integration" + signin-history: "Historique de connexion" + settings: "Réglages" + signout: "Déconnexion" + +mobile/views/pages/user.vue: + follows-you: "vous suit" + following: "Abonnements" + followers: "Abonnés" + notes: "Posts" + overview: "Aperçu" + timeline: "Fil d'actualité" + media: "Media" + is-suspended: "This account has been suspended." + is-remote: "Cet utilisateur n'est pas un utilisateur de Misskey. Certaines informations peuvent être erronées " + view-remote: "Voir les informations détaillées" + +mobile/views/pages/user/home.vue: + recent-notes: "Notes récentes" + images: "Images" + activity: "Activité" + keywords: "Mot clés" + domains: "Domaines" + frequently-replied-users: "Utilisateurs qui interagissent souvent" + followers-you-know: "Abonnés que vous connaissez" + last-used-at: "Dernière connexion il y a" + +mobile/views/pages/user/home.followers-you-know.vue: + loading: "Chargement" + no-users: "Pas d'utilisateurs" + +mobile/views/pages/user/home.friends.vue: + loading: "Chargement" + no-users: "Pass d'utilisateurs" + +mobile/views/pages/user/home.notes.vue: + loading: "Chargement" + no-notes: "Pas de notes" + +mobile/views/pages/user/home.photos.vue: + loading: "Chargement" + no-photos: "Pas de photos" + +docs: + edit-this-page-on-github: "Vous avez trouvé une erreur ou vous voulez contribuer à la documentation?" + edit-this-page-on-github-link: "Modifiez cette page sur github!" + + api: + entities: + properties: "Propriétés" + endpoints: + params: "Paramètres" + res: "Réponse" + props: + name: "Nom" + type: "Type" + optional: "Optionel" + description: "Description" + yes: "Oui" + no: "Non" diff --git a/webpack/langs.ts b/locales/index.ts similarity index 80% rename from webpack/langs.ts rename to locales/index.ts index 409b25504..6e76f3917 100644 --- a/webpack/langs.ts +++ b/locales/index.ts @@ -10,12 +10,13 @@ const loadLang = lang => yaml.safeLoad( const native = loadLang('ja'); -const langs = Object.entries({ +const langs = { 'en': loadLang('en'), + 'fr': loadLang('fr'), 'ja': native -}); +}; -langs.map(([, locale]) => { +Object.entries(langs).map(([, locale]) => { // Extend native language (Japanese) locale = Object.assign({}, native, locale); }); diff --git a/locales/ja.yml b/locales/ja.yml index dcf466339..e13348c40 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -1,5 +1,5 @@ common: - misskey: "Misskeyに何でも投稿して皆と共有しましょう。" + misskey: "Misskeyで皆と共有しよう。" time: unknown: "なぞのじかん" @@ -24,7 +24,7 @@ common: reactions: like: "いいね" - love: "ハート" + love: "しゅき" laugh: "笑" hmm: "ふぅ~む" surprise: "わお" @@ -33,613 +33,617 @@ common: confused: "こまこまのこまり" pudding: "Pudding" - post_categories: - music: "音楽" - game: "ゲーム" - anime: "アニメ" - it: "IT" - gadgets: "ガジェット" - photography: "写真" - - input-message-here: "ここにメッセージを入力" - send: "送信" delete: "削除" loading: "読み込み中" ok: "わかった" update-available: "Misskeyの新しいバージョンがあります({newer}。現在{current}を利用中)。ページを再度読み込みすると更新が適用されます。" my-token-regenerated: "あなたのトークンが更新されたのでサインアウトします。" - tags: - mk-nav-links: - about: "Misskeyについて" - stats: "統計" - status: "ステータス" - wiki: "Wiki" - donors: "ドナー" - repository: "リポジトリ" - develop: "開発者" - - mk-messaging-form: - attach-from-local: "PCからファイルを添付する" - attach-from-drive: "ドライブからファイルを添付する" - - mk-messaging: - search-user: "ユーザーを探す" - you: "あなた" - no-history: "履歴はありません" - - mk-messaging-message: - is-read: "既読" - deleted: "このメッセージは削除されました" - - mk-messaging-room: - empty: "このユーザーと話したことはありません" - more: "もっと読む" - no-history: "これより過去の履歴はありません" - resize-form: "ドラッグしてフォームの広さを調整" - new-message: "新しいメッセージがあります" - - mk-authorized-apps: - no-apps: "連携しているアプリケーションはありません" - - mk-error: - title: "サーバーに接続できません" - description: "インターネット回線に問題があるか、サーバーがダウンまたはメンテナンスしている可能性があります。しばらくしてから{再度お試し}ください。" - thanks: "いつもMisskeyをご利用いただきありがとうございます。" - troubleshoot: "トラブルシュート" - - troubleshooter: - title: "トラブルシューティング" - network: "ネットワーク接続" - checking-network: "ネットワーク接続を確認中" - internet: "インターネット接続" - checking-internet: "インターネット接続を確認中" - server: "サーバー接続" - checking-server: "サーバー接続を確認中" - finding: "問題を調べています" - no-network: "ネットワークに接続されていません" - no-network-desc: "お使いのPCのネットワーク接続が正常か確認してください。" - no-internet: "インターネットに接続されていません" - no-internet-desc: "ネットワークには接続されていますが、インターネットには接続されていないようです。お使いのPCのインターネット接続が正常か確認してください。" - no-server: "Misskeyのサーバーに接続できません" - no-server-desc: "お使いのPCのインターネット接続は正常ですが、Misskeyのサーバーには接続できませんでした。サーバーがダウンまたはメンテナンスしている可能性があるので、しばらくしてから再度御アクセスください。" - success: "Misskeyのサーバーに接続できました" - success-desc: "正常に接続できるようです。ページを再度読み込みしてください。" - - mk-forkit: - open-github-link: "View source on Github" - - mk-poll-editor: - no-only-one-choice: "投票には、選択肢が最低2つ必要です" - choice-n: "選択肢{}" - remove: "この選択肢を削除" - add: "+選択肢を追加" - destroy: "投票を破棄" - - mk-poll: - vote-to: "「{}」に投票する" - vote-count: "{}票" - total-users: "{}人が投票" - vote: "投票する" - show-result: "結果を見る" - voted: "投票済み" - - mk-post-menu: - pin: "ピン留め" - pinned: "ピン留めしました" - select: "カテゴリを選択" - categorize: "決定" - categorized: "カテゴリを報告しました。これによりMisskeyが賢くなり、投稿の自動カテゴライズに役立てられます。ご協力ありがとうございました。" - - mk-reaction-picker: - choose-reaction: "リアクションを選択" - - mk-signin: - username: "ユーザー名" - password: "パスワード" - signing-in: "やってます..." - signin: "サインイン" - - mk-signup: - username: "ユーザー名" - checking: "確認しています..." - available: "利用できます" - unavailable: "既に利用されています" - error: "通信エラー" - invalid-format: "a~z、A~Z、0~9、-(ハイフン)が使えます" - too-short: "3文字以上でお願いします!" - too-long: "20文字以内でお願いします" - password: "パスワード" - password-placeholder: "8文字以上を推奨します" - weak-password: "弱いパスワード" - normal-password: "まあまあのパスワード" - strong-password: "強いパスワード" - retype: "再入力" - retype-placeholder: "確認のため再入力してください" - password-matched: "確認されました" - password-not-matched: "一致していません" - recaptcha: "認証" - create: "アカウント作成" - some-error: "何らかの原因によりアカウントの作成に失敗しました。再度お試しください。" - - mk-special-message: - new-year: "Happy New Year!" - christmas: "Merry Christmas!" - - mk-stream-indicator: - connecting: "接続中" - reconnecting: "再接続中" - connected: "接続完了" - - mk-twitter-setting: - description: "お使いのTwitterアカウントをお使いのMisskeyアカウントに接続しておくと、プロフィールでTwitterアカウント情報が表示されるようになったり、Twitterを用いた便利なサインインを利用できるようになります。" - connected-to: "次のTwitterアカウントに接続されています" - detail: "詳細..." - reconnect: "再接続する" - connect: "Twitterと接続する" - disconnect: "切断する" - - mk-uploader: - waiting: "待機中" - -ch: - tags: - mk-index: - new: "チャンネルを作成" - channel-title: "チャンネルのタイトル" - - mk-channel-form: - textarea: "書いて" - upload: "アップロード" - drive: "ドライブ" - post: "やる" - posting: "やってます" - -desktop: - tags: - mk-api-info: - regenerate-token: "パスワードを入力してください" - - mk-drive-browser-base-contextmenu: - create-folder: "フォルダーを作成" - upload: "ファイルをアップロード" - url-upload: "URLからアップロード" - - mk-drive-browser-window: - used: "使用中" - drive: "ドライブ" - - mk-drive-browser: - search: "検索" - load-more: "もっと読み込む" - empty-draghover: "ドロップですか?いいですよ、ボクはカワイイですからね" - empty-drive: "ドライブには何もありません。" - empty-drive-description: "右クリックして「ファイルをアップロード」を選んだり、ファイルをドラッグ&ドロップすることでもアップロードできます。" - empty-folder: "このフォルダーは空です" - unable-to-process: "操作を完了できません" - circular-reference-detected: "移動先のフォルダーは、移動するフォルダーのサブフォルダーです。" - unhandled-error: "不明なエラー" - url-upload: "URLアップロード" - url-of-file: "アップロードしたいファイルのURL" - url-upload-requested: "アップロードをリクエストしました" - may-take-time: "アップロードが完了するまで時間がかかる場合があります。" - create-folder: "フォルダー作成" - folder-name: "フォルダー名" - - mk-drive-browser-file-contextmenu: - rename: "名前を変更" - copy-url: "URLをコピー" - download: "ダウンロード" - else-files: "その他..." - set-as-avatar: "アバターに設定" - set-as-banner: "バナーに設定" - open-in-app: "アプリで開く" - add-app: "アプリを追加" - rename-file: "ファイル名の変更" - input-new-file-name: "新しいファイル名を入力してください" - copied: "コピー完了" - copied-url-to-clipboard: "URLをクリップボードにコピーしました" - - mk-drive-browser-file: - avatar: "アバター" - banner: "バナー" - - mk-drive-browser-folder-contextmenu: - move-to-this-folder: "このフォルダへ移動" - show-in-new-window: "新しいウィンドウで表示" - rename: "名前を変更" - rename-folder: "フォルダ名の変更" - input-new-folder-name: "新しいフォルダ名を入力してください" - - mk-drive-browser-folder: - unable-to-process: "操作を完了できません" - circular-reference-detected: "移動先のフォルダーは、移動するフォルダーのサブフォルダーです。" - unhandled-error: "不明なエラー" - - mk-drive-browser-nav-folder: - drive: "ドライブ" - - mk-selectdrive-page: - title: "ファイルを選択してください" - ok: "決定" - cancel: "キャンセル" - upload: "PCからドライブにファイルをアップロード" - - mk-ui-header-nav: - home: "ホーム" - messaging: "メッセージ" - ch: "チャンネル" - info: "お知らせ" - - mk-ui-header-search: - placeholder: "検索" - - mk-ui-header-account: - profile: "プロフィール" - drive: "ドライブ" - mentions: "あなた宛て" - settings: "設定" - signout: "サインアウト" - - mk-ui-header-post-button: - post: "新規投稿" - - mk-ui-header-notifications: - title: "通知" - - mk-password-setting: - reset: "パスワードを変更する" - enter-current-password: "現在のパスワードを入力してください" - enter-new-password: "新しいパスワードを入力してください" - enter-new-password-again: "もう一度新しいパスワードを入力してください" - not-match: "新しいパスワードが一致しません" - changed: "パスワードを変更しました" - - mk-post-form: - post-placeholder: "いまどうしてる?" - reply-placeholder: "この投稿への返信..." - quote-placeholder: "この投稿を引用..." - post: "投稿" - reply: "返信" - repost: "Repost" - posted: "投稿しました!" - replied: "返信しました!" - reposted: "Repostしました!" - post-failed: "投稿に失敗しました" - reply-failed: "返信に失敗しました" - repost-failed: "Repostに失敗しました" - posting: "投稿中" - attach-media-from-local: "PCからメディアを添付" - attach-media-from-drive: "ドライブからメディアを添付" - attach-cancel: "添付取り消し" - insert-a-kao: "v(‘ω’)v" - create-poll: "投票を作成" - text-remain: "のこり{}文字" - - mk-post-form-window: - post: "新規投稿" - reply: "返信" - attaches: "添付: {}メディア" - uploading-media: "{}個のメディアをアップロード中" - - mk-post-page: - prev: "前の投稿" - next: "次の投稿" - - mk-settings: - password: "パスワード" - - mk-timeline-post: - reposted-by: "{}がRepost" - reply: "返信" - repost: "Repost" - add-reaction: "リアクション" - detail: "詳細" - - mk-notifications: - more: "もっと見る" - - mk-notifications-home-widget: - title: "通知" - settings: "通知の設定" - - mk-server-home-widget: - title: "サーバー情報" - toggle: "表示を切り替え" - - mk-activity-widget: - title: "アクティビティ" - toggle: "表示を切り替え" - - mk-user-recommendation-home-widget: - title: "おすすめユーザー" - refresh: "他を見る" - no-one: "いません!" - - mk-recommended-polls-home-widget: - title: "投票" - refresh: "他を見る" - nothing: "ありません!" - - mk-trends-home-widget: - title: "トレンド" - refresh: "他を見る" - nothing: "ありません!" - - mk-photo-stream-home-widget: - title: "フォトストリーム" - no-photos: "写真はありません" - - mk-donation-home-widget: - title: "寄付のお願い" - text: "Misskeyの運営にはドメイン、サーバー等のコストが掛かります。Misskeyは広告を掲載したりしないため、収入を皆様からの寄付に頼っています。もしご興味があれば、{}までご連絡ください。ご協力ありがとうございます。" - - mk-channel-home-widget: - title: "チャンネル" - settings: "ウィジェットの設定" - get-started: "右上の歯車をクリックして受信するチャンネルを指定してください" - - mk-calendar-widget: - title: "{1}年 {2}月" - prev: "先月" - next: "来月" - go: "クリックして時間遡行" - - mk-post-form-home-widget: - title: "投稿" - post: "投稿" - placeholder: "いまどうしてる?" - - mk-access-log-home-widget: - title: "アクセスログ" - - mk-messaging-home-widget: - title: "メッセージ" - - mk-broadcast-home-widget: - fetching: "確認中" - no-broadcasts: "お知らせはありません" - have-a-nice-day: "良い一日を!" - next: "次" - - mk-repost-form: - quote: "引用する..." - cancel: "キャンセル" - repost: "Repost" - reposting: "しています..." - success: "Repostしました!" - failure: "Repostに失敗しました" - - mk-repost-form-window: - title: "この投稿をRepostしますか?" - - mk-user: - last-used-at: "最終アクセス" - - photos: - title: "フォト" - loading: "読み込み中" - no-photos: "写真はありません" - - frequently-replied-users: - title: "よく話すユーザー" - loading: "読み込み中" - no-users: "よく話すユーザーはいません" - - followers-you-know: - title: "知り合いのフォロワー" - loading: "読み込み中" - no-users: "知り合いのフォロワーはいません" - -mobile: - tags: - mk-selectdrive-page: - select-file: "ファイルを選択" - - mk-drive-file-viewer: - download: "ダウンロード" - rename: "名前を変更" - move: "移動" - hash: "ハッシュ (md5)" - - mk-entrance-signin: - signup: "新規登録" - about: "Misskeyについて" - - mk-entrance-signup: - cancel: "キャンセル" - - mk-authorized-apps-page: - application: "アプリケーション" - - mk-signin-history-page: - signin-history: "ログイン履歴" - - mk-twitter-setting-page: - twitter-integration: "Twitter連携" - - mk-drive-page: - drive: "ドライブ" - - mk-home: - home: "ホーム" - - mk-messaging-room-page: - message: "メッセージ" - - mk-messaging-page: - message: "メッセージ" - - mk-notifications-page: - notifications: "通知" - read-all: "すべての通知を既読にしますか?" - - mk-post-page: - title: "投稿" - prev: "前の投稿" - next: "次の投稿" - - mk-search-page: - search: "検索" - - mk-settings: - signed-in-as: "{}としてサインイン中" - - mk-settings-page: - profile: "プロフィール" - applications: "アプリケーション" - twitter-integration: "Twitter連携" - signin-history: "ログイン履歴" - api: "API" - link: "Misskeyリンク" - settings: "設定" - signout: "サインアウト" - - mk-profile-setting-page: - title: "プロフィール設定" - - mk-profile-setting: - will-be-published: "これらのプロフィールは公開されます。" +common/views/components/connect-failed.vue: + title: "サーバーに接続できません" + description: "インターネット回線に問題があるか、サーバーがダウンまたはメンテナンスしている可能性があります。しばらくしてから{再度お試し}ください。" + thanks: "いつもMisskeyをご利用いただきありがとうございます。" + troubleshoot: "トラブルシュート" + +common/views/components/connect-failed.troubleshooter.vue: + title: "トラブルシューティング" + network: "ネットワーク接続" + checking-network: "ネットワーク接続を確認中" + internet: "インターネット接続" + checking-internet: "インターネット接続を確認中" + server: "サーバー接続" + checking-server: "サーバー接続を確認中" + finding: "問題を調べています" + no-network: "ネットワークに接続されていません" + no-network-desc: "お使いのPCのネットワーク接続が正常か確認してください。" + no-internet: "インターネットに接続されていません" + no-internet-desc: "ネットワークには接続されていますが、インターネットには接続されていないようです。お使いのPCのインターネット接続が正常か確認してください。" + no-server: "Misskeyのサーバーに接続できません" + no-server-desc: "お使いのPCのインターネット接続は正常ですが、Misskeyのサーバーには接続できませんでした。サーバーがダウンまたはメンテナンスしている可能性があるので、しばらくしてから再度御アクセスください。" + success: "Misskeyのサーバーに接続できました" + success-desc: "正常に接続できるようです。ページを再度読み込みしてください。" + flush: "キャッシュの削除" + set-version: "バージョン指定" + +common/views/components/messaging.vue: + search-user: "ユーザーを探す" + you: "あなた" + no-history: "履歴はありません" + +common/views/components/messaging-room.vue: + empty: "このユーザーと話したことはありません" + more: "もっと読む" + no-history: "これより過去の履歴はありません" + resize-form: "ドラッグしてフォームの広さを調整" + new-message: "新しいメッセージがあります" + +common/views/components/messaging-room.form.vue: + input-message-here: "ここにメッセージを入力" + send: "送信" + attach-from-local: "PCからファイルを添付する" + attach-from-drive: "ドライブからファイルを添付する" + +common/views/components/messaging-room.message.vue: + is-read: "既読" + deleted: "このメッセージは削除されました" + +common/views/components/nav.vue: + about: "Misskeyについて" + stats: "統計" + status: "ステータス" + wiki: "Wiki" + donors: "ドナー" + repository: "リポジトリ" + develop: "開発者" + feedback: "フィードバック" + +common/views/components/note-menu.vue: + favorite: "お気に入り" + pin: "ピン留め" + remote: "投稿元で見る" + +common/views/components/poll.vue: + vote-to: "「{}」に投票する" + vote-count: "{}票" + total-users: "{}人が投票" + vote: "投票する" + show-result: "結果を見る" + voted: "投票済み" + +common/views/components/poll-editor.vue: + no-only-one-choice: "投票には、選択肢が最低2つ必要です" + choice-n: "選択肢{}" + remove: "この選択肢を削除" + add: "+選択肢を追加" + destroy: "投票を破棄" + +common/views/components/reaction-picker.vue: + choose-reaction: "リアクションを選択" + +common/views/components/signin.vue: + username: "ユーザー名" + password: "パスワード" + token: "トークン" + signing-in: "やってます..." + signin: "サインイン" + +common/views/components/signup.vue: + username: "ユーザー名" + checking: "確認しています..." + available: "利用できます" + unavailable: "既に利用されています" + error: "通信エラー" + invalid-format: "a~z、A~Z、0~9、_が使えます" + too-short: "1文字以上でお願いします!" + too-long: "20文字以内でお願いします" + password: "パスワード" + password-placeholder: "8文字以上を推奨します" + weak-password: "弱いパスワード" + normal-password: "まあまあのパスワード" + strong-password: "強いパスワード" + retype: "再入力" + retype-placeholder: "確認のため再入力してください" + password-matched: "確認されました" + password-not-matched: "一致していません" + recaptcha: "認証" + create: "アカウント作成" + some-error: "何らかの原因によりアカウントの作成に失敗しました。再度お試しください。" + +common/views/components/special-message.vue: + new-year: "Happy New Year!" + christmas: "Merry Christmas!" + +common/views/components/stream-indicator.vue: + connecting: "接続中" + reconnecting: "再接続中" + connected: "接続完了" + +common/views/components/twitter-setting.vue: + description: "お使いのTwitterアカウントをお使いのMisskeyアカウントに接続しておくと、プロフィールでTwitterアカウント情報が表示されるようになったり、Twitterを用いた便利なサインインを利用できるようになります。" + connected-to: "次のTwitterアカウントに接続されています" + detail: "詳細..." + reconnect: "再接続する" + connect: "Twitterと接続する" + disconnect: "切断する" + +common/views/components/uploader.vue: + waiting: "待機中" + +common/views/widgets/broadcast.vue: + fetching: "確認中" + no-broadcasts: "お知らせはありません" + have-a-nice-day: "良い一日を!" + next: "次" + +common/views/widgets/donation.vue: + title: "寄付のお願い" + text: "Misskeyの運営にはドメイン、サーバー等のコストが掛かります。Misskeyは広告を掲載したりしないため、収入を皆様からの寄付に頼っています。もしご興味があれば、{}までご連絡ください。ご協力ありがとうございます。" + +common/views/widgets/photo-stream.vue: + title: "フォトストリーム" + no-photos: "写真はありません" + +common/views/widgets/server.vue: + title: "サーバー情報" + toggle: "表示を切り替え" + +desktop/views/components/activity.vue: + title: "アクティビティ" + toggle: "表示を切り替え" + +desktop/views/components/calendar.vue: + title: "{1}年 {2}月" + prev: "前の月" + next: "次の月" + go: "クリックして時間遡行" + +desktop/views/components/drive-window.vue: + used: "使用中" + drive: "ドライブ" + +desktop/views/components/drive.file.vue: + avatar: "アイコン" + banner: "バナー" + contextmenu: + rename: "名前を変更" + copy-url: "URLをコピー" + download: "ダウンロード" + else-files: "その他..." + set-as-avatar: "アイコンに設定" + set-as-banner: "バナーに設定" + open-in-app: "アプリで開く" + add-app: "アプリを追加" + rename-file: "ファイル名の変更" + input-new-file-name: "新しいファイル名を入力してください" + copied: "コピー完了" + copied-url-to-clipboard: "URLをクリップボードにコピーしました" + +desktop/views/components/drive.folder.vue: + unable-to-process: "操作を完了できません" + circular-reference-detected: "移動先のフォルダーは、移動するフォルダーのサブフォルダーです。" + unhandled-error: "不明なエラー" + contextmenu: + move-to-this-folder: "このフォルダへ移動" + show-in-new-window: "新しいウィンドウで表示" + rename: "名前を変更" + rename-folder: "フォルダ名の変更" + input-new-folder-name: "新しいフォルダ名を入力してください" + +desktop/views/components/drive.nav-folder.vue: + drive: "ドライブ" + +desktop/views/components/drive.vue: + search: "検索" + load-more: "もっと読み込む" + empty-draghover: "ドロップですか?いいですよ、ボクはカワイイですからね" + empty-drive: "ドライブには何もありません。" + empty-drive-description: "右クリックして「ファイルをアップロード」を選んだり、ファイルをドラッグ&ドロップすることでもアップロードできます。" + empty-folder: "このフォルダーは空です" + unable-to-process: "操作を完了できません" + circular-reference-detected: "移動先のフォルダーは、移動するフォルダーのサブフォルダーです。" + unhandled-error: "不明なエラー" + url-upload: "URLアップロード" + url-of-file: "アップロードしたいファイルのURL" + url-upload-requested: "アップロードをリクエストしました" + may-take-time: "アップロードが完了するまで時間がかかる場合があります。" + create-folder: "フォルダー作成" + folder-name: "フォルダー名" + contextmenu: + create-folder: "フォルダーを作成" + upload: "ファイルをアップロード" + url-upload: "URLからアップロード" + +desktop/views/components/messaging-window.vue: + title: "メッセージ" + +desktop/views/components/notes.note.vue: + reposted-by: "{}がRenote" + reply: "返信" + renote: "Renote" + add-reaction: "リアクション" + detail: "詳細" + +desktop/views/components/notifications.vue: + more: "もっと見る" + empty: "ありません!" + +desktop/views/components/post-form.vue: + note-placeholder: "いまどうしてる?" + reply-placeholder: "この投稿への返信..." + quote-placeholder: "この投稿を引用..." + note: "投稿" + reply: "返信" + renote: "Renote" + posted: "投稿しました!" + replied: "返信しました!" + reposted: "Renoteしました!" + note-failed: "投稿に失敗しました" + reply-failed: "返信に失敗しました" + renote-failed: "Renoteに失敗しました" + posting: "投稿中" + attach-media-from-local: "PCからメディアを添付" + attach-media-from-drive: "ドライブからメディアを添付" + attach-cancel: "添付取り消し" + insert-a-kao: "v(‘ω’)v" + create-poll: "投票を作成" + text-remain: "残り{}文字" + +desktop/views/components/post-form-window.vue: + note: "新規投稿" + reply: "返信" + attaches: "添付: {}メディア" + uploading-media: "{}個のメディアをアップロード中" + +desktop/views/components/renote-form.vue: + quote: "引用する..." + cancel: "キャンセル" + renote: "Renote" + reposting: "しています..." + success: "Renoteしました!" + failure: "Renoteに失敗しました" + +desktop/views/components/renote-form-window.vue: + title: "この投稿をRenoteしますか?" + +desktop/views/components/settings.vue: + profile: "プロフィール" + notification: "通知" + apps: "アプリ" + mute: "ミュート" + drive: "ドライブ" + security: "セキュリティ" + password: "パスワード" + 2fa: "二段階認証" + other: "その他" + license: "ライセンス" + +desktop/views/components/settings.2fa.vue: + intro: "二段階認証を設定すると、サインイン時にパスワードだけでなく、予め登録しておいた物理的なデバイス(例えばあなたのスマートフォンなど)も必要になり、よりセキュリティが向上します。" + detail: "詳細..." + url: "https://www.google.co.jp/intl/ja/landing/2step/" + caution: "登録したデバイスを紛失するなどした場合、Misskeyにサインインできなくなりますのでご注意ください。" + register: "デバイスを登録する" + already-registered: "既に設定は完了しています。" + unregister: "設定を解除" + unregistered: "二段階認証が無効になりました。" + enter-password: "パスワードを入力してください" + authenticator: "まず、Google Authenticatorをお使いのデバイスにインストールします:" + howtoinstall: "インストール方法はこちら" + scan: "次に、表示されているQRコードをスキャンします:" + done: "お使いのデバイスに表示されているトークンを入力して完了します:" + submit: "完了" + success: "設定が完了しました!" + failed: "設定に失敗しました。トークンに誤りがないかご確認ください。" + info: "次回サインインからは、同様にパスワードに加えてデバイスに表示されているトークンを入力します。" + +desktop/views/components/settings.api.vue: + intro: "APIを利用するには、上記のトークンを「i」というキーでパラメータに付加してリクエストします。" + caution: "アカウントを不正利用される可能性があるため、このトークンは第三者に教えないでください(アプリなどにも入力しないでください)。" + regeneration-of-token: "万が一このトークンが漏れたりその可能性がある場合はトークンを再生成できます。" + regenerate-token: "トークンを再生成" + enter-password: "パスワードを入力してください" + +desktop/views/components/settings.app.vue: + no-apps: "連携しているアプリケーションはありません" + +desktop/views/components/settings.mute.vue: + no-users: "ミュートしているユーザーはいません" + +desktop/views/components/settings.password.vue: + reset: "パスワードを変更する" + enter-current-password: "現在のパスワードを入力してください" + enter-new-password: "新しいパスワードを入力してください" + enter-new-password-again: "もう一度新しいパスワードを入力してください" + not-match: "新しいパスワードが一致しません" + changed: "パスワードを変更しました" + +desktop/views/components/settings.profile.vue: + avatar: "アイコン" + choice-avatar: "画像を選択" + name: "名前" + location: "場所" + description: "自己紹介" + birthday: "誕生日" + save: "保存" + +desktop/views/components/ui.header.account.vue: + profile: "プロフィール" + drive: "ドライブ" + favorites: "お気に入り" + lists: "リスト" + customize: "カスタマイズ" + settings: "設定" + signout: "サインアウト" + dark: "闇に飲まれる" + +desktop/views/components/ui.header.nav.vue: + home: "ホーム" + messaging: "メッセージ" + game: "ゲーム" + +desktop/views/components/ui.header.notifications.vue: + title: "通知" + +desktop/views/components/ui.header.post.vue: + post: "新規投稿" + +desktop/views/components/ui.header.search.vue: + placeholder: "検索" + +desktop/views/pages/note.vue: + prev: "前の投稿" + next: "次の投稿" + +desktop/views/pages/selectdrive.vue: + title: "ファイルを選択してください" + ok: "決定" + cancel: "キャンセル" + upload: "PCからドライブにファイルをアップロード" + +desktop/views/pages/user/user.followers-you-know.vue: + title: "知り合いのフォロワー" + loading: "読み込み中" + no-users: "知り合いのフォロワーはいません" + +desktop/views/pages/user/user.friends.vue: + title: "よく話すユーザー" + loading: "読み込み中" + no-users: "よく話すユーザーはいません" + +desktop/views/pages/user/user.header.vue: + is-suspended: "このユーザーは凍結されています。" + is-remote: "このユーザーはリモートユーザーです。" + view-remote: "正確な情報を見る" + +desktop/views/pages/user/user.home.vue: + last-used-at: "最終アクセス" + +desktop/views/pages/user/user.photos.vue: + title: "フォト" + loading: "読み込み中" + no-photos: "写真はありません" + +desktop/views/pages/user/user.profile.vue: + follows-you: "フォローされています" + stalk: "ストークする" + stalking: "ストーキングしています" + unstalk: "ストーク解除" + mute: "ミュートする" + muted: "ミュートしています" + unmute: "ミュート解除" + +desktop/views/widgets/messaging.vue: + title: "メッセージ" + +desktop/views/widgets/notifications.vue: + title: "通知" + settings: "通知の設定" + +desktop/views/widgets/polls.vue: + title: "投票" + refresh: "他を見る" + nothing: "ありません!" + +desktop/views/widgets/post-form.vue: + title: "投稿" + note: "投稿" + placeholder: "いまどうしてる?" + +desktop/views/widgets/trends.vue: + title: "トレンド" + refresh: "他を見る" + nothing: "ありません!" + +desktop/views/widgets/users.vue: + title: "おすすめユーザー" + refresh: "他を見る" + no-one: "いません!" + +desktop/views/widgets/channel.vue: + title: "チャンネル" + settings: "ウィジェットの設定" + get-started: "右上の歯車をクリックして受信するチャンネルを指定してください" + +mobile/views/components/drive.vue: + drive: "ドライブ" + used: "使用中" + folder-count: "フォルダ" + count-separator: "、" + file-count: "ファイル" + load-more: "もっと読み込む" + nothing-in-drive: "ドライブには何もありません" + folder-is-empty: "このフォルダは空です" + +mobile/views/components/drive-file-chooser.vue: + select-file: "ファイルを選択" + +mobile/views/components/drive-folder-chooser.vue: + select-folder: "フォルダーを選択" + +mobile/views/components/drive.file-detail.vue: + download: "ダウンロード" + rename: "名前を変更" + move: "移動" + hash: "ハッシュ (md5)" + exif: "EXIF" + +mobile/views/components/follow-button.vue: + follow: "フォロー" + unfollow: "フォロー解除" + +mobile/views/components/note.vue: + reposted-by: "{}がRenote" + +mobile/views/components/note-detail.vue: + reply: "返信" + reaction: "リアクション" + +mobile/views/components/notifications.vue: + more: "もっと見る" + empty: "ありません!" + +mobile/views/components/post-form.vue: + submit: "投稿" + reply-placeholder: "この投稿への返信..." + note-placeholder: "いまどうしてる?" + +mobile/views/components/sub-note-content.vue: + media-count: "{}個のメディア" + poll: "投票" + +mobile/views/components/timeline.vue: + empty: "投稿がありません" + load-more: "もっと" + +mobile/views/components/ui.nav.vue: + home: "ホーム" + notifications: "通知" + messaging: "メッセージ" + search: "検索" + drive: "ドライブ" + settings: "設定" + about: "Misskeyについて" + +mobile/views/components/user-timeline.vue: + no-notes: "このユーザーは投稿していないようです。" + no-notes-with-media: "メディア付き投稿はありません。" + load-more: "もっと" + +mobile/views/components/users-list.vue: + all: "すべて" + known: "知り合い" + load-more: "もっと" + +mobile/views/pages/drive.vue: + drive: "ドライブ" + +mobile/views/pages/followers.vue: + followers-of: "{}のフォロワー" + +mobile/views/pages/following.vue: + following-of: "{}のフォロー" + +mobile/views/pages/home.vue: + timeline: "タイムライン" + +mobile/views/pages/messaging.vue: + messaging: "メッセージ" + +mobile/views/pages/messaging-room.vue: + messaging: "メッセージ" + +mobile/views/pages/note.vue: + title: "投稿" + prev: "前の投稿" + next: "次の投稿" + +mobile/views/pages/notifications.vue: + notifications: "通知" + read-all: "すべての通知を既読にしますか?" + +mobile/views/pages/profile-setting.vue: + title: "プロフィール設定" + will-be-published: "これらのプロフィールは公開されます。" + name: "名前" + location: "場所" + description: "自己紹介" + birthday: "誕生日" + avatar: "アイコン" + banner: "バナー" + avatar-saved: "アイコンを保存しました" + banner-saved: "バナーを保存しました" + set-avatar: "アイコンを選択する" + set-banner: "バナーを選択する" + save: "保存" + saved: "プロフィールを保存しました" + +mobile/views/pages/search.vue: + search: "検索" + empty: "「{}」に関する投稿は見つかりませんでした。" + +mobile/views/pages/selectdrive.vue: + select-file: "ファイルを選択" + +mobile/views/pages/settings.vue: + signed-in-as: "{}としてサインイン中" + profile: "プロフィール" + twitter: "Twitter連携" + signin-history: "サインイン履歴" + settings: "設定" + signout: "サインアウト" + +mobile/views/pages/user.vue: + follows-you: "フォローされています" + following: "フォロー" + followers: "フォロワー" + notes: "投稿" + overview: "概要" + timeline: "タイムライン" + media: "メディア" + is-suspended: "このユーザーは凍結されています。" + is-remote: "このユーザーはリモートユーザーです。" + view-remote: "正確な情報を見る" + +mobile/views/pages/user/home.vue: + recent-notes: "最近の投稿" + images: "画像" + activity: "アクティビティ" + keywords: "キーワード" + domains: "頻出ドメイン" + frequently-replied-users: "よく会話するユーザー" + followers-you-know: "知り合いのフォロワー" + last-used-at: "最終ログイン" + +mobile/views/pages/user/home.followers-you-know.vue: + loading: "読み込み中" + no-users: "知り合いのユーザーはいません" + +mobile/views/pages/user/home.friends.vue: + loading: "読み込み中" + no-users: "よく会話するユーザーはいません" + +mobile/views/pages/user/home.notes.vue: + loading: "読み込み中" + no-notes: "投稿はありません" + +mobile/views/pages/user/home.photos.vue: + loading: "読み込み中" + no-photos: "写真はありません" + +docs: + edit-this-page-on-github: "間違いや改善点を見つけましたか?" + edit-this-page-on-github-link: "このページをGitHubで編集" + + api: + entities: + properties: "プロパティ" + endpoints: + params: "パラメータ" + res: "レスポンス" + props: name: "名前" - location: "場所" - description: "自己紹介" - birthday: "誕生日" - avatar: "アバター" - banner: "バナー" - avatar-saved: "アバターを保存しました" - banner-saved: "バナーを保存しました" - set-avatar: "アバターを選択する" - set-banner: "バナーを選択する" - save: "保存" - saved: "プロフィールを保存しました" - - mk-user-followers-page: - followers-of: "{}のフォロワー" - - mk-user-following-page: - following-of: "{}のフォロー" - - mk-drive-folder-selector: - select-folder: "フォルダーを選択" - - mk-drive-selector: - select-file: "ファイルを選択" - - mk-drive: - drive: "ドライブ" - used: "使用中" - folder-count: "フォルダ" - count-separator: "、" - file-count: "ファイル" - load-more: "もっと読み込む" - nothing-in-drive: "ドライブには何もありません" - folder-is-empty: "このフォルダは空です" - - mk-follow-button: - follow: "フォロー" - unfollow: "フォロー解除" - - mk-home-timeline: - empty-timeline: "表示する投稿がありません。誰かしらをフォローするなどしましょう。" - - mk-notifications: - more: "もっと見る" - empty: "ありません!" - - mk-post-detail: - reply: "返信" - reaction: "リアクション" - - mk-post-form: - submit: "投稿" - reply-placeholder: "この投稿への返信..." - post-placeholder: "いまどうしてる?" - attach-media-from-local: "デバイスからメディアを添付" - - mk-search-posts: - empty: "「{}」に関する投稿は見つかりませんでした。" - - mk-sub-post-content: - media-count: "{}個のメディア" - poll: "投票" - - mk-timeline-post: - reposted-by: "{}がRepost" - - mk-timeline: - empty: "表示するものがありません" - load-more: "もっとみる" - - mk-ui-nav: - home: "ホーム" - notifications: "通知" - messaging: "メッセージ" - ch: "チャンネル" - search: "検索" - drive: "ドライブ" - settings: "設定" - about: "Misskeyについて" - - mk-user-followers: - no-users: "フォロワーはいないようです。" - - mk-user-following: - no-users: "フォロー中のユーザーはいないようです。" - - mk-user-timeline: - no-posts: "このユーザーはまだ投稿していないようです。" - no-posts-with-media: "メディア付き投稿はありません。" - - mk-user: - follows-you: "フォローされています" - following: "フォロー" - followers: "フォロワー" - posts: "投稿" - overview: "概要" - timeline: "タイムライン" - media: "メディア" - - mk-user-overview: - recent-posts: "最近の投稿" - images: "画像" - activity: "アクティビティ" - keywords: "キーワード" - domains: "頻出ドメイン" - frequently-replied-users: "よく会話するユーザー" - followers-you-know: "知り合いのフォロワー" - last-used-at: "最終ログイン" - - mk-user-overview-posts: - loading: "読み込み中" - no-posts: "投稿はありません" - - mk-user-overview-photos: - loading: "読み込み中" - no-photos: "写真はありません" - - mk-user-overview-keywords: - no-keywords: "キーワードはありません(十分な数の投稿をしていない可能性があります)" - - mk-user-overview-domains: - no-domains: "よく表れるドメインは検出されませんでした" - - mk-user-overview-frequently-replied-users: - loading: "読み込み中" - no-users: "よく会話するユーザーはいません" - - mk-user-overview-followers-you-know: - loading: "読み込み中" - no-users: "知り合いのユーザーはいません" - - mk-users-list: - all: "すべて" - known: "知り合い" - load-more: "もっと" - -stats: - posts-count: "投稿の数" - users-count: "アカウントの数" - -status: - all-systems-maybe-operational: "すべてのシステムがたぶん正常に作動しています" - what-is-this-site: "" + type: "型" + optional: "オプション" + description: "説明" + yes: "はい" + no: "いいえ" diff --git a/migration/2018-04-19.js b/migration/2018-04-19.js new file mode 100644 index 000000000..b0df22c00 --- /dev/null +++ b/migration/2018-04-19.js @@ -0,0 +1,49 @@ +// for Node.js interpret + +const { default: User } = require('../built/models/user'); +const { default: Following } = require('../built/models/following'); +const { default: zip } = require('@prezzemolo/zip') + +const migrate = async (following) => { + const follower = await User.findOne({ _id: following.followerId }); + const followee = await User.findOne({ _id: following.followeeId }); + const result = await Following.update(following._id, { + $set: { + stalk: true, + _follower: { + host: follower.host, + inbox: follower.host != null ? follower.inbox : undefined + }, + _followee: { + host: followee.host, + inbox: followee.host != null ? followee.inbox : undefined + } + } + }); + return result.ok === 1; +} + +async function main() { + const count = await Following.count({}); + + const dop = Number.parseInt(process.argv[2]) || 5 + const idop = ((count - (count % dop)) / dop) + 1 + + return zip( + 1, + async (time) => { + console.log(`${time} / ${idop}`) + const doc = await Following.find({}, { + limit: dop, skip: time * dop + }) + return Promise.all(doc.map(migrate)) + }, + idop + ).then(a => { + const rv = [] + a.forEach(e => rv.push(...e)) + return rv + }) +} + +main().then(console.dir).catch(console.error) diff --git a/tools/migration/README.md b/migration/README.md similarity index 100% rename from tools/migration/README.md rename to migration/README.md diff --git a/tools/init-migration-file.sh b/migration/init-migration-file.sh old mode 100755 new mode 100644 similarity index 100% rename from tools/init-migration-file.sh rename to migration/init-migration-file.sh diff --git a/package.json b/package.json index 22d74a220..0688c1901 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,20 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.3230", - "license": "MIT", - "description": "A miniblog-based SNS", - "bugs": "https://github.com/syuilo/misskey/issues", - "repository": "https://github.com/syuilo/misskey.git", + "version": "1.7.0", + "clientVersion": "1.0.5175", + "codename": "nighthike", "main": "./built/index.js", "private": true, "scripts": { - "config": "node ./tools/init.js", + "config": "node ./cli/init.js", "start": "node ./built", "debug": "DEBUG=misskey:* node ./built", "swagger": "node ./swagger.js", - "build": "gulp build", + "build": "webpack && gulp build", + "webpack": "webpack", + "watch": "webpack --watch", + "gulp": "gulp build", "rebuild": "gulp rebuild", "clean": "gulp clean", "cleanall": "gulp cleanall", @@ -22,145 +23,198 @@ "format": "gulp format" }, "dependencies": { + "@fortawesome/fontawesome": "1.0.1", + "@fortawesome/fontawesome-free-brands": "5.0.2", + "@fortawesome/fontawesome-free-regular": "5.0.2", + "@fortawesome/fontawesome-free-solid": "5.0.2", + "@koa/cors": "2.2.1", "@prezzemolo/rap": "0.1.2", "@prezzemolo/zip": "0.0.3", "@types/bcryptjs": "2.4.1", - "@types/body-parser": "1.16.8", - "@types/chai": "4.0.6", - "@types/chai-http": "3.0.3", - "@types/compression": "0.0.35", - "@types/cookie": "0.3.1", - "@types/cors": "2.8.3", + "@types/chai": "4.1.3", + "@types/chai-http": "3.0.4", "@types/debug": "0.0.30", "@types/deep-equal": "1.0.1", - "@types/elasticsearch": "5.0.18", - "@types/event-stream": "3.3.33", + "@types/elasticsearch": "5.0.22", "@types/eventemitter3": "2.0.2", - "@types/express": "4.0.39", "@types/gm": "1.17.33", - "@types/gulp": "4.0.3", - "@types/gulp-htmlmin": "1.3.31", - "@types/gulp-mocha": "0.0.31", + "@types/gulp": "3.8.36", + "@types/gulp-htmlmin": "1.3.32", + "@types/gulp-mocha": "0.0.32", "@types/gulp-rename": "0.0.33", "@types/gulp-replace": "0.0.31", - "@types/gulp-uglify": "3.0.3", + "@types/gulp-uglify": "3.0.5", "@types/gulp-util": "3.0.34", - "@types/inquirer": "0.0.35", + "@types/inquirer": "0.0.41", "@types/is-root": "1.0.0", "@types/is-url": "1.2.28", - "@types/js-yaml": "3.10.1", - "@types/mocha": "2.2.44", - "@types/mongodb": "2.2.16", - "@types/monk": "1.0.6", - "@types/morgan": "1.7.35", + "@types/js-yaml": "3.11.1", + "@types/koa": "2.0.45", + "@types/koa-bodyparser": "4.2.0", + "@types/koa-compress": "2.0.8", + "@types/koa-favicon": "2.0.19", + "@types/koa-logger": "3.1.0", + "@types/koa-mount": "3.0.1", + "@types/koa-multer": "1.0.0", + "@types/koa-router": "7.0.28", + "@types/koa-send": "4.1.1", + "@types/koa__cors": "2.2.2", + "@types/kue": "0.11.8", + "@types/license-checker": "15.0.0", + "@types/mkdirp": "0.5.2", + "@types/mocha": "5.2.0", + "@types/mongodb": "3.0.15", + "@types/monk": "6.0.0", "@types/ms": "0.7.30", - "@types/multer": "1.3.6", - "@types/node": "8.0.53", - "@types/page": "1.5.32", - "@types/proxy-addr": "2.0.0", + "@types/node": "9.6.6", + "@types/nopt": "3.0.29", + "@types/pug": "2.0.4", + "@types/qrcode": "0.8.1", "@types/ratelimiter": "2.1.28", - "@types/redis": "2.8.1", - "@types/request": "2.0.8", + "@types/redis": "2.8.6", + "@types/request": "2.47.0", + "@types/request-promise-native": "1.0.14", "@types/rimraf": "2.0.2", - "@types/riot": "3.6.1", "@types/seedrandom": "2.4.27", - "@types/serve-favicon": "2.2.30", + "@types/speakeasy": "2.0.2", "@types/tmp": "0.0.33", "@types/uuid": "3.4.3", - "@types/webpack": "3.8.1", - "@types/webpack-stream": "3.2.8", - "@types/websocket": "0.0.35", - "accesses": "2.5.0", + "@types/webpack": "4.1.4", + "@types/webpack-stream": "3.2.10", + "@types/websocket": "0.0.38", + "@types/ws": "4.0.2", "animejs": "2.2.0", - "autwh": "0.0.1", - "awesome-typescript-loader": "3.4.1", + "autosize": "4.0.1", + "autwh": "0.1.0", "bcryptjs": "2.4.3", - "body-parser": "1.18.2", - "cafy": "3.2.0", + "bootstrap-vue": "2.0.0-rc.6", + "cafy": "8.0.0", "chai": "4.1.2", - "chai-http": "3.0.0", - "chalk": "2.3.0", - "compression": "1.7.1", - "cookie": "0.3.1", - "cors": "2.8.4", - "cropperjs": "1.1.3", - "css-loader": "0.28.7", + "chai-http": "4.0.0", + "chalk": "2.4.1", + "crc-32": "1.2.0", + "css-loader": "0.28.11", "debug": "3.1.0", "deep-equal": "1.0.1", "deepcopy": "0.6.3", "diskusage": "0.2.4", - "elasticsearch": "14.0.0", + "dompurify": "1.0.3", + "elasticsearch": "14.2.2", + "element-ui": "2.3.6", + "emojilib": "2.2.12", "escape-regexp": "0.0.1", - "event-stream": "3.3.4", - "eventemitter3": "3.0.0", - "express": "4.16.2", - "file-type": "7.4.0", + "eslint": "4.19.1", + "eslint-plugin-vue": "4.5.0", + "eventemitter3": "3.1.0", + "exif-js": "2.3.0", + "file-loader": "1.1.11", + "file-type": "7.6.0", "fuckadblock": "3.2.1", - "gm": "1.23.0", + "gm": "1.23.1", "gulp": "3.9.1", - "gulp-cssnano": "2.1.2", - "gulp-htmlmin": "3.0.0", - "gulp-imagemin": "4.0.0", - "gulp-mocha": "4.3.1", - "gulp-pug": "3.3.0", + "gulp-cssnano": "2.1.3", + "gulp-htmlmin": "4.0.0", + "gulp-imagemin": "4.1.0", + "gulp-mocha": "5.0.0", + "gulp-pug": "4.0.1", "gulp-rename": "1.2.2", "gulp-replace": "0.6.1", - "gulp-tslint": "8.1.2", - "gulp-typescript": "3.2.3", + "gulp-sourcemaps": "2.6.4", + "gulp-stylus": "2.7.0", + "gulp-tslint": "8.1.3", + "gulp-typescript": "4.0.2", "gulp-uglify": "3.0.0", "gulp-util": "3.0.8", - "inquirer": "4.0.1", - "is-root": "1.0.0", - "is-url": "1.2.2", - "js-yaml": "3.10.0", + "hard-source-webpack-plugin": "0.6.4", + "highlight.js": "9.12.0", + "html-minifier": "3.5.15", + "http-signature": "1.2.0", + "inquirer": "5.2.0", + "is-root": "2.0.0", + "is-url": "1.2.4", + "js-yaml": "3.11.0", + "jsdom": "11.9.0", + "koa": "2.5.1", + "koa-bodyparser": "4.2.0", + "koa-compress": "3.0.0", + "koa-favicon": "2.0.1", + "koa-json-body": "5.3.0", + "koa-logger": "3.2.0", + "koa-mount": "3.0.0", + "koa-multer": "1.0.2", + "koa-router": "7.4.0", + "koa-send": "4.1.3", + "koa-slow": "2.1.0", + "kue": "0.11.6", + "license-checker": "18.0.0", + "loader-utils": "1.1.0", "mecab-async": "0.1.2", - "mocha": "4.0.1", + "mkdirp": "0.5.1", + "mocha": "5.1.1", "moji": "0.5.1", - "mongodb": "2.2.33", + "mongodb": "3.0.7", "monk": "6.0.5", - "morgan": "1.9.0", "ms": "2.1.1", - "multer": "1.3.0", + "nan": "2.10.0", + "node-sass": "4.9.0", + "node-sass-json-importer": "3.2.0", + "nopt": "4.0.1", "nprogress": "0.2.0", + "object-assign-deep": "0.4.0", + "on-build-webpack": "0.1.0", "os-utils": "0.0.14", - "page": "1.7.1", - "pictograph": "2.1.2", + "progress-bar-webpack-plugin": "1.11.0", "prominence": "0.2.0", - "proxy-addr": "2.0.2", - "pug": "2.0.0-rc.4", + "promise-sequential": "^1.1.1", + "pug": "2.0.3", + "punycode": "2.1.0", + "qrcode": "1.2.0", "ratelimiter": "3.0.3", "recaptcha-promise": "0.1.3", "reconnecting-websocket": "3.2.2", "redis": "2.8.0", - "request": "2.83.0", + "request": "2.85.0", + "request-promise-native": "1.0.5", "rimraf": "2.6.2", - "riot": "3.7.4", - "riot-tag-loader": "1.0.0", "rndstr": "1.0.0", - "s-age": "1.1.0", - "seedrandom": "^2.4.3", - "serve-favicon": "2.4.5", - "sortablejs": "1.7.0", - "string-replace-webpack-plugin": "0.1.3", - "style-loader": "0.19.0", + "s-age": "1.1.2", + "sass-loader": "7.0.1", + "seedrandom": "2.4.3", + "speakeasy": "2.0.0", + "style-loader": "0.21.0", "stylus": "0.54.5", - "stylus-loader": "3.0.1", - "summaly": "2.0.3", + "stylus-loader": "3.0.2", + "summaly": "2.0.4", "swagger-jsdoc": "1.9.7", "syuilo-password-strength": "0.0.1", "tcp-port-used": "0.1.2", - "textarea-caret": "3.0.2", + "textarea-caret": "3.1.0", "tmp": "0.0.33", - "ts-node": "3.3.0", - "tslint": "5.8.0", - "typescript": "2.6.2", - "uglify-es": "3.2.0", - "uglifyjs-webpack-plugin": "1.1.2", - "uuid": "3.1.0", - "vhost": "3.0.2", - "web-push": "3.2.5", - "webpack": "3.10.0", - "websocket": "1.0.25", + "ts-loader": "4.2.0", + "ts-node": "6.0.1", + "tslint": "5.9.1", + "typescript": "2.8.3", + "typescript-eslint-parser": "15.0.0", + "uglify-es": "3.3.9", + "url-loader": "1.0.1", + "uuid": "3.2.1", + "v-animate-css": "0.0.2", + "vue": "2.5.16", + "vue-cropperjs": "2.2.0", + "vue-js-modal": "1.3.13", + "vue-json-tree-view": "2.1.4", + "vue-loader": "15.0.3", + "vue-router": "3.0.1", + "vue-template-compiler": "2.5.16", + "vuedraggable": "2.16.0", + "vuex": "3.0.1", + "web-push": "3.3.0", + "webfinger.js": "2.6.6", + "webpack": "4.6.0", + "webpack-cli": "2.0.15", + "webpack-replace-loader": "1.3.0", + "websocket": "1.0.26", + "ws": "5.1.1", "xev": "2.0.0" } } diff --git a/src/acct/parse.ts b/src/acct/parse.ts new file mode 100644 index 000000000..ef1f55405 --- /dev/null +++ b/src/acct/parse.ts @@ -0,0 +1,4 @@ +export default acct => { + const splitted = acct.split('@', 2); + return { username: splitted[0], host: splitted[1] || null }; +}; diff --git a/src/acct/render.ts b/src/acct/render.ts new file mode 100644 index 000000000..9afb03d88 --- /dev/null +++ b/src/acct/render.ts @@ -0,0 +1,3 @@ +export default user => { + return user.host === null ? user.username : `${user.username}@${user.host}`; +}; diff --git a/src/api/api-handler.ts b/src/api/api-handler.ts deleted file mode 100644 index fb603a0e2..000000000 --- a/src/api/api-handler.ts +++ /dev/null @@ -1,56 +0,0 @@ -import * as express from 'express'; - -import { Endpoint } from './endpoints'; -import authenticate from './authenticate'; -import { IAuthContext } from './authenticate'; -import _reply from './reply'; -import limitter from './limitter'; - -export default async (endpoint: Endpoint, req: express.Request, res: express.Response) => { - const reply = _reply.bind(null, res); - let ctx: IAuthContext; - - // Authentication - try { - ctx = await authenticate(req); - } catch (e) { - return reply(403, 'AUTHENTICATION_FAILED'); - } - - if (endpoint.secure && !ctx.isSecure) { - return reply(403, 'ACCESS_DENIED'); - } - - if (endpoint.withCredential && ctx.user == null) { - return reply(401, 'PLZ_SIGNIN'); - } - - if (ctx.app && endpoint.kind) { - if (!ctx.app.permission.some(p => p === endpoint.kind)) { - return reply(403, 'ACCESS_DENIED'); - } - } - - if (endpoint.withCredential && endpoint.limit) { - try { - await limitter(endpoint, ctx); // Rate limit - } catch (e) { - // drop request if limit exceeded - return reply(429); - } - } - - let exec = require(`${__dirname}/endpoints/${endpoint.name}`); - - if (endpoint.withFile) { - exec = exec.bind(null, req.file); - } - - // API invoking - try { - const res = await exec(req.body, ctx.user, ctx.app, ctx.isSecure); - reply(res); - } catch (e) { - reply(400, e); - } -}; diff --git a/src/api/authenticate.ts b/src/api/authenticate.ts deleted file mode 100644 index b289959ac..000000000 --- a/src/api/authenticate.ts +++ /dev/null @@ -1,69 +0,0 @@ -import * as express from 'express'; -import App from './models/app'; -import { default as User, IUser } from './models/user'; -import AccessToken from './models/access-token'; -import isNativeToken from './common/is-native-token'; - -export interface IAuthContext { - /** - * App which requested - */ - app: any; - - /** - * Authenticated user - */ - user: IUser; - - /** - * Whether requested with a User-Native Token - */ - isSecure: boolean; -} - -export default (req: express.Request) => new Promise(async (resolve, reject) => { - const token = req.body['i'] as string; - - if (token == null) { - return resolve({ - app: null, - user: null, - isSecure: false - }); - } - - if (isNativeToken(token)) { - const user: IUser = await User - .findOne({ token: token }); - - if (user === null) { - return reject('user not found'); - } - - return resolve({ - app: null, - user: user, - isSecure: true - }); - } else { - const accessToken = await AccessToken.findOne({ - hash: token.toLowerCase() - }); - - if (accessToken === null) { - return reject('invalid signature'); - } - - const app = await App - .findOne({ _id: accessToken.app_id }); - - const user = await User - .findOne({ _id: accessToken.user_id }); - - return resolve({ - app: app, - user: user, - isSecure: false - }); - } -}); diff --git a/src/api/common/add-file-to-drive.ts b/src/api/common/add-file-to-drive.ts deleted file mode 100644 index 2a649788a..000000000 --- a/src/api/common/add-file-to-drive.ts +++ /dev/null @@ -1,264 +0,0 @@ -import { Buffer } from 'buffer'; -import * as fs from 'fs'; -import * as tmp from 'tmp'; -import * as stream from 'stream'; - -import * as mongodb from 'mongodb'; -import * as crypto from 'crypto'; -import * as gm from 'gm'; -import * as debug from 'debug'; -import fileType = require('file-type'); -import prominence = require('prominence'); - -import DriveFile, { getGridFSBucket } from '../models/drive-file'; -import DriveFolder from '../models/drive-folder'; -import serialize from '../serializers/drive-file'; -import event, { publishDriveStream } from '../event'; -import config from '../../conf'; - -const log = debug('misskey:register-drive-file'); - -const tmpFile = (): Promise => new Promise((resolve, reject) => { - tmp.file((e, path) => { - if (e) return reject(e); - resolve(path); - }); -}); - -const addToGridFS = (name: string, readable: stream.Readable, type: string, metadata: any): Promise => - getGridFSBucket() - .then(bucket => new Promise((resolve, reject) => { - const writeStream = bucket.openUploadStream(name, { contentType: type, metadata }); - writeStream.once('finish', (doc) => { resolve(doc); }); - writeStream.on('error', reject); - readable.pipe(writeStream); - })); - -const addFile = async ( - user: any, - path: string, - name: string = null, - comment: string = null, - folderId: mongodb.ObjectID = null, - force: boolean = false -) => { - log(`registering ${name} (user: ${user.username}, path: ${path})`); - - // Calculate hash, get content type and get file size - const [hash, [mime, ext], size] = await Promise.all([ - // hash - ((): Promise => new Promise((res, rej) => { - const readable = fs.createReadStream(path); - const hash = crypto.createHash('md5'); - const chunks = []; - readable - .on('error', rej) - .pipe(hash) - .on('error', rej) - .on('data', (chunk) => chunks.push(chunk)) - .on('end', () => { - const buffer = Buffer.concat(chunks); - res(buffer.toString('hex')); - }); - }))(), - // mime - ((): Promise<[string, string | null]> => new Promise((res, rej) => { - const readable = fs.createReadStream(path); - readable - .on('error', rej) - .once('data', (buffer: Buffer) => { - readable.destroy(); - const type = fileType(buffer); - if (type) { - return res([type.mime, type.ext]); - } else { - // 種類が同定できなかったら application/octet-stream にする - return res(['application/octet-stream', null]); - } - }); - }))(), - // size - ((): Promise => new Promise((res, rej) => { - fs.stat(path, (err, stats) => { - if (err) return rej(err); - res(stats.size); - }); - }))() - ]); - - log(`hash: ${hash}, mime: ${mime}, ext: ${ext}, size: ${size}`); - - // detect name - const detectedName: string = name || (ext ? `untitled.${ext}` : 'untitled'); - - if (!force) { - // Check if there is a file with the same hash - const much = await DriveFile.findOne({ - md5: hash, - 'metadata.user_id': user._id - }); - - if (much !== null) { - log('file with same hash is found'); - return much; - } else { - log('file with same hash is not found'); - } - } - - const [properties, folder] = await Promise.all([ - // properties - (async () => { - // 画像かどうか - if (!/^image\/.*$/.test(mime)) { - return null; - } - - const imageType = mime.split('/')[1]; - - // 画像でもPNGかJPEGでないならスキップ - if (imageType != 'png' && imageType != 'jpeg') { - return null; - } - - // If the file is an image, calculate width and height to save in property - const g = gm(fs.createReadStream(path), name); - const size = await prominence(g).size(); - const properties = { - width: size.width, - height: size.height - }; - - log('image width and height is calculated'); - - return properties; - })(), - // folder - (async () => { - if (!folderId) { - return null; - } - const driveFolder = await DriveFolder.findOne({ - _id: folderId, - user_id: user._id - }); - if (!driveFolder) { - throw 'folder-not-found'; - } - return driveFolder; - })(), - // usage checker - (async () => { - // Calculate drive usage - const usage = await DriveFile - .aggregate([{ - $match: { 'metadata.user_id': user._id } - }, { - $project: { - length: true - } - }, { - $group: { - _id: null, - usage: { $sum: '$length' } - } - }]) - .then((aggregates: any[]) => { - if (aggregates.length > 0) { - return aggregates[0].usage; - } - return 0; - }); - - log(`drive usage is ${usage}`); - - // If usage limit exceeded - if (usage + size > user.drive_capacity) { - throw 'no-free-space'; - } - })() - ]); - - const readable = fs.createReadStream(path); - - return addToGridFS(detectedName, readable, mime, { - user_id: user._id, - folder_id: folder !== null ? folder._id : null, - comment: comment, - properties: properties - }); -}; - -/** - * Add file to drive - * - * @param user User who wish to add file - * @param file File path or readableStream - * @param comment Comment - * @param type File type - * @param folderId Folder ID - * @param force If set to true, forcibly upload the file even if there is a file with the same hash. - * @return Object that represents added file - */ -export default (user: any, file: string | stream.Readable, ...args) => new Promise((resolve, reject) => { - // Get file path - new Promise((res: (v: [string, boolean]) => void, rej) => { - if (typeof file === 'string') { - res([file, false]); - return; - } - if (typeof file === 'object' && typeof file.read === 'function') { - tmpFile() - .then(path => { - const readable: stream.Readable = file; - const writable = fs.createWriteStream(path); - readable - .on('error', rej) - .on('end', () => { - res([path, true]); - }) - .pipe(writable) - .on('error', rej); - }) - .catch(rej); - } - rej(new Error('un-compatible file.')); - }) - .then(([path, remove]): Promise => new Promise((res, rej) => { - addFile(user, path, ...args) - .then(file => { - res(file); - if (remove) { - fs.unlink(path, (e) => { - if (e) log(e.stack); - }); - } - }) - .catch(rej); - })) - .then(file => { - log(`drive file has been created ${file._id}`); - resolve(file); - - serialize(file).then(serializedFile => { - // Publish drive_file_created event - event(user._id, 'drive_file_created', serializedFile); - publishDriveStream(user._id, 'file_created', serializedFile); - - // Register to search database - if (config.elasticsearch.enable) { - const es = require('../../db/elasticsearch'); - es.index({ - index: 'misskey', - type: 'drive_file', - id: file._id.toString(), - body: { - name: file.name, - user_id: user._id.toString() - } - }); - } - }); - }) - .catch(reject); -}); diff --git a/src/api/common/get-friends.ts b/src/api/common/get-friends.ts deleted file mode 100644 index db6313816..000000000 --- a/src/api/common/get-friends.ts +++ /dev/null @@ -1,26 +0,0 @@ -import * as mongodb from 'mongodb'; -import Following from '../models/following'; - -export default async (me: mongodb.ObjectID, includeMe: boolean = true) => { - // Fetch relation to other users who the I follows - // SELECT followee - const myfollowing = await Following - .find({ - follower_id: me, - // 削除されたドキュメントは除く - deleted_at: { $exists: false } - }, { - fields: { - followee_id: true - } - }); - - // ID list of other users who the I follows - const myfollowingIds = myfollowing.map(follow => follow.followee_id); - - if (includeMe) { - myfollowingIds.push(me); - } - - return myfollowingIds; -}; diff --git a/src/api/common/signin.ts b/src/api/common/signin.ts deleted file mode 100644 index 693e62f39..000000000 --- a/src/api/common/signin.ts +++ /dev/null @@ -1,19 +0,0 @@ -import config from '../../conf'; - -export default function(res, user, redirect: boolean) { - const expires = 1000 * 60 * 60 * 24 * 365; // One Year - res.cookie('i', user.token, { - path: '/', - domain: `.${config.host}`, - secure: config.url.substr(0, 5) === 'https', - httpOnly: false, - expires: new Date(Date.now() + expires), - maxAge: expires - }); - - if (redirect) { - res.redirect(config.url); - } else { - res.sendStatus(204); - } -} diff --git a/src/api/common/text/elements/mention.ts b/src/api/common/text/elements/mention.ts deleted file mode 100644 index e0fac4dd7..000000000 --- a/src/api/common/text/elements/mention.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Mention - */ - -module.exports = text => { - const match = text.match(/^@[a-zA-Z0-9\-]+/); - if (!match) return null; - const mention = match[0]; - return { - type: 'mention', - content: mention, - username: mention.substr(1) - }; -}; diff --git a/src/api/common/watch-post.ts b/src/api/common/watch-post.ts deleted file mode 100644 index 1a50f0eda..000000000 --- a/src/api/common/watch-post.ts +++ /dev/null @@ -1,26 +0,0 @@ -import * as mongodb from 'mongodb'; -import Watching from '../models/post-watching'; - -export default async (me: mongodb.ObjectID, post: object) => { - // 自分の投稿はwatchできない - if (me.equals((post as any).user_id)) { - return; - } - - // if watching now - const exist = await Watching.findOne({ - post_id: (post as any)._id, - user_id: me, - deleted_at: { $exists: false } - }); - - if (exist !== null) { - return; - } - - await Watching.insert({ - created_at: new Date(), - post_id: (post as any)._id, - user_id: me - }); -}; diff --git a/src/api/endpoints/aggregation/posts/reaction.ts b/src/api/endpoints/aggregation/posts/reaction.ts deleted file mode 100644 index eb99b9d08..000000000 --- a/src/api/endpoints/aggregation/posts/reaction.ts +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../../models/post'; -import Reaction from '../../../models/post-reaction'; - -/** - * Aggregate reaction of a post - * - * @param {any} params - * @return {Promise} - */ -module.exports = (params) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Lookup post - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - const datas = await Reaction - .aggregate([ - { $match: { post_id: post._id } }, - { $project: { - created_at: { $add: ['$created_at', 9 * 60 * 60 * 1000] } // Convert into JST - }}, - { $project: { - date: { - year: { $year: '$created_at' }, - month: { $month: '$created_at' }, - day: { $dayOfMonth: '$created_at' } - } - }}, - { $group: { - _id: '$date', - count: { $sum: 1 } - }} - ]); - - datas.forEach(data => { - data.date = data._id; - delete data._id; - }); - - const graph = []; - - for (let i = 0; i < 30; i++) { - const day = new Date(new Date().setDate(new Date().getDate() - i)); - - const data = datas.filter(d => - d.date.year == day.getFullYear() && d.date.month == day.getMonth() + 1 && d.date.day == day.getDate() - )[0]; - - if (data) { - graph.push(data); - } else { - graph.push({ - date: { - year: day.getFullYear(), - month: day.getMonth() + 1, // In JavaScript, month is zero-based. - day: day.getDate() - }, - count: 0 - }); - } - } - - res(graph); -}); diff --git a/src/api/endpoints/aggregation/posts/reactions.ts b/src/api/endpoints/aggregation/posts/reactions.ts deleted file mode 100644 index 2cd4588ae..000000000 --- a/src/api/endpoints/aggregation/posts/reactions.ts +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../../models/post'; -import Reaction from '../../../models/post-reaction'; - -/** - * Aggregate reactions of a post - * - * @param {any} params - * @return {Promise} - */ -module.exports = (params) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Lookup post - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - const startTime = new Date(new Date().setMonth(new Date().getMonth() - 1)); - - const reactions = await Reaction - .find({ - post_id: post._id, - $or: [ - { deleted_at: { $exists: false } }, - { deleted_at: { $gt: startTime } } - ] - }, { - _id: false, - post_id: false - }, { - sort: { created_at: -1 } - }); - - const graph = []; - - for (let i = 0; i < 30; i++) { - let day = new Date(new Date().setDate(new Date().getDate() - i)); - day = new Date(day.setMilliseconds(999)); - day = new Date(day.setSeconds(59)); - day = new Date(day.setMinutes(59)); - day = new Date(day.setHours(23)); - // day = day.getTime(); - - const count = reactions.filter(r => - r.created_at < day && (r.deleted_at == null || r.deleted_at > day) - ).length; - - graph.push({ - date: { - year: day.getFullYear(), - month: day.getMonth() + 1, // In JavaScript, month is zero-based. - day: day.getDate() - }, - count: count - }); - } - - res(graph); -}); diff --git a/src/api/endpoints/aggregation/posts/reply.ts b/src/api/endpoints/aggregation/posts/reply.ts deleted file mode 100644 index b114c34e1..000000000 --- a/src/api/endpoints/aggregation/posts/reply.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../../models/post'; - -/** - * Aggregate reply of a post - * - * @param {any} params - * @return {Promise} - */ -module.exports = (params) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Lookup post - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - const datas = await Post - .aggregate([ - { $match: { reply: post._id } }, - { $project: { - created_at: { $add: ['$created_at', 9 * 60 * 60 * 1000] } // Convert into JST - }}, - { $project: { - date: { - year: { $year: '$created_at' }, - month: { $month: '$created_at' }, - day: { $dayOfMonth: '$created_at' } - } - }}, - { $group: { - _id: '$date', - count: { $sum: 1 } - }} - ]); - - datas.forEach(data => { - data.date = data._id; - delete data._id; - }); - - const graph = []; - - for (let i = 0; i < 30; i++) { - const day = new Date(new Date().setDate(new Date().getDate() - i)); - - const data = datas.filter(d => - d.date.year == day.getFullYear() && d.date.month == day.getMonth() + 1 && d.date.day == day.getDate() - )[0]; - - if (data) { - graph.push(data); - } else { - graph.push({ - date: { - year: day.getFullYear(), - month: day.getMonth() + 1, // In JavaScript, month is zero-based. - day: day.getDate() - }, - count: 0 - }); - } - } - - res(graph); -}); diff --git a/src/api/endpoints/aggregation/posts/repost.ts b/src/api/endpoints/aggregation/posts/repost.ts deleted file mode 100644 index 217159caa..000000000 --- a/src/api/endpoints/aggregation/posts/repost.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../../models/post'; - -/** - * Aggregate repost of a post - * - * @param {any} params - * @return {Promise} - */ -module.exports = (params) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Lookup post - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - const datas = await Post - .aggregate([ - { $match: { repost_id: post._id } }, - { $project: { - created_at: { $add: ['$created_at', 9 * 60 * 60 * 1000] } // Convert into JST - }}, - { $project: { - date: { - year: { $year: '$created_at' }, - month: { $month: '$created_at' }, - day: { $dayOfMonth: '$created_at' } - } - }}, - { $group: { - _id: '$date', - count: { $sum: 1 } - }} - ]); - - datas.forEach(data => { - data.date = data._id; - delete data._id; - }); - - const graph = []; - - for (let i = 0; i < 30; i++) { - const day = new Date(new Date().setDate(new Date().getDate() - i)); - - const data = datas.filter(d => - d.date.year == day.getFullYear() && d.date.month == day.getMonth() + 1 && d.date.day == day.getDate() - )[0]; - - if (data) { - graph.push(data); - } else { - graph.push({ - date: { - year: day.getFullYear(), - month: day.getMonth() + 1, // In JavaScript, month is zero-based. - day: day.getDate() - }, - count: 0 - }); - } - } - - res(graph); -}); diff --git a/src/api/endpoints/aggregation/users/followers.ts b/src/api/endpoints/aggregation/users/followers.ts deleted file mode 100644 index 3022b2b00..000000000 --- a/src/api/endpoints/aggregation/users/followers.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import User from '../../../models/user'; -import Following from '../../../models/following'; - -/** - * Aggregate followers of a user - * - * @param {any} params - * @return {Promise} - */ -module.exports = (params) => new Promise(async (res, rej) => { - // Get 'user_id' parameter - const [userId, userIdErr] = $(params.user_id).id().$; - if (userIdErr) return rej('invalid user_id param'); - - // Lookup user - const user = await User.findOne({ - _id: userId - }, { - fields: { - _id: true - } - }); - - if (user === null) { - return rej('user not found'); - } - - const startTime = new Date(new Date().setMonth(new Date().getMonth() - 1)); - - const following = await Following - .find({ - followee_id: user._id, - $or: [ - { deleted_at: { $exists: false } }, - { deleted_at: { $gt: startTime } } - ] - }, { - _id: false, - follower_id: false, - followee_id: false - }, { - sort: { created_at: -1 } - }); - - const graph = []; - - for (let i = 0; i < 30; i++) { - let day = new Date(new Date().setDate(new Date().getDate() - i)); - day = new Date(day.setMilliseconds(999)); - day = new Date(day.setSeconds(59)); - day = new Date(day.setMinutes(59)); - day = new Date(day.setHours(23)); - // day = day.getTime(); - - const count = following.filter(f => - f.created_at < day && (f.deleted_at == null || f.deleted_at > day) - ).length; - - graph.push({ - date: { - year: day.getFullYear(), - month: day.getMonth() + 1, // In JavaScript, month is zero-based. - day: day.getDate() - }, - count: count - }); - } - - res(graph); -}); diff --git a/src/api/endpoints/aggregation/users/following.ts b/src/api/endpoints/aggregation/users/following.ts deleted file mode 100644 index 92da7e692..000000000 --- a/src/api/endpoints/aggregation/users/following.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import User from '../../../models/user'; -import Following from '../../../models/following'; - -/** - * Aggregate following of a user - * - * @param {any} params - * @return {Promise} - */ -module.exports = (params) => new Promise(async (res, rej) => { - // Get 'user_id' parameter - const [userId, userIdErr] = $(params.user_id).id().$; - if (userIdErr) return rej('invalid user_id param'); - - // Lookup user - const user = await User.findOne({ - _id: userId - }, { - fields: { - _id: true - } - }); - - if (user === null) { - return rej('user not found'); - } - - const startTime = new Date(new Date().setMonth(new Date().getMonth() - 1)); - - const following = await Following - .find({ - follower_id: user._id, - $or: [ - { deleted_at: { $exists: false } }, - { deleted_at: { $gt: startTime } } - ] - }, { - _id: false, - follower_id: false, - followee_id: false - }, { - sort: { created_at: -1 } - }); - - const graph = []; - - for (let i = 0; i < 30; i++) { - let day = new Date(new Date().setDate(new Date().getDate() - i)); - day = new Date(day.setMilliseconds(999)); - day = new Date(day.setSeconds(59)); - day = new Date(day.setMinutes(59)); - day = new Date(day.setHours(23)); - - const count = following.filter(f => - f.created_at < day && (f.deleted_at == null || f.deleted_at > day) - ).length; - - graph.push({ - date: { - year: day.getFullYear(), - month: day.getMonth() + 1, // In JavaScript, month is zero-based. - day: day.getDate() - }, - count: count - }); - } - - res(graph); -}); diff --git a/src/api/endpoints/app/show.ts b/src/api/endpoints/app/show.ts deleted file mode 100644 index 054aab859..000000000 --- a/src/api/endpoints/app/show.ts +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import App from '../../models/app'; -import serialize from '../../serializers/app'; - -/** - * @swagger - * /app/show: - * post: - * summary: Show an application's information - * description: Require app_id or name_id - * parameters: - * - - * name: app_id - * description: Application ID - * in: formData - * type: string - * - - * name: name_id - * description: Application unique name - * in: formData - * type: string - * - * responses: - * 200: - * description: Success - * schema: - * $ref: "#/definitions/Application" - * - * default: - * description: Failed - * schema: - * $ref: "#/definitions/Error" - */ - -/** - * Show an app - * - * @param {any} params - * @param {any} user - * @param {any} _ - * @param {any} isSecure - * @return {Promise} - */ -module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => { - // Get 'app_id' parameter - const [appId, appIdErr] = $(params.app_id).optional.id().$; - if (appIdErr) return rej('invalid app_id param'); - - // Get 'name_id' parameter - const [nameId, nameIdErr] = $(params.name_id).optional.string().$; - if (nameIdErr) return rej('invalid name_id param'); - - if (appId === undefined && nameId === undefined) { - return rej('app_id or name_id is required'); - } - - // Lookup app - const app = appId !== undefined - ? await App.findOne({ _id: appId }) - : await App.findOne({ name_id_lower: nameId.toLowerCase() }); - - if (app === null) { - return rej('app not found'); - } - - // Send response - res(await serialize(app, user, { - includeSecret: isSecure && app.user_id.equals(user._id) - })); -}); diff --git a/src/api/endpoints/channels.ts b/src/api/endpoints/channels.ts deleted file mode 100644 index e10c94389..000000000 --- a/src/api/endpoints/channels.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Channel from '../models/channel'; -import serialize from '../serializers/channel'; - -/** - * Get all channels - * - * @param {any} params - * @param {any} me - * @return {Promise} - */ -module.exports = (params, me) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - // Construct query - const sort = { - _id: -1 - }; - const query = {} as any; - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - - // Issue query - const channels = await Channel - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(channels.map(async channel => - await serialize(channel, me)))); -}); diff --git a/src/api/endpoints/channels/create.ts b/src/api/endpoints/channels/create.ts deleted file mode 100644 index a8d7c29dc..000000000 --- a/src/api/endpoints/channels/create.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Channel from '../../models/channel'; -import Watching from '../../models/channel-watching'; -import serialize from '../../serializers/channel'; - -/** - * Create a channel - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = async (params, user) => new Promise(async (res, rej) => { - // Get 'title' parameter - const [title, titleErr] = $(params.title).string().range(1, 100).$; - if (titleErr) return rej('invalid title param'); - - // Create a channel - const channel = await Channel.insert({ - created_at: new Date(), - user_id: user._id, - title: title, - index: 0, - watching_count: 1 - }); - - // Response - res(await serialize(channel)); - - // Create Watching - await Watching.insert({ - created_at: new Date(), - user_id: user._id, - channel_id: channel._id - }); -}); diff --git a/src/api/endpoints/channels/posts.ts b/src/api/endpoints/channels/posts.ts deleted file mode 100644 index 5c071a124..000000000 --- a/src/api/endpoints/channels/posts.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import { default as Channel, IChannel } from '../../models/channel'; -import Post from '../../models/post'; -import serialize from '../../serializers/post'; - -/** - * Show a posts of a channel - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 1000, limitErr] = $(params.limit).optional.number().range(1, 1000).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - // Get 'channel_id' parameter - const [channelId, channelIdErr] = $(params.channel_id).id().$; - if (channelIdErr) return rej('invalid channel_id param'); - - // Fetch channel - const channel: IChannel = await Channel.findOne({ - _id: channelId - }); - - if (channel === null) { - return rej('channel not found'); - } - - //#region Construct query - const sort = { - _id: -1 - }; - - const query = { - channel_id: channel._id - } as any; - - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - //#endregion Construct query - - // Issue query - const posts = await Post - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(posts.map(async (post) => - await serialize(post, user) - ))); -}); diff --git a/src/api/endpoints/channels/show.ts b/src/api/endpoints/channels/show.ts deleted file mode 100644 index 8861e5459..000000000 --- a/src/api/endpoints/channels/show.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import { default as Channel, IChannel } from '../../models/channel'; -import serialize from '../../serializers/channel'; - -/** - * Show a channel - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'channel_id' parameter - const [channelId, channelIdErr] = $(params.channel_id).id().$; - if (channelIdErr) return rej('invalid channel_id param'); - - // Fetch channel - const channel: IChannel = await Channel.findOne({ - _id: channelId - }); - - if (channel === null) { - return rej('channel not found'); - } - - // Serialize - res(await serialize(channel, user)); -}); diff --git a/src/api/endpoints/drive/files.ts b/src/api/endpoints/drive/files.ts deleted file mode 100644 index b2e094775..000000000 --- a/src/api/endpoints/drive/files.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import DriveFile from '../../models/drive-file'; -import serialize from '../../serializers/drive-file'; - -/** - * Get drive files - * - * @param {any} params - * @param {any} user - * @param {any} app - * @return {Promise} - */ -module.exports = async (params, user, app) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) throw 'invalid limit param'; - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) throw 'invalid since_id param'; - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) throw 'invalid max_id param'; - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - throw 'cannot set since_id and max_id'; - } - - // Get 'folder_id' parameter - const [folderId = null, folderIdErr] = $(params.folder_id).optional.nullable.id().$; - if (folderIdErr) throw 'invalid folder_id param'; - - // Get 'type' parameter - const [type, typeErr] = $(params.type).optional.string().match(/^[a-zA-Z\/\-\*]+$/).$; - if (typeErr) throw 'invalid type param'; - - // Construct query - const sort = { - _id: -1 - }; - const query = { - 'metadata.user_id': user._id, - 'metadata.folder_id': folderId - } as any; - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - if (type) { - query.contentType = new RegExp(`^${type.replace(/\*/g, '.+?')}$`); - } - - // Issue query - const files = await DriveFile - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - const _files = await Promise.all(files.map(file => serialize(file))); - return _files; -}; diff --git a/src/api/endpoints/drive/files/create.ts b/src/api/endpoints/drive/files/create.ts deleted file mode 100644 index 7546eca30..000000000 --- a/src/api/endpoints/drive/files/create.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import { validateFileName } from '../../../models/drive-file'; -import serialize from '../../../serializers/drive-file'; -import create from '../../../common/add-file-to-drive'; - -/** - * Create a file - * - * @param {any} file - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = async (file, params, user): Promise => { - if (file == null) { - throw 'file is required'; - } - - // Get 'name' parameter - let name = file.originalname; - if (name !== undefined && name !== null) { - name = name.trim(); - if (name.length === 0) { - name = null; - } else if (name === 'blob') { - name = null; - } else if (!validateFileName(name)) { - throw 'invalid name'; - } - } else { - name = null; - } - - // Get 'folder_id' parameter - const [folderId = null, folderIdErr] = $(params.folder_id).optional.nullable.id().$; - if (folderIdErr) throw 'invalid folder_id param'; - - // Create file - const driveFile = await create(user, file.path, name, null, folderId); - - // Serialize - return serialize(driveFile); -}; diff --git a/src/api/endpoints/drive/files/find.ts b/src/api/endpoints/drive/files/find.ts deleted file mode 100644 index a1cdf1643..000000000 --- a/src/api/endpoints/drive/files/find.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import DriveFile from '../../../models/drive-file'; -import serialize from '../../../serializers/drive-file'; - -/** - * Find a file(s) - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'name' parameter - const [name, nameErr] = $(params.name).string().$; - if (nameErr) return rej('invalid name param'); - - // Get 'folder_id' parameter - const [folderId = null, folderIdErr] = $(params.folder_id).optional.nullable.id().$; - if (folderIdErr) return rej('invalid folder_id param'); - - // Issue query - const files = await DriveFile - .find({ - filename: name, - 'metadata.user_id': user._id, - 'metadata.folder_id': folderId - }); - - // Serialize - res(await Promise.all(files.map(async file => - await serialize(file)))); -}); diff --git a/src/api/endpoints/drive/files/show.ts b/src/api/endpoints/drive/files/show.ts deleted file mode 100644 index 3c7cf774f..000000000 --- a/src/api/endpoints/drive/files/show.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import DriveFile from '../../../models/drive-file'; -import serialize from '../../../serializers/drive-file'; - -/** - * Show a file - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = async (params, user) => { - // Get 'file_id' parameter - const [fileId, fileIdErr] = $(params.file_id).id().$; - if (fileIdErr) throw 'invalid file_id param'; - - // Fetch file - const file = await DriveFile - .findOne({ - _id: fileId, - 'metadata.user_id': user._id - }); - - if (file === null) { - throw 'file-not-found'; - } - - // Serialize - const _file = await serialize(file, { - detail: true - }); - - return _file; -}; diff --git a/src/api/endpoints/drive/files/update.ts b/src/api/endpoints/drive/files/update.ts deleted file mode 100644 index f39a420d6..000000000 --- a/src/api/endpoints/drive/files/update.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import DriveFolder from '../../../models/drive-folder'; -import DriveFile from '../../../models/drive-file'; -import { validateFileName } from '../../../models/drive-file'; -import serialize from '../../../serializers/drive-file'; -import { publishDriveStream } from '../../../event'; - -/** - * Update a file - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'file_id' parameter - const [fileId, fileIdErr] = $(params.file_id).id().$; - if (fileIdErr) return rej('invalid file_id param'); - - // Fetch file - const file = await DriveFile - .findOne({ - _id: fileId, - 'metadata.user_id': user._id - }); - - if (file === null) { - return rej('file-not-found'); - } - - // Get 'name' parameter - const [name, nameErr] = $(params.name).optional.string().pipe(validateFileName).$; - if (nameErr) return rej('invalid name param'); - if (name) file.filename = name; - - // Get 'folder_id' parameter - const [folderId, folderIdErr] = $(params.folder_id).optional.nullable.id().$; - if (folderIdErr) return rej('invalid folder_id param'); - - if (folderId !== undefined) { - if (folderId === null) { - file.metadata.folder_id = null; - } else { - // Fetch folder - const folder = await DriveFolder - .findOne({ - _id: folderId, - user_id: user._id - }); - - if (folder === null) { - return rej('folder-not-found'); - } - - file.metadata.folder_id = folder._id; - } - } - - await DriveFile.update(file._id, { - $set: { - filename: file.filename, - 'metadata.folder_id': file.metadata.folder_id - } - }); - - // Serialize - const fileObj = await serialize(file); - - // Response - res(fileObj); - - // Publish file_updated event - publishDriveStream(user._id, 'file_updated', fileObj); -}); diff --git a/src/api/endpoints/drive/files/upload_from_url.ts b/src/api/endpoints/drive/files/upload_from_url.ts deleted file mode 100644 index 519e0bdf6..000000000 --- a/src/api/endpoints/drive/files/upload_from_url.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Module dependencies - */ -import * as URL from 'url'; -import $ from 'cafy'; -import { validateFileName } from '../../../models/drive-file'; -import serialize from '../../../serializers/drive-file'; -import create from '../../../common/add-file-to-drive'; -import * as debug from 'debug'; -import * as tmp from 'tmp'; -import * as fs from 'fs'; -import * as request from 'request'; - -const log = debug('misskey:endpoint:upload_from_url'); - -/** - * Create a file from a URL - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = async (params, user): Promise => { - // Get 'url' parameter - // TODO: Validate this url - const [url, urlErr] = $(params.url).string().$; - if (urlErr) throw 'invalid url param'; - - let name = URL.parse(url).pathname.split('/').pop(); - if (!validateFileName(name)) { - name = null; - } - - // Get 'folder_id' parameter - const [folderId = null, folderIdErr] = $(params.folder_id).optional.nullable.id().$; - if (folderIdErr) throw 'invalid folder_id param'; - - // Create temp file - const path = await new Promise((res: (string) => void, rej) => { - tmp.file((e, path) => { - if (e) return rej(e); - res(path); - }); - }); - - // write content at URL to temp file - await new Promise((res, rej) => { - const writable = fs.createWriteStream(path); - request(url) - .on('error', rej) - .on('end', () => { - writable.close(); - res(path); - }) - .pipe(writable) - .on('error', rej); - }); - - const driveFile = await create(user, path, name, null, folderId); - - // clean-up - fs.unlink(path, (e) => { - if (e) log(e.stack); - }); - - return serialize(driveFile); -}; diff --git a/src/api/endpoints/drive/folders.ts b/src/api/endpoints/drive/folders.ts deleted file mode 100644 index d49ef0af0..000000000 --- a/src/api/endpoints/drive/folders.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import DriveFolder from '../../models/drive-folder'; -import serialize from '../../serializers/drive-folder'; - -/** - * Get drive folders - * - * @param {any} params - * @param {any} user - * @param {any} app - * @return {Promise} - */ -module.exports = (params, user, app) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - // Get 'folder_id' parameter - const [folderId = null, folderIdErr] = $(params.folder_id).optional.nullable.id().$; - if (folderIdErr) return rej('invalid folder_id param'); - - // Construct query - const sort = { - _id: -1 - }; - const query = { - user_id: user._id, - parent_id: folderId - } as any; - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - - // Issue query - const folders = await DriveFolder - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(folders.map(async folder => - await serialize(folder)))); -}); diff --git a/src/api/endpoints/drive/folders/create.ts b/src/api/endpoints/drive/folders/create.ts deleted file mode 100644 index be847b215..000000000 --- a/src/api/endpoints/drive/folders/create.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import DriveFolder from '../../../models/drive-folder'; -import { isValidFolderName } from '../../../models/drive-folder'; -import serialize from '../../../serializers/drive-folder'; -import { publishDriveStream } from '../../../event'; - -/** - * Create drive folder - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'name' parameter - const [name = '無題のフォルダー', nameErr] = $(params.name).optional.string().pipe(isValidFolderName).$; - if (nameErr) return rej('invalid name param'); - - // Get 'parent_id' parameter - const [parentId = null, parentIdErr] = $(params.parent_id).optional.nullable.id().$; - if (parentIdErr) return rej('invalid parent_id param'); - - // If the parent folder is specified - let parent = null; - if (parentId) { - // Fetch parent folder - parent = await DriveFolder - .findOne({ - _id: parentId, - user_id: user._id - }); - - if (parent === null) { - return rej('parent-not-found'); - } - } - - // Create folder - const folder = await DriveFolder.insert({ - created_at: new Date(), - name: name, - parent_id: parent !== null ? parent._id : null, - user_id: user._id - }); - - // Serialize - const folderObj = await serialize(folder); - - // Response - res(folderObj); - - // Publish folder_created event - publishDriveStream(user._id, 'folder_created', folderObj); -}); diff --git a/src/api/endpoints/drive/folders/find.ts b/src/api/endpoints/drive/folders/find.ts deleted file mode 100644 index a5eb8e015..000000000 --- a/src/api/endpoints/drive/folders/find.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import DriveFolder from '../../../models/drive-folder'; -import serialize from '../../../serializers/drive-folder'; - -/** - * Find a folder(s) - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'name' parameter - const [name, nameErr] = $(params.name).string().$; - if (nameErr) return rej('invalid name param'); - - // Get 'parent_id' parameter - const [parentId = null, parentIdErr] = $(params.parent_id).optional.nullable.id().$; - if (parentIdErr) return rej('invalid parent_id param'); - - // Issue query - const folders = await DriveFolder - .find({ - name: name, - user_id: user._id, - parent_id: parentId - }); - - // Serialize - res(await Promise.all(folders.map(folder => serialize(folder)))); -}); diff --git a/src/api/endpoints/drive/folders/show.ts b/src/api/endpoints/drive/folders/show.ts deleted file mode 100644 index 9b1c04ca3..000000000 --- a/src/api/endpoints/drive/folders/show.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import DriveFolder from '../../../models/drive-folder'; -import serialize from '../../../serializers/drive-folder'; - -/** - * Show a folder - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'folder_id' parameter - const [folderId, folderIdErr] = $(params.folder_id).id().$; - if (folderIdErr) return rej('invalid folder_id param'); - - // Get folder - const folder = await DriveFolder - .findOne({ - _id: folderId, - user_id: user._id - }); - - if (folder === null) { - return rej('folder-not-found'); - } - - // Serialize - res(await serialize(folder, { - detail: true - })); -}); diff --git a/src/api/endpoints/drive/stream.ts b/src/api/endpoints/drive/stream.ts deleted file mode 100644 index 7ee255e5d..000000000 --- a/src/api/endpoints/drive/stream.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import DriveFile from '../../models/drive-file'; -import serialize from '../../serializers/drive-file'; - -/** - * Get drive stream - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - // Get 'type' parameter - const [type, typeErr] = $(params.type).optional.string().match(/^[a-zA-Z\/\-\*]+$/).$; - if (typeErr) return rej('invalid type param'); - - // Construct query - const sort = { - _id: -1 - }; - const query = { - 'metadata.user_id': user._id - } as any; - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - if (type) { - query.contentType = new RegExp(`^${type.replace(/\*/g, '.+?')}$`); - } - - // Issue query - const files = await DriveFile - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(files.map(async file => - await serialize(file)))); -}); diff --git a/src/api/endpoints/following/create.ts b/src/api/endpoints/following/create.ts deleted file mode 100644 index b4a2217b1..000000000 --- a/src/api/endpoints/following/create.ts +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import User from '../../models/user'; -import Following from '../../models/following'; -import notify from '../../common/notify'; -import event from '../../event'; -import serializeUser from '../../serializers/user'; - -/** - * Follow a user - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - const follower = user; - - // Get 'user_id' parameter - const [userId, userIdErr] = $(params.user_id).id().$; - if (userIdErr) return rej('invalid user_id param'); - - // 自分自身 - if (user._id.equals(userId)) { - return rej('followee is yourself'); - } - - // Get followee - const followee = await User.findOne({ - _id: userId - }, { - fields: { - data: false, - profile: false - } - }); - - if (followee === null) { - return rej('user not found'); - } - - // Check if already following - const exist = await Following.findOne({ - follower_id: follower._id, - followee_id: followee._id, - deleted_at: { $exists: false } - }); - - if (exist !== null) { - return rej('already following'); - } - - // Create following - await Following.insert({ - created_at: new Date(), - follower_id: follower._id, - followee_id: followee._id - }); - - // Send response - res(); - - // Increment following count - User.update(follower._id, { - $inc: { - following_count: 1 - } - }); - - // Increment followers count - User.update({ _id: followee._id }, { - $inc: { - followers_count: 1 - } - }); - - // Publish follow event - event(follower._id, 'follow', await serializeUser(followee, follower)); - event(followee._id, 'followed', await serializeUser(follower, followee)); - - // Notify - notify(followee._id, follower._id, 'follow'); -}); diff --git a/src/api/endpoints/following/delete.ts b/src/api/endpoints/following/delete.ts deleted file mode 100644 index aa1639ef6..000000000 --- a/src/api/endpoints/following/delete.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import User from '../../models/user'; -import Following from '../../models/following'; -import event from '../../event'; -import serializeUser from '../../serializers/user'; - -/** - * Unfollow a user - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - const follower = user; - - // Get 'user_id' parameter - const [userId, userIdErr] = $(params.user_id).id().$; - if (userIdErr) return rej('invalid user_id param'); - - // Check if the followee is yourself - if (user._id.equals(userId)) { - return rej('followee is yourself'); - } - - // Get followee - const followee = await User.findOne({ - _id: userId - }, { - fields: { - data: false, - profile: false - } - }); - - if (followee === null) { - return rej('user not found'); - } - - // Check not following - const exist = await Following.findOne({ - follower_id: follower._id, - followee_id: followee._id, - deleted_at: { $exists: false } - }); - - if (exist === null) { - return rej('already not following'); - } - - // Delete following - await Following.update({ - _id: exist._id - }, { - $set: { - deleted_at: new Date() - } - }); - - // Send response - res(); - - // Decrement following count - User.update({ _id: follower._id }, { - $inc: { - following_count: -1 - } - }); - - // Decrement followers count - User.update({ _id: followee._id }, { - $inc: { - followers_count: -1 - } - }); - - // Publish follow event - event(follower._id, 'unfollow', await serializeUser(followee, follower)); -}); diff --git a/src/api/endpoints/i.ts b/src/api/endpoints/i.ts deleted file mode 100644 index ae75f11d5..000000000 --- a/src/api/endpoints/i.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Module dependencies - */ -import User from '../models/user'; -import serialize from '../serializers/user'; - -/** - * Show myself - * - * @param {any} params - * @param {any} user - * @param {any} app - * @param {Boolean} isSecure - * @return {Promise} - */ -module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => { - // Serialize - res(await serialize(user, user, { - detail: true, - includeSecrets: isSecure - })); - - // Update lastUsedAt - User.update({ _id: user._id }, { - $set: { - last_used_at: new Date() - } - }); -}); diff --git a/src/api/endpoints/i/appdata/get.ts b/src/api/endpoints/i/appdata/get.ts deleted file mode 100644 index 571208d46..000000000 --- a/src/api/endpoints/i/appdata/get.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Appdata from '../../../models/appdata'; - -/** - * Get app data - * - * @param {any} params - * @param {any} user - * @param {any} app - * @param {Boolean} isSecure - * @return {Promise} - */ -module.exports = (params, user, app) => new Promise(async (res, rej) => { - if (app == null) return rej('このAPIはサードパーティAppからのみ利用できます'); - - // Get 'key' parameter - const [key = null, keyError] = $(params.key).optional.nullable.string().match(/[a-z_]+/).$; - if (keyError) return rej('invalid key param'); - - const select = {}; - if (key !== null) { - select[`data.${key}`] = true; - } - const appdata = await Appdata.findOne({ - app_id: app._id, - user_id: user._id - }, { - fields: select - }); - - if (appdata) { - res(appdata.data); - } else { - res(); - } -}); diff --git a/src/api/endpoints/i/appdata/set.ts b/src/api/endpoints/i/appdata/set.ts deleted file mode 100644 index 2804a14cb..000000000 --- a/src/api/endpoints/i/appdata/set.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Appdata from '../../../models/appdata'; - -/** - * Set app data - * - * @param {any} params - * @param {any} user - * @param {any} app - * @param {Boolean} isSecure - * @return {Promise} - */ -module.exports = (params, user, app) => new Promise(async (res, rej) => { - if (app == null) return rej('このAPIはサードパーティAppからのみ利用できます'); - - // Get 'data' parameter - const [data, dataError] = $(params.data).optional.object() - .pipe(obj => { - const hasInvalidData = Object.entries(obj).some(([k, v]) => - $(k).string().match(/^[a-z_]+$/).nok() && $(v).string().nok()); - return !hasInvalidData; - }).$; - if (dataError) return rej('invalid data param'); - - // Get 'key' parameter - const [key, keyError] = $(params.key).optional.string().match(/[a-z_]+/).$; - if (keyError) return rej('invalid key param'); - - // Get 'value' parameter - const [value, valueError] = $(params.value).optional.string().$; - if (valueError) return rej('invalid value param'); - - const set = {}; - if (data) { - Object.entries(data).forEach(([k, v]) => { - set[`data.${k}`] = v; - }); - } else { - set[`data.${key}`] = value; - } - - await Appdata.update({ - app_id: app._id, - user_id: user._id - }, Object.assign({ - app_id: app._id, - user_id: user._id - }, { - $set: set - }), { - upsert: true - }); - - res(204); -}); diff --git a/src/api/endpoints/i/favorites.ts b/src/api/endpoints/i/favorites.ts deleted file mode 100644 index a66eaa754..000000000 --- a/src/api/endpoints/i/favorites.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Favorite from '../../models/favorite'; -import serialize from '../../serializers/post'; - -/** - * Get followers of a user - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; - if (offsetErr) return rej('invalid offset param'); - - // Get 'sort' parameter - const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').$; - if (sortError) return rej('invalid sort param'); - - // Get favorites - const favorites = await Favorite - .find({ - user_id: user._id - }, { - limit: limit, - skip: offset, - sort: { - _id: sort == 'asc' ? 1 : -1 - } - }); - - // Serialize - res(await Promise.all(favorites.map(async favorite => - await serialize(favorite.post) - ))); -}); diff --git a/src/api/endpoints/i/notifications.ts b/src/api/endpoints/i/notifications.ts deleted file mode 100644 index 607e0768a..000000000 --- a/src/api/endpoints/i/notifications.ts +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Notification from '../../models/notification'; -import serialize from '../../serializers/notification'; -import getFriends from '../../common/get-friends'; -import read from '../../common/read-notification'; - -/** - * Get notifications - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'following' parameter - const [following = false, followingError] = - $(params.following).optional.boolean().$; - if (followingError) return rej('invalid following param'); - - // Get 'mark_as_read' parameter - const [markAsRead = true, markAsReadErr] = $(params.mark_as_read).optional.boolean().$; - if (markAsReadErr) return rej('invalid mark_as_read param'); - - // Get 'type' parameter - const [type, typeErr] = $(params.type).optional.array('string').unique().$; - if (typeErr) return rej('invalid type param'); - - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - const query = { - notifiee_id: user._id - } as any; - - const sort = { - _id: -1 - }; - - if (following) { - // ID list of the user $self and other users who the user follows - const followingIds = await getFriends(user._id); - - query.notifier_id = { - $in: followingIds - }; - } - - if (type) { - query.type = { - $in: type - }; - } - - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - - // Issue query - const notifications = await Notification - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(notifications.map(async notification => - await serialize(notification)))); - - // Mark as read all - if (notifications.length > 0 && markAsRead) { - read(user._id, notifications); - } -}); diff --git a/src/api/endpoints/i/pin.ts b/src/api/endpoints/i/pin.ts deleted file mode 100644 index a94950d22..000000000 --- a/src/api/endpoints/i/pin.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import User from '../../models/user'; -import Post from '../../models/post'; -import serialize from '../../serializers/user'; - -/** - * Pin post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = async (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Fetch pinee - const post = await Post.findOne({ - _id: postId, - user_id: user._id - }); - - if (post === null) { - return rej('post not found'); - } - - await User.update(user._id, { - $set: { - pinned_post_id: post._id - } - }); - - // Serialize - const iObj = await serialize(user, user, { - detail: true - }); - - // Send response - res(iObj); -}); diff --git a/src/api/endpoints/i/signin_history.ts b/src/api/endpoints/i/signin_history.ts deleted file mode 100644 index 1a6e50c7c..000000000 --- a/src/api/endpoints/i/signin_history.ts +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Signin from '../../models/signin'; -import serialize from '../../serializers/signin'; - -/** - * Get signin history of my account - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - const query = { - user_id: user._id - } as any; - - const sort = { - _id: -1 - }; - - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - - // Issue query - const history = await Signin - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(history.map(async record => - await serialize(record)))); -}); diff --git a/src/api/endpoints/i/update.ts b/src/api/endpoints/i/update.ts deleted file mode 100644 index c484c51a9..000000000 --- a/src/api/endpoints/i/update.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import User from '../../models/user'; -import { isValidName, isValidDescription, isValidLocation, isValidBirthday } from '../../models/user'; -import serialize from '../../serializers/user'; -import event from '../../event'; -import config from '../../../conf'; - -/** - * Update myself - * - * @param {any} params - * @param {any} user - * @param {any} _ - * @param {boolean} isSecure - * @return {Promise} - */ -module.exports = async (params, user, _, isSecure) => new Promise(async (res, rej) => { - // Get 'name' parameter - const [name, nameErr] = $(params.name).optional.string().pipe(isValidName).$; - if (nameErr) return rej('invalid name param'); - if (name) user.name = name; - - // Get 'description' parameter - const [description, descriptionErr] = $(params.description).optional.nullable.string().pipe(isValidDescription).$; - if (descriptionErr) return rej('invalid description param'); - if (description !== undefined) user.description = description; - - // Get 'location' parameter - const [location, locationErr] = $(params.location).optional.nullable.string().pipe(isValidLocation).$; - if (locationErr) return rej('invalid location param'); - if (location !== undefined) user.profile.location = location; - - // Get 'birthday' parameter - const [birthday, birthdayErr] = $(params.birthday).optional.nullable.string().pipe(isValidBirthday).$; - if (birthdayErr) return rej('invalid birthday param'); - if (birthday !== undefined) user.profile.birthday = birthday; - - // Get 'avatar_id' parameter - const [avatarId, avatarIdErr] = $(params.avatar_id).optional.id().$; - if (avatarIdErr) return rej('invalid avatar_id param'); - if (avatarId) user.avatar_id = avatarId; - - // Get 'banner_id' parameter - const [bannerId, bannerIdErr] = $(params.banner_id).optional.id().$; - if (bannerIdErr) return rej('invalid banner_id param'); - if (bannerId) user.banner_id = bannerId; - - // Get 'show_donation' parameter - const [showDonation, showDonationErr] = $(params.show_donation).optional.boolean().$; - if (showDonationErr) return rej('invalid show_donation param'); - if (showDonation) user.client_settings.show_donation = showDonation; - - await User.update(user._id, { - $set: { - name: user.name, - description: user.description, - avatar_id: user.avatar_id, - banner_id: user.banner_id, - profile: user.profile, - 'client_settings.show_donation': user.client_settings.show_donation - } - }); - - // Serialize - const iObj = await serialize(user, user, { - detail: true, - includeSecrets: isSecure - }); - - // Send response - res(iObj); - - // Publish i updated event - event(user._id, 'i_updated', iObj); - - // Update search index - if (config.elasticsearch.enable) { - const es = require('../../../db/elasticsearch'); - - es.index({ - index: 'misskey', - type: 'user', - id: user._id.toString(), - body: { - name: user.name, - bio: user.bio - } - }); - } -}); diff --git a/src/api/endpoints/i/update_home.ts b/src/api/endpoints/i/update_home.ts deleted file mode 100644 index 429e88529..000000000 --- a/src/api/endpoints/i/update_home.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import User from '../../models/user'; - -/** - * Update myself - * - * @param {any} params - * @param {any} user - * @param {any} _ - * @param {boolean} isSecure - * @return {Promise} - */ -module.exports = async (params, user, _, isSecure) => new Promise(async (res, rej) => { - // Get 'home' parameter - const [home, homeErr] = $(params.home).optional.array().each( - $().strict.object() - .have('name', $().string()) - .have('id', $().string()) - .have('place', $().string()) - .have('data', $().object())).$; - if (homeErr) return rej('invalid home param'); - - // Get 'id' parameter - const [id, idErr] = $(params.id).optional.string().$; - if (idErr) return rej('invalid id param'); - - // Get 'data' parameter - const [data, dataErr] = $(params.data).optional.object().$; - if (dataErr) return rej('invalid data param'); - - if (home) { - await User.update(user._id, { - $set: { - 'client_settings.home': home - } - }); - - res(); - } else { - if (id == null && data == null) return rej('you need to set id and data params if home param unset'); - - const _home = user.client_settings.home; - const widget = _home.find(w => w.id == id); - - if (widget == null) return rej('widget not found'); - - widget.data = data; - - await User.update(user._id, { - $set: { - 'client_settings.home': _home - } - }); - - res(); - } -}); diff --git a/src/api/endpoints/messaging/history.ts b/src/api/endpoints/messaging/history.ts deleted file mode 100644 index 5f7c9276d..000000000 --- a/src/api/endpoints/messaging/history.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import History from '../../models/messaging-history'; -import serialize from '../../serializers/messaging-message'; - -/** - * Show messaging history - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get history - const history = await History - .find({ - user_id: user._id - }, { - limit: limit, - sort: { - updated_at: -1 - } - }); - - // Serialize - res(await Promise.all(history.map(async h => - await serialize(h.message, user)))); -}); diff --git a/src/api/endpoints/messaging/messages.ts b/src/api/endpoints/messaging/messages.ts deleted file mode 100644 index 7b270924e..000000000 --- a/src/api/endpoints/messaging/messages.ts +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Message from '../../models/messaging-message'; -import User from '../../models/user'; -import serialize from '../../serializers/messaging-message'; -import read from '../../common/read-messaging-message'; - -/** - * Get messages - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'user_id' parameter - const [recipientId, recipientIdErr] = $(params.user_id).id().$; - if (recipientIdErr) return rej('invalid user_id param'); - - // Fetch recipient - const recipient = await User.findOne({ - _id: recipientId - }, { - fields: { - _id: true - } - }); - - if (recipient === null) { - return rej('user not found'); - } - - // Get 'mark_as_read' parameter - const [markAsRead = true, markAsReadErr] = $(params.mark_as_read).optional.boolean().$; - if (markAsReadErr) return rej('invalid mark_as_read param'); - - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - const query = { - $or: [{ - user_id: user._id, - recipient_id: recipient._id - }, { - user_id: recipient._id, - recipient_id: user._id - }] - } as any; - - const sort = { - _id: -1 - }; - - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - - // Issue query - const messages = await Message - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(messages.map(async message => - await serialize(message, user, { - populateRecipient: false - })))); - - if (messages.length === 0) { - return; - } - - // Mark as read all - if (markAsRead) { - read(user._id, recipient._id, messages); - } -}); diff --git a/src/api/endpoints/messaging/messages/create.ts b/src/api/endpoints/messaging/messages/create.ts deleted file mode 100644 index 3c7689f96..000000000 --- a/src/api/endpoints/messaging/messages/create.ts +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Message from '../../../models/messaging-message'; -import { isValidText } from '../../../models/messaging-message'; -import History from '../../../models/messaging-history'; -import User from '../../../models/user'; -import DriveFile from '../../../models/drive-file'; -import serialize from '../../../serializers/messaging-message'; -import publishUserStream from '../../../event'; -import { publishMessagingStream, publishMessagingIndexStream, pushSw } from '../../../event'; -import config from '../../../../conf'; - -/** - * Create a message - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'user_id' parameter - const [recipientId, recipientIdErr] = $(params.user_id).id().$; - if (recipientIdErr) return rej('invalid user_id param'); - - // Myself - if (recipientId.equals(user._id)) { - return rej('cannot send message to myself'); - } - - // Fetch recipient - const recipient = await User.findOne({ - _id: recipientId - }, { - fields: { - _id: true - } - }); - - if (recipient === null) { - return rej('user not found'); - } - - // Get 'text' parameter - const [text, textErr] = $(params.text).optional.string().pipe(isValidText).$; - if (textErr) return rej('invalid text'); - - // Get 'file_id' parameter - const [fileId, fileIdErr] = $(params.file_id).optional.id().$; - if (fileIdErr) return rej('invalid file_id param'); - - let file = null; - if (fileId !== undefined) { - file = await DriveFile.findOne({ - _id: fileId, - 'metadata.user_id': user._id - }); - - if (file === null) { - return rej('file not found'); - } - } - - // テキストが無いかつ添付ファイルも無かったらエラー - if (text === undefined && file === null) { - return rej('text or file is required'); - } - - // メッセージを作成 - const message = await Message.insert({ - created_at: new Date(), - file_id: file ? file._id : undefined, - recipient_id: recipient._id, - text: text ? text : undefined, - user_id: user._id, - is_read: false - }); - - // Serialize - const messageObj = await serialize(message); - - // Reponse - res(messageObj); - - // 自分のストリーム - publishMessagingStream(message.user_id, message.recipient_id, 'message', messageObj); - publishMessagingIndexStream(message.user_id, 'message', messageObj); - publishUserStream(message.user_id, 'messaging_message', messageObj); - - // 相手のストリーム - publishMessagingStream(message.recipient_id, message.user_id, 'message', messageObj); - publishMessagingIndexStream(message.recipient_id, 'message', messageObj); - publishUserStream(message.recipient_id, 'messaging_message', messageObj); - - // 3秒経っても(今回作成した)メッセージが既読にならなかったら「未読のメッセージがありますよ」イベントを発行する - setTimeout(async () => { - const freshMessage = await Message.findOne({ _id: message._id }, { is_read: true }); - if (!freshMessage.is_read) { - publishUserStream(message.recipient_id, 'unread_messaging_message', messageObj); - pushSw(message.recipient_id, 'unread_messaging_message', messageObj); - } - }, 3000); - - // Register to search database - if (message.text && config.elasticsearch.enable) { - const es = require('../../../db/elasticsearch'); - - es.index({ - index: 'misskey', - type: 'messaging_message', - id: message._id.toString(), - body: { - text: message.text - } - }); - } - - // 履歴作成(自分) - History.update({ - user_id: user._id, - partner: recipient._id - }, { - updated_at: new Date(), - user_id: user._id, - partner: recipient._id, - message: message._id - }, { - upsert: true - }); - - // 履歴作成(相手) - History.update({ - user_id: recipient._id, - partner: user._id - }, { - updated_at: new Date(), - user_id: recipient._id, - partner: user._id, - message: message._id - }, { - upsert: true - }); -}); diff --git a/src/api/endpoints/messaging/unread.ts b/src/api/endpoints/messaging/unread.ts deleted file mode 100644 index 40bc83fe1..000000000 --- a/src/api/endpoints/messaging/unread.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Module dependencies - */ -import Message from '../../models/messaging-message'; - -/** - * Get count of unread messages - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - const count = await Message - .count({ - recipient_id: user._id, - is_read: false - }); - - res({ - count: count - }); -}); diff --git a/src/api/endpoints/notifications/get_unread_count.ts b/src/api/endpoints/notifications/get_unread_count.ts deleted file mode 100644 index 9514e7871..000000000 --- a/src/api/endpoints/notifications/get_unread_count.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Module dependencies - */ -import Notification from '../../models/notification'; - -/** - * Get count of unread notifications - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - const count = await Notification - .count({ - notifiee_id: user._id, - is_read: false - }); - - res({ - count: count - }); -}); diff --git a/src/api/endpoints/posts.ts b/src/api/endpoints/posts.ts deleted file mode 100644 index f6efcc108..000000000 --- a/src/api/endpoints/posts.ts +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../models/post'; -import serialize from '../serializers/post'; - -/** - * Lists all posts - * - * @param {any} params - * @return {Promise} - */ -module.exports = (params) => new Promise(async (res, rej) => { - // Get 'reply' parameter - const [reply, replyErr] = $(params.reply).optional.boolean().$; - if (replyErr) return rej('invalid reply param'); - - // Get 'repost' parameter - const [repost, repostErr] = $(params.repost).optional.boolean().$; - if (repostErr) return rej('invalid repost param'); - - // Get 'media' parameter - const [media, mediaErr] = $(params.media).optional.boolean().$; - if (mediaErr) return rej('invalid media param'); - - // Get 'poll' parameter - const [poll, pollErr] = $(params.poll).optional.boolean().$; - if (pollErr) return rej('invalid poll param'); - - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - // Construct query - const sort = { - _id: -1 - }; - const query = {} as any; - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - - if (reply != undefined) { - query.reply_id = reply ? { $exists: true, $ne: null } : null; - } - - if (repost != undefined) { - query.repost_id = repost ? { $exists: true, $ne: null } : null; - } - - if (media != undefined) { - query.media_ids = media ? { $exists: true, $ne: null } : null; - } - - if (poll != undefined) { - query.poll = poll ? { $exists: true, $ne: null } : null; - } - - // Issue query - const posts = await Post - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(posts.map(async post => await serialize(post)))); -}); diff --git a/src/api/endpoints/posts/categorize.ts b/src/api/endpoints/posts/categorize.ts deleted file mode 100644 index 3530ba6bc..000000000 --- a/src/api/endpoints/posts/categorize.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../models/post'; - -/** - * Categorize a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - if (!user.is_pro) { - return rej('This endpoint is available only from a Pro account'); - } - - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Get categorizee - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - if (post.is_category_verified) { - return rej('This post already has the verified category'); - } - - // Get 'category' parameter - const [category, categoryErr] = $(params.category).string().or([ - 'music', 'game', 'anime', 'it', 'gadgets', 'photography' - ]).$; - if (categoryErr) return rej('invalid category param'); - - // Set category - Post.update({ _id: post._id }, { - $set: { - category: category, - is_category_verified: true - } - }); - - // Send response - res(); -}); diff --git a/src/api/endpoints/posts/context.ts b/src/api/endpoints/posts/context.ts deleted file mode 100644 index bad59a6be..000000000 --- a/src/api/endpoints/posts/context.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../models/post'; -import serialize from '../../serializers/post'; - -/** - * Show a context of a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; - if (offsetErr) return rej('invalid offset param'); - - // Lookup post - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - const context = []; - let i = 0; - - async function get(id) { - i++; - const p = await Post.findOne({ _id: id }); - - if (i > offset) { - context.push(p); - } - - if (context.length == limit) { - return; - } - - if (p.reply_id) { - await get(p.reply_id); - } - } - - if (post.reply_id) { - await get(post.reply_id); - } - - // Serialize - res(await Promise.all(context.map(async post => - await serialize(post, user)))); -}); diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts deleted file mode 100644 index ae4959dae..000000000 --- a/src/api/endpoints/posts/create.ts +++ /dev/null @@ -1,484 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import deepEqual = require('deep-equal'); -import parse from '../../common/text'; -import { default as Post, IPost, isValidText } from '../../models/post'; -import { default as User, IUser } from '../../models/user'; -import { default as Channel, IChannel } from '../../models/channel'; -import Following from '../../models/following'; -import DriveFile from '../../models/drive-file'; -import Watching from '../../models/post-watching'; -import ChannelWatching from '../../models/channel-watching'; -import serialize from '../../serializers/post'; -import notify from '../../common/notify'; -import watch from '../../common/watch-post'; -import event, { pushSw, publishChannelStream } from '../../event'; -import config from '../../../conf'; - -/** - * Create a post - * - * @param {any} params - * @param {any} user - * @param {any} app - * @return {Promise} - */ -module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { - // Get 'text' parameter - const [text, textErr] = $(params.text).optional.string().pipe(isValidText).$; - if (textErr) return rej('invalid text'); - - // Get 'media_ids' parameter - const [mediaIds, mediaIdsErr] = $(params.media_ids).optional.array('id').unique().range(1, 4).$; - if (mediaIdsErr) return rej('invalid media_ids'); - - let files = []; - if (mediaIds !== undefined) { - // Fetch files - // forEach だと途中でエラーなどがあっても return できないので - // 敢えて for を使っています。 - for (const mediaId of mediaIds) { - // Fetch file - // SELECT _id - const entity = await DriveFile.findOne({ - _id: mediaId, - 'metadata.user_id': user._id - }); - - if (entity === null) { - return rej('file not found'); - } else { - files.push(entity); - } - } - } else { - files = null; - } - - // Get 'repost_id' parameter - const [repostId, repostIdErr] = $(params.repost_id).optional.id().$; - if (repostIdErr) return rej('invalid repost_id'); - - let repost: IPost = null; - let isQuote = false; - if (repostId !== undefined) { - // Fetch repost to post - repost = await Post.findOne({ - _id: repostId - }); - - if (repost == null) { - return rej('repostee is not found'); - } else if (repost.repost_id && !repost.text && !repost.media_ids) { - return rej('cannot repost to repost'); - } - - // Fetch recently post - const latestPost = await Post.findOne({ - user_id: user._id - }, { - sort: { - _id: -1 - } - }); - - isQuote = text != null || files != null; - - // 直近と同じRepost対象かつ引用じゃなかったらエラー - if (latestPost && - latestPost.repost_id && - latestPost.repost_id.equals(repost._id) && - !isQuote) { - return rej('cannot repost same post that already reposted in your latest post'); - } - - // 直近がRepost対象かつ引用じゃなかったらエラー - if (latestPost && - latestPost._id.equals(repost._id) && - !isQuote) { - return rej('cannot repost your latest post'); - } - } - - // Get 'reply_id' parameter - const [replyId, replyIdErr] = $(params.reply_id).optional.id().$; - if (replyIdErr) return rej('invalid reply_id'); - - let reply: IPost = null; - if (replyId !== undefined) { - // Fetch reply - reply = await Post.findOne({ - _id: replyId - }); - - if (reply === null) { - return rej('in reply to post is not found'); - } - - // 返信対象が引用でないRepostだったらエラー - if (reply.repost_id && !reply.text && !reply.media_ids) { - return rej('cannot reply to repost'); - } - } - - // Get 'channel_id' parameter - const [channelId, channelIdErr] = $(params.channel_id).optional.id().$; - if (channelIdErr) return rej('invalid channel_id'); - - let channel: IChannel = null; - if (channelId !== undefined) { - // Fetch channel - channel = await Channel.findOne({ - _id: channelId - }); - - if (channel === null) { - return rej('channel not found'); - } - - // 返信対象の投稿がこのチャンネルじゃなかったらダメ - if (reply && !channelId.equals(reply.channel_id)) { - return rej('チャンネル内部からチャンネル外部の投稿に返信することはできません'); - } - - // Repost対象の投稿がこのチャンネルじゃなかったらダメ - if (repost && !channelId.equals(repost.channel_id)) { - return rej('チャンネル内部からチャンネル外部の投稿をRepostすることはできません'); - } - - // 引用ではないRepostはダメ - if (repost && !isQuote) { - return rej('チャンネル内部では引用ではないRepostをすることはできません'); - } - } else { - // 返信対象の投稿がチャンネルへの投稿だったらダメ - if (reply && reply.channel_id != null) { - return rej('チャンネル外部からチャンネル内部の投稿に返信することはできません'); - } - - // Repost対象の投稿がチャンネルへの投稿だったらダメ - if (repost && repost.channel_id != null) { - return rej('チャンネル外部からチャンネル内部の投稿をRepostすることはできません'); - } - } - - // Get 'poll' parameter - const [poll, pollErr] = $(params.poll).optional.strict.object() - .have('choices', $().array('string') - .unique() - .range(2, 10) - .each(c => c.length > 0 && c.length < 50)) - .$; - if (pollErr) return rej('invalid poll'); - - if (poll) { - (poll as any).choices = (poll as any).choices.map((choice, i) => ({ - id: i, // IDを付与 - text: choice.trim(), - votes: 0 - })); - } - - // テキストが無いかつ添付ファイルが無いかつRepostも無いかつ投票も無かったらエラー - if (text === undefined && files === null && repost === null && poll === undefined) { - return rej('text, media_ids, repost_id or poll is required'); - } - - // 直近の投稿と重複してたらエラー - // TODO: 直近の投稿が一日前くらいなら重複とは見なさない - if (user.latest_post) { - if (deepEqual({ - text: user.latest_post.text, - reply: user.latest_post.reply_id ? user.latest_post.reply_id.toString() : null, - repost: user.latest_post.repost_id ? user.latest_post.repost_id.toString() : null, - media_ids: (user.latest_post.media_ids || []).map(id => id.toString()) - }, { - text: text, - reply: reply ? reply._id.toString() : null, - repost: repost ? repost._id.toString() : null, - media_ids: (files || []).map(file => file._id.toString()) - })) { - return rej('duplicate'); - } - } - - // 投稿を作成 - const post = await Post.insert({ - created_at: new Date(), - channel_id: channel ? channel._id : undefined, - index: channel ? channel.index + 1 : undefined, - media_ids: files ? files.map(file => file._id) : undefined, - reply_id: reply ? reply._id : undefined, - repost_id: repost ? repost._id : undefined, - poll: poll, - text: text, - user_id: user._id, - app_id: app ? app._id : null - }); - - // Serialize - const postObj = await serialize(post); - - // Reponse - res(postObj); - - //#region Post processes - - User.update({ _id: user._id }, { - $set: { - latest_post: post - } - }); - - const mentions = []; - - function addMention(mentionee, reason) { - // Reject if already added - if (mentions.some(x => x.equals(mentionee))) return; - - // Add mention - mentions.push(mentionee); - - // Publish event - if (!user._id.equals(mentionee)) { - event(mentionee, reason, postObj); - pushSw(mentionee, reason, postObj); - } - } - - // タイムラインへの投稿 - if (!channel) { - // Publish event to myself's stream - event(user._id, 'post', postObj); - - // Fetch all followers - const followers = await Following - .find({ - followee_id: user._id, - // 削除されたドキュメントは除く - deleted_at: { $exists: false } - }, { - follower_id: true, - _id: false - }); - - // Publish event to followers stream - followers.forEach(following => - event(following.follower_id, 'post', postObj)); - } - - // チャンネルへの投稿 - if (channel) { - // Increment channel index(posts count) - Channel.update({ _id: channel._id }, { - $inc: { - index: 1 - } - }); - - // Publish event to channel - publishChannelStream(channel._id, 'post', postObj); - - // Get channel watchers - const watches = await ChannelWatching.find({ - channel_id: channel._id, - // 削除されたドキュメントは除く - deleted_at: { $exists: false } - }); - - // チャンネルの視聴者(のタイムライン)に配信 - watches.forEach(w => { - event(w.user_id, 'post', postObj); - }); - } - - // Increment my posts count - User.update({ _id: user._id }, { - $inc: { - posts_count: 1 - } - }); - - // If has in reply to post - if (reply) { - // Increment replies count - Post.update({ _id: reply._id }, { - $inc: { - replies_count: 1 - } - }); - - // 自分自身へのリプライでない限りは通知を作成 - notify(reply.user_id, user._id, 'reply', { - post_id: post._id - }); - - // Fetch watchers - Watching - .find({ - post_id: reply._id, - user_id: { $ne: user._id }, - // 削除されたドキュメントは除く - deleted_at: { $exists: false } - }, { - fields: { - user_id: true - } - }) - .then(watchers => { - watchers.forEach(watcher => { - notify(watcher.user_id, user._id, 'reply', { - post_id: post._id - }); - }); - }); - - // この投稿をWatchする - // TODO: ユーザーが「返信したときに自動でWatchする」設定を - // オフにしていた場合はしない - watch(user._id, reply); - - // Add mention - addMention(reply.user_id, 'reply'); - } - - // If it is repost - if (repost) { - // Notify - const type = text ? 'quote' : 'repost'; - notify(repost.user_id, user._id, type, { - post_id: post._id - }); - - // Fetch watchers - Watching - .find({ - post_id: repost._id, - user_id: { $ne: user._id }, - // 削除されたドキュメントは除く - deleted_at: { $exists: false } - }, { - fields: { - user_id: true - } - }) - .then(watchers => { - watchers.forEach(watcher => { - notify(watcher.user_id, user._id, type, { - post_id: post._id - }); - }); - }); - - // この投稿をWatchする - // TODO: ユーザーが「Repostしたときに自動でWatchする」設定を - // オフにしていた場合はしない - watch(user._id, repost); - - // If it is quote repost - if (text) { - // Add mention - addMention(repost.user_id, 'quote'); - } else { - // Publish event - if (!user._id.equals(repost.user_id)) { - event(repost.user_id, 'repost', postObj); - } - } - - // 今までで同じ投稿をRepostしているか - const existRepost = await Post.findOne({ - user_id: user._id, - repost_id: repost._id, - _id: { - $ne: post._id - } - }); - - if (!existRepost) { - // Update repostee status - Post.update({ _id: repost._id }, { - $inc: { - repost_count: 1 - } - }); - } - } - - // If has text content - if (text) { - // Analyze - const tokens = parse(text); - /* - // Extract a hashtags - const hashtags = tokens - .filter(t => t.type == 'hashtag') - .map(t => t.hashtag) - // Drop dupulicates - .filter((v, i, s) => s.indexOf(v) == i); - - // ハッシュタグをデータベースに登録 - registerHashtags(user, hashtags); - */ - // Extract an '@' mentions - const atMentions = tokens - .filter(t => t.type == 'mention') - .map(m => m.username) - // Drop dupulicates - .filter((v, i, s) => s.indexOf(v) == i); - - // Resolve all mentions - await Promise.all(atMentions.map(async (mention) => { - // Fetch mentioned user - // SELECT _id - const mentionee = await User - .findOne({ - username_lower: mention.toLowerCase() - }, { _id: true }); - - // When mentioned user not found - if (mentionee == null) return; - - // 既に言及されたユーザーに対する返信や引用repostの場合も無視 - if (reply && reply.user_id.equals(mentionee._id)) return; - if (repost && repost.user_id.equals(mentionee._id)) return; - - // Add mention - addMention(mentionee._id, 'mention'); - - // Create notification - notify(mentionee._id, user._id, 'mention', { - post_id: post._id - }); - - return; - })); - } - - // Register to search database - if (text && config.elasticsearch.enable) { - const es = require('../../../db/elasticsearch'); - - es.index({ - index: 'misskey', - type: 'post', - id: post._id.toString(), - body: { - text: post.text - } - }); - } - - // Append mentions data - if (mentions.length > 0) { - Post.update({ _id: post._id }, { - $set: { - mentions: mentions - } - }); - } - - //#endregion -}); diff --git a/src/api/endpoints/posts/favorites/create.ts b/src/api/endpoints/posts/favorites/create.ts deleted file mode 100644 index f9dee271b..000000000 --- a/src/api/endpoints/posts/favorites/create.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Favorite from '../../../models/favorite'; -import Post from '../../../models/post'; - -/** - * Favorite a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Get favoritee - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - // if already favorited - const exist = await Favorite.findOne({ - post_id: post._id, - user_id: user._id - }); - - if (exist !== null) { - return rej('already favorited'); - } - - // Create favorite - await Favorite.insert({ - created_at: new Date(), - post_id: post._id, - user_id: user._id - }); - - // Send response - res(); -}); diff --git a/src/api/endpoints/posts/favorites/delete.ts b/src/api/endpoints/posts/favorites/delete.ts deleted file mode 100644 index c4fe7d323..000000000 --- a/src/api/endpoints/posts/favorites/delete.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Favorite from '../../../models/favorite'; -import Post from '../../../models/post'; - -/** - * Unfavorite a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Get favoritee - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - // if already favorited - const exist = await Favorite.findOne({ - post_id: post._id, - user_id: user._id - }); - - if (exist === null) { - return rej('already not favorited'); - } - - // Delete favorite - await Favorite.deleteOne({ - _id: exist._id - }); - - // Send response - res(); -}); diff --git a/src/api/endpoints/posts/mentions.ts b/src/api/endpoints/posts/mentions.ts deleted file mode 100644 index 0ebe8be50..000000000 --- a/src/api/endpoints/posts/mentions.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../models/post'; -import getFriends from '../../common/get-friends'; -import serialize from '../../serializers/post'; - -/** - * Get mentions of myself - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'following' parameter - const [following = false, followingError] = - $(params.following).optional.boolean().$; - if (followingError) return rej('invalid following param'); - - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - // Construct query - const query = { - mentions: user._id - } as any; - - const sort = { - _id: -1 - }; - - if (following) { - const followingIds = await getFriends(user._id); - - query.user_id = { - $in: followingIds - }; - } - - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - - // Issue query - const mentions = await Post - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(mentions.map(async mention => - await serialize(mention, user) - ))); -}); diff --git a/src/api/endpoints/posts/polls/recommendation.ts b/src/api/endpoints/posts/polls/recommendation.ts deleted file mode 100644 index 9c92d6cac..000000000 --- a/src/api/endpoints/posts/polls/recommendation.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Vote from '../../../models/poll-vote'; -import Post from '../../../models/post'; -import serialize from '../../../serializers/post'; - -/** - * Get recommended polls - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; - if (offsetErr) return rej('invalid offset param'); - - // Get votes - const votes = await Vote.find({ - user_id: user._id - }, { - fields: { - _id: false, - post_id: true - } - }); - - const nin = votes && votes.length != 0 ? votes.map(v => v.post_id) : []; - - const posts = await Post - .find({ - _id: { - $nin: nin - }, - user_id: { - $ne: user._id - }, - poll: { - $exists: true, - $ne: null - } - }, { - limit: limit, - skip: offset, - sort: { - _id: -1 - } - }); - - // Serialize - res(await Promise.all(posts.map(async post => - await serialize(post, user, { detail: true })))); -}); diff --git a/src/api/endpoints/posts/polls/vote.ts b/src/api/endpoints/posts/polls/vote.ts deleted file mode 100644 index 5a4fd1c26..000000000 --- a/src/api/endpoints/posts/polls/vote.ts +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Vote from '../../../models/poll-vote'; -import Post from '../../../models/post'; -import Watching from '../../../models/post-watching'; -import notify from '../../../common/notify'; -import watch from '../../../common/watch-post'; -import { publishPostStream } from '../../../event'; - -/** - * Vote poll of a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Get votee - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - if (post.poll == null) { - return rej('poll not found'); - } - - // Get 'choice' parameter - const [choice, choiceError] = - $(params.choice).number() - .pipe(c => post.poll.choices.some(x => x.id == c)) - .$; - if (choiceError) return rej('invalid choice param'); - - // if already voted - const exist = await Vote.findOne({ - post_id: post._id, - user_id: user._id - }); - - if (exist !== null) { - return rej('already voted'); - } - - // Create vote - await Vote.insert({ - created_at: new Date(), - post_id: post._id, - user_id: user._id, - choice: choice - }); - - // Send response - res(); - - const inc = {}; - inc[`poll.choices.${findWithAttr(post.poll.choices, 'id', choice)}.votes`] = 1; - - // Increment votes count - await Post.update({ _id: post._id }, { - $inc: inc - }); - - publishPostStream(post._id, 'poll_voted'); - - // Notify - notify(post.user_id, user._id, 'poll_vote', { - post_id: post._id, - choice: choice - }); - - // Fetch watchers - Watching - .find({ - post_id: post._id, - user_id: { $ne: user._id }, - // 削除されたドキュメントは除く - deleted_at: { $exists: false } - }, { - fields: { - user_id: true - } - }) - .then(watchers => { - watchers.forEach(watcher => { - notify(watcher.user_id, user._id, 'poll_vote', { - post_id: post._id, - choice: choice - }); - }); - }); - - // この投稿をWatchする - // TODO: ユーザーが「投票したときに自動でWatchする」設定を - // オフにしていた場合はしない - watch(user._id, post); -}); - -function findWithAttr(array, attr, value) { - for (let i = 0; i < array.length; i += 1) { - if (array[i][attr] === value) { - return i; - } - } - return -1; -} diff --git a/src/api/endpoints/posts/reactions.ts b/src/api/endpoints/posts/reactions.ts deleted file mode 100644 index eab5d9b25..000000000 --- a/src/api/endpoints/posts/reactions.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../models/post'; -import Reaction from '../../models/post-reaction'; -import serialize from '../../serializers/post-reaction'; - -/** - * Show reactions of a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; - if (offsetErr) return rej('invalid offset param'); - - // Get 'sort' parameter - const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').$; - if (sortError) return rej('invalid sort param'); - - // Lookup post - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - // Issue query - const reactions = await Reaction - .find({ - post_id: post._id, - deleted_at: { $exists: false } - }, { - limit: limit, - skip: offset, - sort: { - _id: sort == 'asc' ? 1 : -1 - } - }); - - // Serialize - res(await Promise.all(reactions.map(async reaction => - await serialize(reaction, user)))); -}); diff --git a/src/api/endpoints/posts/reactions/create.ts b/src/api/endpoints/posts/reactions/create.ts deleted file mode 100644 index d537463df..000000000 --- a/src/api/endpoints/posts/reactions/create.ts +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Reaction from '../../../models/post-reaction'; -import Post from '../../../models/post'; -import Watching from '../../../models/post-watching'; -import notify from '../../../common/notify'; -import watch from '../../../common/watch-post'; -import { publishPostStream, pushSw } from '../../../event'; -import serializePost from '../../../serializers/post'; -import serializeUser from '../../../serializers/user'; - -/** - * React to a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Get 'reaction' parameter - const [reaction, reactionErr] = $(params.reaction).string().or([ - 'like', - 'love', - 'laugh', - 'hmm', - 'surprise', - 'congrats', - 'angry', - 'confused', - 'pudding' - ]).$; - if (reactionErr) return rej('invalid reaction param'); - - // Fetch reactee - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - // Myself - if (post.user_id.equals(user._id)) { - return rej('cannot react to my post'); - } - - // if already reacted - const exist = await Reaction.findOne({ - post_id: post._id, - user_id: user._id, - deleted_at: { $exists: false } - }); - - if (exist !== null) { - return rej('already reacted'); - } - - // Create reaction - await Reaction.insert({ - created_at: new Date(), - post_id: post._id, - user_id: user._id, - reaction: reaction - }); - - // Send response - res(); - - const inc = {}; - inc[`reaction_counts.${reaction}`] = 1; - - // Increment reactions count - await Post.update({ _id: post._id }, { - $inc: inc - }); - - publishPostStream(post._id, 'reacted'); - - // Notify - notify(post.user_id, user._id, 'reaction', { - post_id: post._id, - reaction: reaction - }); - - pushSw(post.user_id, 'reaction', { - user: await serializeUser(user, post.user_id), - post: await serializePost(post, post.user_id), - reaction: reaction - }); - - // Fetch watchers - Watching - .find({ - post_id: post._id, - user_id: { $ne: user._id }, - // 削除されたドキュメントは除く - deleted_at: { $exists: false } - }, { - fields: { - user_id: true - } - }) - .then(watchers => { - watchers.forEach(watcher => { - notify(watcher.user_id, user._id, 'reaction', { - post_id: post._id, - reaction: reaction - }); - }); - }); - - // この投稿をWatchする - // TODO: ユーザーが「リアクションしたときに自動でWatchする」設定を - // オフにしていた場合はしない - watch(user._id, post); -}); diff --git a/src/api/endpoints/posts/reactions/delete.ts b/src/api/endpoints/posts/reactions/delete.ts deleted file mode 100644 index 922c57ab1..000000000 --- a/src/api/endpoints/posts/reactions/delete.ts +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Reaction from '../../../models/post-reaction'; -import Post from '../../../models/post'; -// import event from '../../../event'; - -/** - * Unreact to a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Fetch unreactee - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - // if already unreacted - const exist = await Reaction.findOne({ - post_id: post._id, - user_id: user._id, - deleted_at: { $exists: false } - }); - - if (exist === null) { - return rej('never reacted'); - } - - // Delete reaction - await Reaction.update({ - _id: exist._id - }, { - $set: { - deleted_at: new Date() - } - }); - - // Send response - res(); - - const dec = {}; - dec[`reaction_counts.${exist.reaction}`] = -1; - - // Decrement reactions count - Post.update({ _id: post._id }, { - $inc: dec - }); -}); diff --git a/src/api/endpoints/posts/replies.ts b/src/api/endpoints/posts/replies.ts deleted file mode 100644 index 3fd6a4676..000000000 --- a/src/api/endpoints/posts/replies.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../models/post'; -import serialize from '../../serializers/post'; - -/** - * Show a replies of a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; - if (offsetErr) return rej('invalid offset param'); - - // Get 'sort' parameter - const [sort = 'desc', sortError] = $(params.sort).optional.string().or('desc asc').$; - if (sortError) return rej('invalid sort param'); - - // Lookup post - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - // Issue query - const replies = await Post - .find({ reply_id: post._id }, { - limit: limit, - skip: offset, - sort: { - _id: sort == 'asc' ? 1 : -1 - } - }); - - // Serialize - res(await Promise.all(replies.map(async post => - await serialize(post, user)))); -}); diff --git a/src/api/endpoints/posts/reposts.ts b/src/api/endpoints/posts/reposts.ts deleted file mode 100644 index b701ff757..000000000 --- a/src/api/endpoints/posts/reposts.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../models/post'; -import serialize from '../../serializers/post'; - -/** - * Show a reposts of a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - // Lookup post - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - // Construct query - const sort = { - _id: -1 - }; - const query = { - repost_id: post._id - } as any; - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - - // Issue query - const reposts = await Post - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(reposts.map(async post => - await serialize(post, user)))); -}); diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts deleted file mode 100644 index b434f6434..000000000 --- a/src/api/endpoints/posts/search.ts +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import $ from 'cafy'; -const escapeRegexp = require('escape-regexp'); -import Post from '../../models/post'; -import serialize from '../../serializers/post'; -import config from '../../../conf'; - -/** - * Search a post - * - * @param {any} params - * @param {any} me - * @return {Promise} - */ -module.exports = (params, me) => new Promise(async (res, rej) => { - // Get 'query' parameter - const [query, queryError] = $(params.query).string().pipe(x => x != '').$; - if (queryError) return rej('invalid query param'); - - // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; - if (offsetErr) return rej('invalid offset param'); - - // Get 'max' parameter - const [max = 10, maxErr] = $(params.max).optional.number().range(1, 30).$; - if (maxErr) return rej('invalid max param'); - - // If Elasticsearch is available, search by $ - // If not, search by MongoDB - (config.elasticsearch.enable ? byElasticsearch : byNative) - (res, rej, me, query, offset, max); -}); - -// Search by MongoDB -async function byNative(res, rej, me, query, offset, max) { - const escapedQuery = escapeRegexp(query); - - // Search posts - const posts = await Post - .find({ - text: new RegExp(escapedQuery) - }, { - sort: { - _id: -1 - }, - limit: max, - skip: offset - }); - - // Serialize - res(await Promise.all(posts.map(async post => - await serialize(post, me)))); -} - -// Search by Elasticsearch -async function byElasticsearch(res, rej, me, query, offset, max) { - const es = require('../../db/elasticsearch'); - - es.search({ - index: 'misskey', - type: 'post', - body: { - size: max, - from: offset, - query: { - simple_query_string: { - fields: ['text'], - query: query, - default_operator: 'and' - } - }, - sort: [ - { _doc: 'desc' } - ], - highlight: { - pre_tags: [''], - post_tags: [''], - encoder: 'html', - fields: { - text: {} - } - } - } - }, async (error, response) => { - if (error) { - console.error(error); - return res(500); - } - - if (response.hits.total === 0) { - return res([]); - } - - const hits = response.hits.hits.map(hit => new mongo.ObjectID(hit._id)); - - // Fetch found posts - const posts = await Post - .find({ - _id: { - $in: hits - } - }, { - sort: { - _id: -1 - } - }); - - posts.map(post => { - post._highlight = response.hits.hits.filter(hit => post._id.equals(hit._id))[0].highlight.text[0]; - }); - - // Serialize - res(await Promise.all(posts.map(async post => - await serialize(post, me)))); - }); -} diff --git a/src/api/endpoints/posts/show.ts b/src/api/endpoints/posts/show.ts deleted file mode 100644 index 5bfe4f660..000000000 --- a/src/api/endpoints/posts/show.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../models/post'; -import serialize from '../../serializers/post'; - -/** - * Show a post - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'post_id' parameter - const [postId, postIdErr] = $(params.post_id).id().$; - if (postIdErr) return rej('invalid post_id param'); - - // Get post - const post = await Post.findOne({ - _id: postId - }); - - if (post === null) { - return rej('post not found'); - } - - // Serialize - res(await serialize(post, user, { - detail: true - })); -}); diff --git a/src/api/endpoints/posts/timeline.ts b/src/api/endpoints/posts/timeline.ts deleted file mode 100644 index 0d08b9546..000000000 --- a/src/api/endpoints/posts/timeline.ts +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import rap from '@prezzemolo/rap'; -import Post from '../../models/post'; -import ChannelWatching from '../../models/channel-watching'; -import getFriends from '../../common/get-friends'; -import serialize from '../../serializers/post'; - -/** - * Get timeline of myself - * - * @param {any} params - * @param {any} user - * @param {any} app - * @return {Promise} - */ -module.exports = async (params, user, app) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) throw 'invalid limit param'; - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) throw 'invalid since_id param'; - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) throw 'invalid max_id param'; - - // Get 'since_date' parameter - const [sinceDate, sinceDateErr] = $(params.since_date).optional.number().$; - if (sinceDateErr) throw 'invalid since_date param'; - - // Get 'max_date' parameter - const [maxDate, maxDateErr] = $(params.max_date).optional.number().$; - if (maxDateErr) throw 'invalid max_date param'; - - // Check if only one of since_id, max_id, since_date, max_date specified - if ([sinceId, maxId, sinceDate, maxDate].filter(x => x != null).length > 1) { - throw 'only one of since_id, max_id, since_date, max_date can be specified'; - } - - const { followingIds, watchingChannelIds } = await rap({ - // ID list of the user itself and other users who the user follows - followingIds: getFriends(user._id), - // Watchしているチャンネルを取得 - watchingChannelIds: ChannelWatching.find({ - user_id: user._id, - // 削除されたドキュメントは除く - deleted_at: { $exists: false } - }).then(watches => watches.map(w => w.channel_id)) - }); - - //#region Construct query - const sort = { - _id: -1 - }; - - const query = { - $or: [{ - // フォローしている人のタイムラインへの投稿 - user_id: { - $in: followingIds - }, - // 「タイムラインへの」投稿に限定するためにチャンネルが指定されていないもののみに限る - $or: [{ - channel_id: { - $exists: false - } - }, { - channel_id: null - }] - }, { - // Watchしているチャンネルへの投稿 - channel_id: { - $in: watchingChannelIds - } - }] - } as any; - - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } else if (sinceDate) { - sort._id = 1; - query.created_at = { - $gt: new Date(sinceDate) - }; - } else if (maxDate) { - query.created_at = { - $lt: new Date(maxDate) - }; - } - //#endregion - - // Issue query - const timeline = await Post - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - return await Promise.all(timeline.map(post => serialize(post, user))); -}; diff --git a/src/api/endpoints/posts/trend.ts b/src/api/endpoints/posts/trend.ts deleted file mode 100644 index 64a195dff..000000000 --- a/src/api/endpoints/posts/trend.ts +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Module dependencies - */ -const ms = require('ms'); -import $ from 'cafy'; -import Post from '../../models/post'; -import serialize from '../../serializers/post'; - -/** - * Get trend posts - * - * @param {any} params - * @param {any} user - * @return {Promise} - */ -module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; - if (offsetErr) return rej('invalid offset param'); - - // Get 'reply' parameter - const [reply, replyErr] = $(params.reply).optional.boolean().$; - if (replyErr) return rej('invalid reply param'); - - // Get 'repost' parameter - const [repost, repostErr] = $(params.repost).optional.boolean().$; - if (repostErr) return rej('invalid repost param'); - - // Get 'media' parameter - const [media, mediaErr] = $(params.media).optional.boolean().$; - if (mediaErr) return rej('invalid media param'); - - // Get 'poll' parameter - const [poll, pollErr] = $(params.poll).optional.boolean().$; - if (pollErr) return rej('invalid poll param'); - - const query = { - created_at: { - $gte: new Date(Date.now() - ms('1days')) - }, - repost_count: { - $gt: 0 - } - } as any; - - if (reply != undefined) { - query.reply_id = reply ? { $exists: true, $ne: null } : null; - } - - if (repost != undefined) { - query.repost_id = repost ? { $exists: true, $ne: null } : null; - } - - if (media != undefined) { - query.media_ids = media ? { $exists: true, $ne: null } : null; - } - - if (poll != undefined) { - query.poll = poll ? { $exists: true, $ne: null } : null; - } - - // Issue query - const posts = await Post - .find(query, { - limit: limit, - skip: offset, - sort: { - repost_count: -1, - _id: -1 - } - }); - - // Serialize - res(await Promise.all(posts.map(async post => - await serialize(post, user, { detail: true })))); -}); diff --git a/src/api/endpoints/users.ts b/src/api/endpoints/users.ts deleted file mode 100644 index 134f262fb..000000000 --- a/src/api/endpoints/users.ts +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import User from '../models/user'; -import serialize from '../serializers/user'; - -/** - * Lists all users - * - * @param {any} params - * @param {any} me - * @return {Promise} - */ -module.exports = (params, me) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('cannot set since_id and max_id'); - } - - // Construct query - const sort = { - _id: -1 - }; - const query = {} as any; - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } - - // Issue query - const users = await User - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(users.map(async user => - await serialize(user, me)))); -}); diff --git a/src/api/endpoints/users/posts.ts b/src/api/endpoints/users/posts.ts deleted file mode 100644 index fe821cf17..000000000 --- a/src/api/endpoints/users/posts.ts +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import Post from '../../models/post'; -import User from '../../models/user'; -import serialize from '../../serializers/post'; - -/** - * Get posts of a user - * - * @param {any} params - * @param {any} me - * @return {Promise} - */ -module.exports = (params, me) => new Promise(async (res, rej) => { - // Get 'user_id' parameter - const [userId, userIdErr] = $(params.user_id).optional.id().$; - if (userIdErr) return rej('invalid user_id param'); - - // Get 'username' parameter - const [username, usernameErr] = $(params.username).optional.string().$; - if (usernameErr) return rej('invalid username param'); - - if (userId === undefined && username === undefined) { - return rej('user_id or username is required'); - } - - // Get 'include_replies' parameter - const [includeReplies = true, includeRepliesErr] = $(params.include_replies).optional.boolean().$; - if (includeRepliesErr) return rej('invalid include_replies param'); - - // Get 'with_media' parameter - const [withMedia = false, withMediaErr] = $(params.with_media).optional.boolean().$; - if (withMediaErr) return rej('invalid with_media param'); - - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'since_id' parameter - const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$; - if (sinceIdErr) return rej('invalid since_id param'); - - // Get 'max_id' parameter - const [maxId, maxIdErr] = $(params.max_id).optional.id().$; - if (maxIdErr) return rej('invalid max_id param'); - - // Get 'since_date' parameter - const [sinceDate, sinceDateErr] = $(params.since_date).optional.number().$; - if (sinceDateErr) throw 'invalid since_date param'; - - // Get 'max_date' parameter - const [maxDate, maxDateErr] = $(params.max_date).optional.number().$; - if (maxDateErr) throw 'invalid max_date param'; - - // Check if only one of since_id, max_id, since_date, max_date specified - if ([sinceId, maxId, sinceDate, maxDate].filter(x => x != null).length > 1) { - throw 'only one of since_id, max_id, since_date, max_date can be specified'; - } - - const q = userId !== undefined - ? { _id: userId } - : { username_lower: username.toLowerCase() } ; - - // Lookup user - const user = await User.findOne(q, { - fields: { - _id: true - } - }); - - if (user === null) { - return rej('user not found'); - } - - //#region Construct query - const sort = { - _id: -1 - }; - - const query = { - user_id: user._id - } as any; - - if (sinceId) { - sort._id = 1; - query._id = { - $gt: sinceId - }; - } else if (maxId) { - query._id = { - $lt: maxId - }; - } else if (sinceDate) { - sort._id = 1; - query.created_at = { - $gt: new Date(sinceDate) - }; - } else if (maxDate) { - query.created_at = { - $lt: new Date(maxDate) - }; - } - - if (!includeReplies) { - query.reply_id = null; - } - - if (withMedia) { - query.media_ids = { - $exists: true, - $ne: null - }; - } - //#endregion - - // Issue query - const posts = await Post - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(posts.map(async (post) => - await serialize(post, me) - ))); -}); diff --git a/src/api/endpoints/users/recommendation.ts b/src/api/endpoints/users/recommendation.ts deleted file mode 100644 index 731d68a7b..000000000 --- a/src/api/endpoints/users/recommendation.ts +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Module dependencies - */ -const ms = require('ms'); -import $ from 'cafy'; -import User from '../../models/user'; -import serialize from '../../serializers/user'; -import getFriends from '../../common/get-friends'; - -/** - * Get recommended users - * - * @param {any} params - * @param {any} me - * @return {Promise} - */ -module.exports = (params, me) => new Promise(async (res, rej) => { - // Get 'limit' parameter - const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; - if (limitErr) return rej('invalid limit param'); - - // Get 'offset' parameter - const [offset = 0, offsetErr] = $(params.offset).optional.number().min(0).$; - if (offsetErr) return rej('invalid offset param'); - - // ID list of the user itself and other users who the user follows - const followingIds = await getFriends(me._id); - - const users = await User - .find({ - _id: { - $nin: followingIds - }, - last_used_at: { - $gte: new Date(Date.now() - ms('7days')) - } - }, { - limit: limit, - skip: offset, - sort: { - followers_count: -1 - } - }); - - // Serialize - res(await Promise.all(users.map(async user => - await serialize(user, me, { detail: true })))); -}); diff --git a/src/api/endpoints/users/show.ts b/src/api/endpoints/users/show.ts deleted file mode 100644 index 8e74b0fe3..000000000 --- a/src/api/endpoints/users/show.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Module dependencies - */ -import $ from 'cafy'; -import User from '../../models/user'; -import serialize from '../../serializers/user'; - -/** - * Show a user - * - * @param {any} params - * @param {any} me - * @return {Promise} - */ -module.exports = (params, me) => new Promise(async (res, rej) => { - // Get 'user_id' parameter - const [userId, userIdErr] = $(params.user_id).optional.id().$; - if (userIdErr) return rej('invalid user_id param'); - - // Get 'username' parameter - const [username, usernameErr] = $(params.username).optional.string().$; - if (usernameErr) return rej('invalid username param'); - - if (userId === undefined && username === undefined) { - return rej('user_id or username is required'); - } - - const q = userId !== undefined - ? { _id: userId } - : { username_lower: username.toLowerCase() }; - - // Lookup user - const user = await User.findOne(q, { - fields: { - data: false - } - }); - - if (user === null) { - return rej('user not found'); - } - - // Send response - res(await serialize(user, me, { - detail: true - })); -}); diff --git a/src/api/models/access-token.ts b/src/api/models/access-token.ts deleted file mode 100644 index 9985be501..000000000 --- a/src/api/models/access-token.ts +++ /dev/null @@ -1,8 +0,0 @@ -import db from '../../db/mongodb'; - -const collection = db.get('access_tokens'); - -(collection as any).createIndex('token'); // fuck type definition -(collection as any).createIndex('hash'); // fuck type definition - -export default collection as any; // fuck type definition diff --git a/src/api/models/app.ts b/src/api/models/app.ts deleted file mode 100644 index 68f2f448b..000000000 --- a/src/api/models/app.ts +++ /dev/null @@ -1,13 +0,0 @@ -import db from '../../db/mongodb'; - -const collection = db.get('apps'); - -(collection as any).createIndex('name_id'); // fuck type definition -(collection as any).createIndex('name_id_lower'); // fuck type definition -(collection as any).createIndex('secret'); // fuck type definition - -export default collection as any; // fuck type definition - -export function isValidNameId(nameId: string): boolean { - return typeof nameId == 'string' && /^[a-zA-Z0-9\-]{3,30}$/.test(nameId); -} diff --git a/src/api/models/appdata.ts b/src/api/models/appdata.ts deleted file mode 100644 index 3e68354fa..000000000 --- a/src/api/models/appdata.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('appdata') as any; // fuck type definition diff --git a/src/api/models/auth-session.ts b/src/api/models/auth-session.ts deleted file mode 100644 index b264a133e..000000000 --- a/src/api/models/auth-session.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('auth_sessions') as any; // fuck type definition diff --git a/src/api/models/channel-watching.ts b/src/api/models/channel-watching.ts deleted file mode 100644 index 6184ae408..000000000 --- a/src/api/models/channel-watching.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('channel_watching') as any; // fuck type definition diff --git a/src/api/models/channel.ts b/src/api/models/channel.ts deleted file mode 100644 index c80e84dbc..000000000 --- a/src/api/models/channel.ts +++ /dev/null @@ -1,14 +0,0 @@ -import * as mongo from 'mongodb'; -import db from '../../db/mongodb'; - -const collection = db.get('channels'); - -export default collection as any; // fuck type definition - -export type IChannel = { - _id: mongo.ObjectID; - created_at: Date; - title: string; - user_id: mongo.ObjectID; - index: number; -}; diff --git a/src/api/models/drive-file.ts b/src/api/models/drive-file.ts deleted file mode 100644 index 802ee5a5f..000000000 --- a/src/api/models/drive-file.ts +++ /dev/null @@ -1,26 +0,0 @@ -import * as mongodb from 'mongodb'; -import monkDb, { nativeDbConn } from '../../db/mongodb'; - -const collection = monkDb.get('drive_files.files'); - -export default collection as any; // fuck type definition - -const getGridFSBucket = async (): Promise => { - const db = await nativeDbConn(); - const bucket = new mongodb.GridFSBucket(db, { - bucketName: 'drive_files' - }); - return bucket; -}; - -export { getGridFSBucket }; - -export function validateFileName(name: string): boolean { - return ( - (name.trim().length > 0) && - (name.length <= 200) && - (name.indexOf('\\') === -1) && - (name.indexOf('/') === -1) && - (name.indexOf('..') === -1) - ); -} diff --git a/src/api/models/drive-folder.ts b/src/api/models/drive-folder.ts deleted file mode 100644 index f81ffe855..000000000 --- a/src/api/models/drive-folder.ts +++ /dev/null @@ -1,10 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('drive_folders') as any; // fuck type definition - -export function isValidFolderName(name: string): boolean { - return ( - (name.trim().length > 0) && - (name.length <= 200) - ); -} diff --git a/src/api/models/drive-tag.ts b/src/api/models/drive-tag.ts deleted file mode 100644 index 991c935e8..000000000 --- a/src/api/models/drive-tag.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('drive_tags') as any; // fuck type definition diff --git a/src/api/models/favorite.ts b/src/api/models/favorite.ts deleted file mode 100644 index e01d9e343..000000000 --- a/src/api/models/favorite.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('favorites') as any; // fuck type definition diff --git a/src/api/models/following.ts b/src/api/models/following.ts deleted file mode 100644 index cb3db9b53..000000000 --- a/src/api/models/following.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('following') as any; // fuck type definition diff --git a/src/api/models/messaging-history.ts b/src/api/models/messaging-history.ts deleted file mode 100644 index c06987e45..000000000 --- a/src/api/models/messaging-history.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('messaging_histories') as any; // fuck type definition diff --git a/src/api/models/messaging-message.ts b/src/api/models/messaging-message.ts deleted file mode 100644 index 18afa57e4..000000000 --- a/src/api/models/messaging-message.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as mongo from 'mongodb'; -import db from '../../db/mongodb'; - -export default db.get('messaging_messages') as any; // fuck type definition - -export interface IMessagingMessage { - _id: mongo.ObjectID; -} - -export function isValidText(text: string): boolean { - return text.length <= 1000 && text.trim() != ''; -} diff --git a/src/api/models/meta.ts b/src/api/models/meta.ts deleted file mode 100644 index c7dba8fcb..000000000 --- a/src/api/models/meta.ts +++ /dev/null @@ -1,7 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('meta') as any; // fuck type definition - -export type IMeta = { - top_image: string; -}; diff --git a/src/api/models/notification.ts b/src/api/models/notification.ts deleted file mode 100644 index e3dc6c70a..000000000 --- a/src/api/models/notification.ts +++ /dev/null @@ -1,47 +0,0 @@ -import * as mongo from 'mongodb'; -import db from '../../db/mongodb'; -import { IUser } from './user'; - -export default db.get('notifications') as any; // fuck type definition - -export interface INotification { - _id: mongo.ObjectID; - created_at: Date; - - /** - * 通知の受信者 - */ - notifiee?: IUser; - - /** - * 通知の受信者 - */ - notifiee_id: mongo.ObjectID; - - /** - * イニシエータ(initiator)、Origin。通知を行う原因となったユーザー - */ - notifier?: IUser; - - /** - * イニシエータ(initiator)、Origin。通知を行う原因となったユーザー - */ - notifier_id: mongo.ObjectID; - - /** - * 通知の種類。 - * follow - フォローされた - * mention - 投稿で自分が言及された - * reply - (自分または自分がWatchしている)投稿が返信された - * repost - (自分または自分がWatchしている)投稿がRepostされた - * quote - (自分または自分がWatchしている)投稿が引用Repostされた - * reaction - (自分または自分がWatchしている)投稿にリアクションされた - * poll_vote - (自分または自分がWatchしている)投稿の投票に投票された - */ - type: 'follow' | 'mention' | 'reply' | 'repost' | 'quote' | 'reaction' | 'poll_vote'; - - /** - * 通知が読まれたかどうか - */ - is_read: Boolean; -} diff --git a/src/api/models/poll-vote.ts b/src/api/models/poll-vote.ts deleted file mode 100644 index af77a2643..000000000 --- a/src/api/models/poll-vote.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('poll_votes') as any; // fuck type definition diff --git a/src/api/models/post-reaction.ts b/src/api/models/post-reaction.ts deleted file mode 100644 index 282ae5bd2..000000000 --- a/src/api/models/post-reaction.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('post_reactions') as any; // fuck type definition diff --git a/src/api/models/post-watching.ts b/src/api/models/post-watching.ts deleted file mode 100644 index 41d37e270..000000000 --- a/src/api/models/post-watching.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('post_watching') as any; // fuck type definition diff --git a/src/api/models/post.ts b/src/api/models/post.ts deleted file mode 100644 index 7584ce182..000000000 --- a/src/api/models/post.ts +++ /dev/null @@ -1,22 +0,0 @@ -import * as mongo from 'mongodb'; - -import db from '../../db/mongodb'; - -export default db.get('posts') as any; // fuck type definition - -export function isValidText(text: string): boolean { - return text.length <= 1000 && text.trim() != ''; -} - -export type IPost = { - _id: mongo.ObjectID; - channel_id: mongo.ObjectID; - created_at: Date; - media_ids: mongo.ObjectID[]; - reply_id: mongo.ObjectID; - repost_id: mongo.ObjectID; - poll: {}; // todo - text: string; - user_id: mongo.ObjectID; - app_id: mongo.ObjectID; -}; diff --git a/src/api/models/signin.ts b/src/api/models/signin.ts deleted file mode 100644 index 385a348f2..000000000 --- a/src/api/models/signin.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('signin') as any; // fuck type definition diff --git a/src/api/models/sw-subscription.ts b/src/api/models/sw-subscription.ts deleted file mode 100644 index ecca04cb9..000000000 --- a/src/api/models/sw-subscription.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('sw_subscriptions') as any; // fuck type definition diff --git a/src/api/models/user.ts b/src/api/models/user.ts deleted file mode 100644 index b2f3af09f..000000000 --- a/src/api/models/user.ts +++ /dev/null @@ -1,83 +0,0 @@ -import * as mongo from 'mongodb'; - -import db from '../../db/mongodb'; -import { IPost } from './post'; - -const collection = db.get('users'); - -(collection as any).createIndex('username'); // fuck type definition -(collection as any).createIndex('token'); // fuck type definition - -export default collection as any; // fuck type definition - -export function validateUsername(username: string): boolean { - return typeof username == 'string' && /^[a-zA-Z0-9\-]{3,20}$/.test(username); -} - -export function validatePassword(password: string): boolean { - return typeof password == 'string' && password != ''; -} - -export function isValidName(name: string): boolean { - return typeof name == 'string' && name.length < 30 && name.trim() != ''; -} - -export function isValidDescription(description: string): boolean { - return typeof description == 'string' && description.length < 500 && description.trim() != ''; -} - -export function isValidLocation(location: string): boolean { - return typeof location == 'string' && location.length < 50 && location.trim() != ''; -} - -export function isValidBirthday(birthday: string): boolean { - return typeof birthday == 'string' && /^([0-9]{4})\-([0-9]{2})-([0-9]{2})$/.test(birthday); -} - -export type IUser = { - _id: mongo.ObjectID; - created_at: Date; - email: string; - followers_count: number; - following_count: number; - links: string[]; - name: string; - password: string; - posts_count: number; - drive_capacity: number; - username: string; - username_lower: string; - token: string; - avatar_id: mongo.ObjectID; - banner_id: mongo.ObjectID; - data: any; - twitter: { - access_token: string; - access_token_secret: string; - user_id: string; - screen_name: string; - }; - line: { - user_id: string; - }; - description: string; - profile: { - location: string; - birthday: string; // 'YYYY-MM-DD' - tags: string[]; - }; - last_used_at: Date; - latest_post: IPost; - pinned_post_id: mongo.ObjectID; - is_pro: boolean; - is_suspended: boolean; - keywords: string[]; -}; - -export function init(user): IUser { - user._id = new mongo.ObjectID(user._id); - user.avatar_id = new mongo.ObjectID(user.avatar_id); - user.banner_id = new mongo.ObjectID(user.banner_id); - user.pinned_post_id = new mongo.ObjectID(user.pinned_post_id); - return user; -} diff --git a/src/api/private/signin.ts b/src/api/private/signin.ts deleted file mode 100644 index 0ebf8d6aa..000000000 --- a/src/api/private/signin.ts +++ /dev/null @@ -1,64 +0,0 @@ -import * as express from 'express'; -import * as bcrypt from 'bcryptjs'; -import { default as User, IUser } from '../models/user'; -import Signin from '../models/signin'; -import serialize from '../serializers/signin'; -import event from '../event'; -import signin from '../common/signin'; - -export default async (req: express.Request, res: express.Response) => { - res.header('Access-Control-Allow-Credentials', 'true'); - - const username = req.body['username']; - const password = req.body['password']; - - if (typeof username != 'string') { - res.sendStatus(400); - return; - } - - if (typeof password != 'string') { - res.sendStatus(400); - return; - } - - // Fetch user - const user: IUser = await User.findOne({ - username_lower: username.toLowerCase() - }, { - fields: { - data: false, - profile: false - } - }); - - if (user === null) { - res.status(404).send({ - error: 'user not found' - }); - return; - } - - // Compare password - const same = await bcrypt.compare(password, user.password); - - if (same) { - signin(res, user, false); - } else { - res.status(400).send({ - error: 'incorrect password' - }); - } - - // Append signin history - const record = await Signin.insert({ - created_at: new Date(), - user_id: user._id, - ip: req.ip, - headers: req.headers, - success: same - }); - - // Publish signin event - event(user._id, 'signin', await serialize(record)); -}; diff --git a/src/api/reply.ts b/src/api/reply.ts deleted file mode 100644 index e47fc85b9..000000000 --- a/src/api/reply.ts +++ /dev/null @@ -1,13 +0,0 @@ -import * as express from 'express'; - -export default (res: express.Response, x?: any, y?: any) => { - if (x === undefined) { - res.sendStatus(204); - } else if (typeof x === 'number') { - res.status(x).send({ - error: x === 500 ? 'INTERNAL_ERROR' : y - }); - } else { - res.send(x); - } -}; diff --git a/src/api/serializers/drive-file.ts b/src/api/serializers/drive-file.ts deleted file mode 100644 index dcdaa01fa..000000000 --- a/src/api/serializers/drive-file.ts +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import DriveFile from '../models/drive-file'; -import serializeDriveFolder from './drive-folder'; -import serializeDriveTag from './drive-tag'; -import deepcopy = require('deepcopy'); -import config from '../../conf'; - -/** - * Serialize a drive file - * - * @param {any} file - * @param {any} options? - * @return {Promise} - */ -export default ( - file: any, - options?: { - detail: boolean - } -) => new Promise(async (resolve, reject) => { - const opts = Object.assign({ - detail: false - }, options); - - let _file: any; - - // Populate the file if 'file' is ID - if (mongo.ObjectID.prototype.isPrototypeOf(file)) { - _file = await DriveFile.findOne({ - _id: file - }); - } else if (typeof file === 'string') { - _file = await DriveFile.findOne({ - _id: new mongo.ObjectID(file) - }); - } else { - _file = deepcopy(file); - } - - if (!_file) return reject('invalid file arg.'); - - // rendered target - let _target: any = {}; - - _target.id = _file._id; - _target.created_at = _file.uploadDate; - _target.name = _file.filename; - _target.type = _file.contentType; - _target.datasize = _file.length; - _target.md5 = _file.md5; - - _target = Object.assign(_target, _file.metadata); - - _target.url = `${config.drive_url}/${_target.id}/${encodeURIComponent(_target.name)}`; - - if (opts.detail && _target.folder_id) { - // Populate folder - _target.folder = await serializeDriveFolder(_target.folder_id, { - detail: true - }); - } - - if (opts.detail && _target.tags) { - // Populate tags - _target.tags = await _target.tags.map(async (tag: any) => - await serializeDriveTag(tag) - ); - } - - resolve(_target); -}); diff --git a/src/api/serializers/drive-folder.ts b/src/api/serializers/drive-folder.ts deleted file mode 100644 index 6ebf454a2..000000000 --- a/src/api/serializers/drive-folder.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import DriveFolder from '../models/drive-folder'; -import DriveFile from '../models/drive-file'; -import deepcopy = require('deepcopy'); - -/** - * Serialize a drive folder - * - * @param {any} folder - * @param {any} options? - * @return {Promise} - */ -const self = ( - folder: any, - options?: { - detail: boolean - } -) => new Promise(async (resolve, reject) => { - const opts = Object.assign({ - detail: false - }, options); - - let _folder: any; - - // Populate the folder if 'folder' is ID - if (mongo.ObjectID.prototype.isPrototypeOf(folder)) { - _folder = await DriveFolder.findOne({ _id: folder }); - } else if (typeof folder === 'string') { - _folder = await DriveFolder.findOne({ _id: new mongo.ObjectID(folder) }); - } else { - _folder = deepcopy(folder); - } - - // Rename _id to id - _folder.id = _folder._id; - delete _folder._id; - - if (opts.detail) { - const childFoldersCount = await DriveFolder.count({ - parent_id: _folder.id - }); - - const childFilesCount = await DriveFile.count({ - 'metadata.folder_id': _folder.id - }); - - _folder.folders_count = childFoldersCount; - _folder.files_count = childFilesCount; - } - - if (opts.detail && _folder.parent_id) { - // Populate parent folder - _folder.parent = await self(_folder.parent_id, { - detail: true - }); - } - - resolve(_folder); -}); - -export default self; diff --git a/src/api/serializers/drive-tag.ts b/src/api/serializers/drive-tag.ts deleted file mode 100644 index 2f152381b..000000000 --- a/src/api/serializers/drive-tag.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import DriveTag from '../models/drive-tag'; -import deepcopy = require('deepcopy'); - -/** - * Serialize a drive tag - * - * @param {any} tag - * @return {Promise} - */ -const self = ( - tag: any -) => new Promise(async (resolve, reject) => { - let _tag: any; - - // Populate the tag if 'tag' is ID - if (mongo.ObjectID.prototype.isPrototypeOf(tag)) { - _tag = await DriveTag.findOne({ _id: tag }); - } else if (typeof tag === 'string') { - _tag = await DriveTag.findOne({ _id: new mongo.ObjectID(tag) }); - } else { - _tag = deepcopy(tag); - } - - // Rename _id to id - _tag.id = _tag._id; - delete _tag._id; - - resolve(_tag); -}); - -export default self; diff --git a/src/api/serializers/messaging-message.ts b/src/api/serializers/messaging-message.ts deleted file mode 100644 index 4ab95e42a..000000000 --- a/src/api/serializers/messaging-message.ts +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import deepcopy = require('deepcopy'); -import Message from '../models/messaging-message'; -import serializeUser from './user'; -import serializeDriveFile from './drive-file'; -import parse from '../common/text'; - -/** - * Serialize a message - * - * @param {any} message - * @param {any} me? - * @param {any} options? - * @return {Promise} - */ -export default ( - message: any, - me?: any, - options?: { - populateRecipient: boolean - } -) => new Promise(async (resolve, reject) => { - const opts = options || { - populateRecipient: true - }; - - let _message: any; - - // Populate the message if 'message' is ID - if (mongo.ObjectID.prototype.isPrototypeOf(message)) { - _message = await Message.findOne({ - _id: message - }); - } else if (typeof message === 'string') { - _message = await Message.findOne({ - _id: new mongo.ObjectID(message) - }); - } else { - _message = deepcopy(message); - } - - // Rename _id to id - _message.id = _message._id; - delete _message._id; - - // Parse text - if (_message.text) { - _message.ast = parse(_message.text); - } - - // Populate user - _message.user = await serializeUser(_message.user_id, me); - - if (_message.file) { - // Populate file - _message.file = await serializeDriveFile(_message.file_id); - } - - if (opts.populateRecipient) { - // Populate recipient - _message.recipient = await serializeUser(_message.recipient_id, me); - } - - resolve(_message); -}); diff --git a/src/api/serializers/notification.ts b/src/api/serializers/notification.ts deleted file mode 100644 index ac919dc8b..000000000 --- a/src/api/serializers/notification.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import Notification from '../models/notification'; -import serializeUser from './user'; -import serializePost from './post'; -import deepcopy = require('deepcopy'); - -/** - * Serialize a notification - * - * @param {any} notification - * @return {Promise} - */ -export default (notification: any) => new Promise(async (resolve, reject) => { - let _notification: any; - - // Populate the notification if 'notification' is ID - if (mongo.ObjectID.prototype.isPrototypeOf(notification)) { - _notification = await Notification.findOne({ - _id: notification - }); - } else if (typeof notification === 'string') { - _notification = await Notification.findOne({ - _id: new mongo.ObjectID(notification) - }); - } else { - _notification = deepcopy(notification); - } - - // Rename _id to id - _notification.id = _notification._id; - delete _notification._id; - - // Rename notifier_id to user_id - _notification.user_id = _notification.notifier_id; - delete _notification.notifier_id; - - const me = _notification.notifiee_id; - delete _notification.notifiee_id; - - // Populate notifier - _notification.user = await serializeUser(_notification.user_id, me); - - switch (_notification.type) { - case 'follow': - // nope - break; - case 'mention': - case 'reply': - case 'repost': - case 'quote': - case 'reaction': - case 'poll_vote': - // Populate post - _notification.post = await serializePost(_notification.post_id, me); - break; - default: - console.error(`Unknown type: ${_notification.type}`); - break; - } - - resolve(_notification); -}); diff --git a/src/api/serializers/post-reaction.ts b/src/api/serializers/post-reaction.ts deleted file mode 100644 index b8807a741..000000000 --- a/src/api/serializers/post-reaction.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import deepcopy = require('deepcopy'); -import Reaction from '../models/post-reaction'; -import serializeUser from './user'; - -/** - * Serialize a reaction - * - * @param {any} reaction - * @param {any} me? - * @return {Promise} - */ -export default ( - reaction: any, - me?: any -) => new Promise(async (resolve, reject) => { - let _reaction: any; - - // Populate the reaction if 'reaction' is ID - if (mongo.ObjectID.prototype.isPrototypeOf(reaction)) { - _reaction = await Reaction.findOne({ - _id: reaction - }); - } else if (typeof reaction === 'string') { - _reaction = await Reaction.findOne({ - _id: new mongo.ObjectID(reaction) - }); - } else { - _reaction = deepcopy(reaction); - } - - // Rename _id to id - _reaction.id = _reaction._id; - delete _reaction._id; - - // Populate user - _reaction.user = await serializeUser(_reaction.user_id, me); - - resolve(_reaction); -}); diff --git a/src/api/serializers/post.ts b/src/api/serializers/post.ts deleted file mode 100644 index 03fd12077..000000000 --- a/src/api/serializers/post.ts +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import deepcopy = require('deepcopy'); -import { default as Post, IPost } from '../models/post'; -import Reaction from '../models/post-reaction'; -import { IUser } from '../models/user'; -import Vote from '../models/poll-vote'; -import serializeApp from './app'; -import serializeChannel from './channel'; -import serializeUser from './user'; -import serializeDriveFile from './drive-file'; -import parse from '../common/text'; -import rap from '@prezzemolo/rap'; - -/** - * Serialize a post - * - * @param post target - * @param me? serializee - * @param options? serialize options - * @return response - */ -const self = async ( - post: string | mongo.ObjectID | IPost, - me?: string | mongo.ObjectID | IUser, - options?: { - detail: boolean - } -) => { - const opts = options || { - detail: true, - }; - - // Me - const meId: mongo.ObjectID = me - ? mongo.ObjectID.prototype.isPrototypeOf(me) - ? me as mongo.ObjectID - : typeof me === 'string' - ? new mongo.ObjectID(me) - : (me as IUser)._id - : null; - - let _post: any; - - // Populate the post if 'post' is ID - if (mongo.ObjectID.prototype.isPrototypeOf(post)) { - _post = await Post.findOne({ - _id: post - }); - } else if (typeof post === 'string') { - _post = await Post.findOne({ - _id: new mongo.ObjectID(post) - }); - } else { - _post = deepcopy(post); - } - - if (!_post) throw 'invalid post arg.'; - - const id = _post._id; - - // Rename _id to id - _post.id = _post._id; - delete _post._id; - - delete _post.mentions; - - // Parse text - if (_post.text) { - _post.ast = parse(_post.text); - } - - // Populate user - _post.user = serializeUser(_post.user_id, meId); - - // Populate app - if (_post.app_id) { - _post.app = serializeApp(_post.app_id); - } - - // Populate channel - if (_post.channel_id) { - _post.channel = serializeChannel(_post.channel_id); - } - - // Populate media - if (_post.media_ids) { - _post.media = Promise.all(_post.media_ids.map(fileId => - serializeDriveFile(fileId) - )); - } - - // When requested a detailed post data - if (opts.detail) { - // Get previous post info - _post.prev = (async () => { - const prev = await Post.findOne({ - user_id: _post.user_id, - _id: { - $lt: id - } - }, { - fields: { - _id: true - }, - sort: { - _id: -1 - } - }); - return prev ? prev._id : null; - })(); - - // Get next post info - _post.next = (async () => { - const next = await Post.findOne({ - user_id: _post.user_id, - _id: { - $gt: id - } - }, { - fields: { - _id: true - }, - sort: { - _id: 1 - } - }); - return next ? next._id : null; - })(); - - if (_post.reply_id) { - // Populate reply to post - _post.reply = self(_post.reply_id, meId, { - detail: false - }); - } - - if (_post.repost_id) { - // Populate repost - _post.repost = self(_post.repost_id, meId, { - detail: _post.text == null - }); - } - - // Poll - if (meId && _post.poll) { - _post.poll = (async (poll) => { - const vote = await Vote - .findOne({ - user_id: meId, - post_id: id - }); - - if (vote != null) { - const myChoice = poll.choices - .filter(c => c.id == vote.choice)[0]; - - myChoice.is_voted = true; - } - - return poll; - })(_post.poll); - } - - // Fetch my reaction - if (meId) { - _post.my_reaction = (async () => { - const reaction = await Reaction - .findOne({ - user_id: meId, - post_id: id, - deleted_at: { $exists: false } - }); - - if (reaction) { - return reaction.reaction; - } - - return null; - })(); - } - } - - // resolve promises in _post object - _post = await rap(_post); - - return _post; -}; - -export default self; diff --git a/src/api/serializers/signin.ts b/src/api/serializers/signin.ts deleted file mode 100644 index 406806767..000000000 --- a/src/api/serializers/signin.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Module dependencies - */ -import deepcopy = require('deepcopy'); - -/** - * Serialize a signin record - * - * @param {any} record - * @return {Promise} - */ -export default ( - record: any -) => new Promise(async (resolve, reject) => { - - const _record = deepcopy(record); - - // Rename _id to id - _record.id = _record._id; - delete _record._id; - - resolve(_record); -}); diff --git a/src/api/serializers/user.ts b/src/api/serializers/user.ts deleted file mode 100644 index 3d8415660..000000000 --- a/src/api/serializers/user.ts +++ /dev/null @@ -1,173 +0,0 @@ -/** - * Module dependencies - */ -import * as mongo from 'mongodb'; -import deepcopy = require('deepcopy'); -import { default as User, IUser } from '../models/user'; -import serializePost from './post'; -import Following from '../models/following'; -import getFriends from '../common/get-friends'; -import config from '../../conf'; -import rap from '@prezzemolo/rap'; - -/** - * Serialize a user - * - * @param user target - * @param me? serializee - * @param options? serialize options - * @return response - */ -export default ( - user: string | mongo.ObjectID | IUser, - me?: string | mongo.ObjectID | IUser, - options?: { - detail?: boolean, - includeSecrets?: boolean - } -) => new Promise(async (resolve, reject) => { - - const opts = Object.assign({ - detail: false, - includeSecrets: false - }, options); - - let _user: any; - - const fields = opts.detail ? { - settings: false - } : { - settings: false, - client_settings: false, - profile: false, - keywords: false, - domains: false - }; - - // Populate the user if 'user' is ID - if (mongo.ObjectID.prototype.isPrototypeOf(user)) { - _user = await User.findOne({ - _id: user - }, { fields }); - } else if (typeof user === 'string') { - _user = await User.findOne({ - _id: new mongo.ObjectID(user) - }, { fields }); - } else { - _user = deepcopy(user); - } - - if (!_user) return reject('invalid user arg.'); - - // Me - const meId: mongo.ObjectID = me - ? mongo.ObjectID.prototype.isPrototypeOf(me) - ? me as mongo.ObjectID - : typeof me === 'string' - ? new mongo.ObjectID(me) - : (me as IUser)._id - : null; - - // Rename _id to id - _user.id = _user._id; - delete _user._id; - - // Remove needless properties - delete _user.latest_post; - - // Remove private properties - delete _user.password; - delete _user.token; - delete _user.username_lower; - if (_user.twitter) { - delete _user.twitter.access_token; - delete _user.twitter.access_token_secret; - } - delete _user.line; - - // Visible via only the official client - if (!opts.includeSecrets) { - delete _user.email; - delete _user.client_settings; - } - - _user.avatar_url = _user.avatar_id != null - ? `${config.drive_url}/${_user.avatar_id}` - : `${config.drive_url}/default-avatar.jpg`; - - _user.banner_url = _user.banner_id != null - ? `${config.drive_url}/${_user.banner_id}` - : null; - - if (!meId || !meId.equals(_user.id) || !opts.detail) { - delete _user.avatar_id; - delete _user.banner_id; - - delete _user.drive_capacity; - } - - if (meId && !meId.equals(_user.id)) { - // If the user is following - _user.is_following = (async () => { - const follow = await Following.findOne({ - follower_id: meId, - followee_id: _user.id, - deleted_at: { $exists: false } - }); - return follow !== null; - })(); - - // If the user is followed - _user.is_followed = (async () => { - const follow2 = await Following.findOne({ - follower_id: _user.id, - followee_id: meId, - deleted_at: { $exists: false } - }); - return follow2 !== null; - })(); - } - - if (opts.detail) { - if (_user.pinned_post_id) { - // Populate pinned post - _user.pinned_post = serializePost(_user.pinned_post_id, meId, { - detail: true - }); - } - - if (meId && !meId.equals(_user.id)) { - const myFollowingIds = await getFriends(meId); - - // Get following you know count - _user.following_you_know_count = Following.count({ - followee_id: { $in: myFollowingIds }, - follower_id: _user.id, - deleted_at: { $exists: false } - }); - - // Get followers you know count - _user.followers_you_know_count = Following.count({ - followee_id: _user.id, - follower_id: { $in: myFollowingIds }, - deleted_at: { $exists: false } - }); - } - } - - // resolve promises in _user object - _user = await rap(_user); - - resolve(_user); -}); -/* -function img(url) { - return { - thumbnail: { - large: `${url}`, - medium: '', - small: '' - } - }; -} -*/ diff --git a/src/api/server.ts b/src/api/server.ts deleted file mode 100644 index 026357b46..000000000 --- a/src/api/server.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * API Server - */ - -import * as express from 'express'; -import * as bodyParser from 'body-parser'; -import * as cors from 'cors'; -import * as multer from 'multer'; - -// import authenticate from './authenticate'; -import endpoints from './endpoints'; - -/** - * Init app - */ -const app = express(); - -app.disable('x-powered-by'); -app.set('etag', false); -app.use(bodyParser.urlencoded({ extended: true })); -app.use(bodyParser.json({ - type: ['application/json', 'text/plain'], - verify: (req, res, buf, encoding) => { - if (buf && buf.length) { - (req as any).rawBody = buf.toString(encoding || 'utf8'); - } - } -})); -app.use(cors({ - origin: true -})); - -app.get('/', (req, res) => { - res.send('YEE HAW'); -}); - -/** - * Register endpoint handlers - */ -endpoints.forEach(endpoint => - endpoint.withFile ? - app.post(`/${endpoint.name}`, - endpoint.withFile ? multer({ storage: multer.diskStorage({}) }).single('file') : null, - require('./api-handler').default.bind(null, endpoint)) : - app.post(`/${endpoint.name}`, - require('./api-handler').default.bind(null, endpoint)) -); - -app.post('/signup', require('./private/signup').default); -app.post('/signin', require('./private/signin').default); - -app.use((req, res, next) => { - // req.headers['cookie'] は常に string ですが、型定義の都合上 - // string | string[] になっているので string を明示しています - res.locals.user = ((req.headers['cookie'] as string || '').match(/i=(!\w+)/) || [null, null])[1]; - next(); -}); - -require('./service/github')(app); -require('./service/twitter')(app); - -require('./bot/interfaces/line')(app); - -module.exports = app; diff --git a/src/api/service/github.ts b/src/api/service/github.ts deleted file mode 100644 index 1c78267c0..000000000 --- a/src/api/service/github.ts +++ /dev/null @@ -1,138 +0,0 @@ -import * as EventEmitter from 'events'; -import * as express from 'express'; -import * as request from 'request'; -const crypto = require('crypto'); -import User from '../models/user'; -import config from '../../conf'; - -module.exports = async (app: express.Application) => { - if (config.github_bot == null) return; - - const bot = await User.findOne({ - username_lower: config.github_bot.username.toLowerCase() - }); - - if (bot == null) { - console.warn(`GitHub hook bot specified, but not found: @${config.github_bot.username}`); - return; - } - - const post = text => require('../endpoints/posts/create')({ text }, bot); - - const handler = new EventEmitter(); - - app.post('/hooks/github', (req, res, next) => { - // req.headers['x-hub-signature'] および - // req.headers['x-github-event'] は常に string ですが、型定義の都合上 - // string | string[] になっているので string を明示しています - if ((new Buffer(req.headers['x-hub-signature'] as string)).equals(new Buffer(`sha1=${crypto.createHmac('sha1', config.github_bot.hook_secret).update(JSON.stringify(req.body)).digest('hex')}`))) { - handler.emit(req.headers['x-github-event'] as string, req.body); - res.sendStatus(200); - } else { - res.sendStatus(400); - } - }); - - handler.on('status', event => { - const state = event.state; - switch (state) { - case 'error': - case 'failure': - const commit = event.commit; - const parent = commit.parents[0]; - - // Fetch parent status - request({ - url: `${parent.url}/statuses`, - headers: { - 'User-Agent': 'misskey' - } - }, (err, res, body) => { - if (err) { - console.error(err); - return; - } - const parentStatuses = JSON.parse(body); - const parentState = parentStatuses[0].state; - const stillFailed = parentState == 'failure' || parentState == 'error'; - if (stillFailed) { - post(`**⚠️BUILD STILL FAILED⚠️**: ?[${commit.commit.message}](${commit.html_url})`); - } else { - post(`**🚨BUILD FAILED🚨**: →→→?[${commit.commit.message}](${commit.html_url})←←←`); - } - }); - break; - } - }); - - handler.on('push', event => { - const ref = event.ref; - switch (ref) { - case 'refs/heads/master': - const pusher = event.pusher; - const compare = event.compare; - const commits = event.commits; - post([ - `Pushed by **${pusher.name}** with ?[${commits.length} commit${commits.length > 1 ? 's' : ''}](${compare}):`, - commits.reverse().map(commit => `・[?[${commit.id.substr(0, 7)}](${commit.url})] ${commit.message.split('\n')[0]}`).join('\n'), - ].join('\n')); - break; - case 'refs/heads/release': - const commit = event.commits[0]; - post(`RELEASED: ${commit.message}`); - break; - } - }); - - handler.on('issues', event => { - const issue = event.issue; - const action = event.action; - let title: string; - switch (action) { - case 'opened': title = 'Issue opened'; break; - case 'closed': title = 'Issue closed'; break; - case 'reopened': title = 'Issue reopened'; break; - default: return; - } - post(`${title}: <${issue.number}>「${issue.title}」\n${issue.html_url}`); - }); - - handler.on('issue_comment', event => { - const issue = event.issue; - const comment = event.comment; - const action = event.action; - let text: string; - switch (action) { - case 'created': text = `Commented to「${issue.title}」:${comment.user.login}「${comment.body}」\n${comment.html_url}`; break; - default: return; - } - post(text); - }); - - handler.on('watch', event => { - const sender = event.sender; - post(`⭐️ Starred by **${sender.login}** ⭐️`); - }); - - handler.on('fork', event => { - const repo = event.forkee; - post(`🍴 Forked:\n${repo.html_url} 🍴`); - }); - - handler.on('pull_request', event => { - const pr = event.pull_request; - const action = event.action; - let text: string; - switch (action) { - case 'opened': text = `New Pull Request:「${pr.title}」\n${pr.html_url}`; break; - case 'reopened': text = `Pull Request Reopened:「${pr.title}」\n${pr.html_url}`; break; - case 'closed': - text = pr.merged - ? `Pull Request Merged!:「${pr.title}」\n${pr.html_url}` - : `Pull Request Closed:「${pr.title}」\n${pr.html_url}`; - break; - default: return; - } - post(text); - }); -}; diff --git a/src/api/service/twitter.ts b/src/api/service/twitter.ts deleted file mode 100644 index f164cdc45..000000000 --- a/src/api/service/twitter.ts +++ /dev/null @@ -1,131 +0,0 @@ -import * as express from 'express'; -import * as cookie from 'cookie'; -import * as uuid from 'uuid'; -// import * as Twitter from 'twitter'; -// const Twitter = require('twitter'); -import autwh from 'autwh'; -import redis from '../../db/redis'; -import User from '../models/user'; -import serialize from '../serializers/user'; -import event from '../event'; -import config from '../../conf'; -import signin from '../common/signin'; - -module.exports = (app: express.Application) => { - app.get('/disconnect/twitter', async (req, res): Promise => { - if (res.locals.user == null) return res.send('plz signin'); - const user = await User.findOneAndUpdate({ - token: res.locals.user - }, { - $set: { - twitter: null - } - }); - - res.send(`Twitterの連携を解除しました :v:`); - - // Publish i updated event - event(user._id, 'i_updated', await serialize(user, user, { - detail: true, - includeSecrets: true - })); - }); - - if (config.twitter == null) { - app.get('/connect/twitter', (req, res) => { - res.send('現在Twitterへ接続できません (このインスタンスではTwitterはサポートされていません)'); - }); - - app.get('/signin/twitter', (req, res) => { - res.send('現在Twitterへ接続できません (このインスタンスではTwitterはサポートされていません)'); - }); - - return; - } - - const twAuth = autwh({ - consumerKey: config.twitter.consumer_key, - consumerSecret: config.twitter.consumer_secret, - callbackUrl: `${config.api_url}/tw/cb` - }); - - app.get('/connect/twitter', async (req, res): Promise => { - if (res.locals.user == null) return res.send('plz signin'); - const ctx = await twAuth.begin(); - redis.set(res.locals.user, JSON.stringify(ctx)); - res.redirect(ctx.url); - }); - - app.get('/signin/twitter', async (req, res): Promise => { - const ctx = await twAuth.begin(); - - const sessid = uuid(); - - redis.set(sessid, JSON.stringify(ctx)); - - const expires = 1000 * 60 * 60; // 1h - res.cookie('signin_with_twitter_session_id', sessid, { - path: '/', - domain: `.${config.host}`, - secure: config.url.substr(0, 5) === 'https', - httpOnly: true, - expires: new Date(Date.now() + expires), - maxAge: expires - }); - - res.redirect(ctx.url); - }); - - app.get('/tw/cb', (req, res): any => { - if (res.locals.user == null) { - // req.headers['cookie'] は常に string ですが、型定義の都合上 - // string | string[] になっているので string を明示しています - const cookies = cookie.parse((req.headers['cookie'] as string || '')); - - const sessid = cookies['signin_with_twitter_session_id']; - - if (sessid == undefined) { - res.status(400).send('invalid session'); - } - - redis.get(sessid, async (_, ctx) => { - const result = await twAuth.done(JSON.parse(ctx), req.query.oauth_verifier); - - const user = await User.findOne({ - 'twitter.user_id': result.userId - }); - - if (user == null) { - res.status(404).send(`@${result.screenName}と連携しているMisskeyアカウントはありませんでした...`); - } - - signin(res, user, true); - }); - } else { - redis.get(res.locals.user, async (_, ctx) => { - const result = await twAuth.done(JSON.parse(ctx), req.query.oauth_verifier); - - const user = await User.findOneAndUpdate({ - token: res.locals.user - }, { - $set: { - twitter: { - access_token: result.accessToken, - access_token_secret: result.accessTokenSecret, - user_id: result.userId, - screen_name: result.screenName - } - } - }); - - res.send(`Twitter: @${result.screenName} を、Misskey: @${user.username} に接続しました!`); - - // Publish i updated event - event(user._id, 'i_updated', await serialize(user, user, { - detail: true, - includeSecrets: true - })); - }); - } - }); -}; diff --git a/src/api/stream/home.ts b/src/api/stream/home.ts deleted file mode 100644 index 7c8f3bfec..000000000 --- a/src/api/stream/home.ts +++ /dev/null @@ -1,62 +0,0 @@ -import * as websocket from 'websocket'; -import * as redis from 'redis'; -import * as debug from 'debug'; - -import User from '../models/user'; -import serializePost from '../serializers/post'; -import readNotification from '../common/read-notification'; - -const log = debug('misskey'); - -export default function homeStream(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void { - // Subscribe Home stream channel - subscriber.subscribe(`misskey:user-stream:${user._id}`); - - subscriber.on('message', async (channel, data) => { - switch (channel.split(':')[1]) { - case 'user-stream': - connection.send(data); - break; - case 'post-stream': - const postId = channel.split(':')[2]; - log(`RECEIVED: ${postId} ${data} by @${user.username}`); - const post = await serializePost(postId, user, { - detail: true - }); - connection.send(JSON.stringify({ - type: 'post-updated', - body: { - post: post - } - })); - break; - } - }); - - connection.on('message', data => { - const msg = JSON.parse(data.utf8Data); - - switch (msg.type) { - case 'alive': - // Update lastUsedAt - User.update({ _id: user._id }, { - $set: { - last_used_at: new Date() - } - }); - break; - - case 'read_notification': - if (!msg.id) return; - readNotification(user._id, msg.id); - break; - - case 'capture': - if (!msg.id) return; - const postId = msg.id; - log(`CAPTURE: ${postId} by @${user.username}`); - subscriber.subscribe(`misskey:post-stream:${postId}`); - break; - } - }); -} diff --git a/src/build/fa.ts b/src/build/fa.ts new file mode 100644 index 000000000..f6f2427d0 --- /dev/null +++ b/src/build/fa.ts @@ -0,0 +1,57 @@ +/** + * Replace fontawesome symbols + */ + +import * as fontawesome from '@fortawesome/fontawesome'; +import * as regular from '@fortawesome/fontawesome-free-regular'; +import * as solid from '@fortawesome/fontawesome-free-solid'; +import * as brands from '@fortawesome/fontawesome-free-brands'; + +// Add icons +fontawesome.library.add(regular); +fontawesome.library.add(solid); +fontawesome.library.add(brands); + +export const pattern = /%fa:(.+?)%/g; + +export const replacement = (match, key) => { + const args = key.split(' '); + let prefix = 'fas'; + const classes = []; + let transform = ''; + let name; + + args.forEach(arg => { + if (arg == 'R' || arg == 'S' || arg == 'B') { + prefix = + arg == 'R' ? 'far' : + arg == 'S' ? 'fas' : + arg == 'B' ? 'fab' : + ''; + } else if (arg[0] == '.') { + classes.push('fa-' + arg.substr(1)); + } else if (arg[0] == '-') { + transform = arg.substr(1).split('|').join(' '); + } else { + name = arg; + } + }); + + const icon = fontawesome.icon({ prefix, iconName: name }, { + classes: classes + }); + + if (icon) { + icon.transform = fontawesome.parse.transform(transform); + return `${icon.html[0]}`; + } else { + console.warn(`'${name}' not found in fa`); + return ''; + } +}; + +export default (src: string) => { + return src.replace(pattern, replacement); +}; + +export const fa = fontawesome; diff --git a/src/build/i18n.ts b/src/build/i18n.ts new file mode 100644 index 000000000..a6cc6c38f --- /dev/null +++ b/src/build/i18n.ts @@ -0,0 +1,78 @@ +/** + * Replace i18n texts + */ + +import locale from '../../locales'; + +export default class Replacer { + private lang: string; + + public pattern = /%i18n:([a-z_\-@\.\!]+?)%/g; + + constructor(lang: string) { + this.lang = lang; + + this.get = this.get.bind(this); + this.replacement = this.replacement.bind(this); + } + + private get(path: string, key: string) { + const texts = locale[this.lang]; + + if (texts == null) { + console.warn(`lang '${this.lang}' is not supported`); + return key; // Fallback + } + + let text = texts; + + if (path) { + if (text.hasOwnProperty(path)) { + text = text[path]; + } else { + console.warn(`path '${path}' not found in '${this.lang}'`); + return key; // Fallback + } + } + + // Check the key existance + const error = key.split('.').some(k => { + if (text.hasOwnProperty(k)) { + text = text[k]; + return false; + } else { + return true; + } + }); + + if (error) { + console.warn(`key '${key}' not found in '${path}' of '${this.lang}'`); + return key; // Fallback + } else { + return text; + } + } + + public replacement(ctx, match, key) { + const client = '/src/client/app/'; + let name = null; + + const shouldEscape = key[0] == '!'; + if (shouldEscape) { + key = key.substr(1); + } + + if (key[0] == '@') { + name = ctx.src.substr(ctx.src.indexOf(client) + client.length); + key = key.substr(1); + } + + if (ctx && ctx.lang) this.lang = ctx.lang; + + const txt = this.get(name, key); + + return shouldEscape + ? txt.replace(/'/g, '\\x27').replace(/"/g, '\\x22') + : txt.replace(/"/g, '"'); + } +} diff --git a/src/build/license.ts b/src/build/license.ts new file mode 100644 index 000000000..d36af665c --- /dev/null +++ b/src/build/license.ts @@ -0,0 +1,13 @@ +import * as fs from 'fs'; + +const license = fs.readFileSync(__dirname + '/../../LICENSE', 'utf-8'); + +const licenseHtml = license + .replace(/\r\n/g, '\n') + .replace(/(.)\n(.)/g, '$1 $2') + .replace(/(^|\n)(.*?)($|\n)/g, '

$2

'); + +export { + license, + licenseHtml +}; diff --git a/src/cafy-id.ts b/src/cafy-id.ts new file mode 100644 index 000000000..310b1eb20 --- /dev/null +++ b/src/cafy-id.ts @@ -0,0 +1,29 @@ +import * as mongo from 'mongodb'; +import { Query } from 'cafy'; + +export const isAnId = x => mongo.ObjectID.isValid(x); +export const isNotAnId = x => !isAnId(x); + +/** + * ID + */ +export default class ID extends Query { + constructor() { + super(); + + this.transform = v => { + if (isAnId(v) && !mongo.ObjectID.prototype.isPrototypeOf(v)) { + return new mongo.ObjectID(v); + } else { + return v; + } + }; + + this.push(v => { + if (!mongo.ObjectID.prototype.isPrototypeOf(v) && isNotAnId(v)) { + return new Error('must-be-an-id'); + } + return true; + }); + } +} diff --git a/src/client/app/animation.styl b/src/client/app/animation.styl new file mode 100644 index 000000000..8f121b313 --- /dev/null +++ b/src/client/app/animation.styl @@ -0,0 +1,12 @@ +.zoom-in-top-enter-active, +.zoom-in-top-leave-active { + opacity: 1; + transform: scaleY(1); + transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1), opacity 300ms cubic-bezier(0.23, 1, 0.32, 1); + transform-origin: center top; +} +.zoom-in-top-enter, +.zoom-in-top-leave-active { + opacity: 0; + transform: scaleY(0); +} diff --git a/src/web/app/app.styl b/src/client/app/app.styl similarity index 69% rename from src/web/app/app.styl rename to src/client/app/app.styl index 94faba73d..431b9daa6 100644 --- a/src/web/app/app.styl +++ b/src/client/app/app.styl @@ -1,29 +1,5 @@ -json('../../const.json') - -@charset 'utf-8' - -$theme-color = themeColor -$theme-color-foreground = themeColorForeground - -/* - ::selection - background $theme-color - color #fff -*/ - -* - position relative - box-sizing border-box - background-clip padding-box !important - tap-highlight-color rgba($theme-color, 0.7) - -webkit-tap-highlight-color rgba($theme-color, 0.7) - -html, body - margin 0 - padding 0 - scroll-behavior smooth - text-size-adjust 100% - font-family sans-serif +@import "../style" +@import "../animation" html &.progress @@ -96,17 +72,6 @@ body 100% transform rotate(360deg) -a - text-decoration none - color $theme-color - cursor pointer - - &:hover - text-decoration underline - - * - cursor pointer - code font-family Consolas, 'Courier New', Courier, Monaco, monospace @@ -159,12 +124,5 @@ pre overflow auto tab-size 2 -mk-locker - display block - position fixed - top 0 - left 0 - z-index 65536 - width 100% - height 100% - cursor wait +[data-fa] + display inline-block diff --git a/src/client/app/app.vue b/src/client/app/app.vue new file mode 100644 index 000000000..7a46e7dea --- /dev/null +++ b/src/client/app/app.vue @@ -0,0 +1,3 @@ + diff --git a/src/web/app/auth/assets/logo.svg b/src/client/app/auth/assets/logo.svg similarity index 100% rename from src/web/app/auth/assets/logo.svg rename to src/client/app/auth/assets/logo.svg diff --git a/src/client/app/auth/script.ts b/src/client/app/auth/script.ts new file mode 100644 index 000000000..20f59bf03 --- /dev/null +++ b/src/client/app/auth/script.ts @@ -0,0 +1,30 @@ +/** + * Authorize Form + */ + +import VueRouter from 'vue-router'; + +// Style +import './style.styl'; + +import init from '../init'; + +import Index from './views/index.vue'; + +/** + * init + */ +init(launch => { + document.title = 'Misskey | アプリの連携'; + + // Init router + const router = new VueRouter({ + mode: 'history', + routes: [ + { path: '/:token', component: Index }, + ] + }); + + // Launch the app + launch(router); +}); diff --git a/src/web/app/auth/style.styl b/src/client/app/auth/style.styl similarity index 100% rename from src/web/app/auth/style.styl rename to src/client/app/auth/style.styl diff --git a/src/client/app/auth/views/form.vue b/src/client/app/auth/views/form.vue new file mode 100644 index 000000000..152b90042 --- /dev/null +++ b/src/client/app/auth/views/form.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/src/client/app/auth/views/index.vue b/src/client/app/auth/views/index.vue new file mode 100644 index 000000000..0fcd9bfe5 --- /dev/null +++ b/src/client/app/auth/views/index.vue @@ -0,0 +1,149 @@ + + + + + diff --git a/src/web/app/base.pug b/src/client/app/base.pug similarity index 62% rename from src/web/app/base.pug rename to src/client/app/base.pug index 3c3546d50..32a95a6c9 100644 --- a/src/web/app/base.pug +++ b/src/client/app/base.pug @@ -14,20 +14,24 @@ html title Misskey style - include ./../../../built/web/assets/init.css + include ./../../../built/client/assets/init.css script - include ./../../../built/web/assets/boot.js + include ./../../../built/client/assets/boot.js script - include ./../../../built/web/assets/safe.js + include ./../../../built/client/assets/safe.js - script(src='https://use.fontawesome.com/db921426cb.js' async) + //- FontAwesome style + style #{facss} + + //- highlight.js style + style #{hljscss} body noscript: p | JavaScriptを有効にしてください br - | Please turn on JavaScript + | Please turn on your JavaScript div#ini: p span . span . diff --git a/src/web/app/boot.js b/src/client/app/boot.js similarity index 54% rename from src/web/app/boot.js rename to src/client/app/boot.js index 0a3154ad8..35d02cf9c 100644 --- a/src/web/app/boot.js +++ b/src/client/app/boot.js @@ -11,30 +11,29 @@ 'use strict'; -// Chromeで確認したことなのですが、constやletを用いたとしても -// グローバルなスコープで定数/変数を定義するとwindowのプロパティ -// としてそれがアクセスできるようになる訳ではありませんが、普通に -// コンソールから定数/変数名を入力するとアクセスできてしまいます。 -// ブロック内に入れてスコープを非グローバル化するとそれが防げます -// (Chrome以外のブラウザでは検証していません) -{ +(function() { + // キャッシュ削除要求があれば従う + if (localStorage.getItem('shouldFlush') == 'true') { + refresh(); + return; + } + // Get the current url information const url = new URL(location.href); - // Extarct the (sub) domain part of the current url - // - // e.g. - // misskey.alice => misskey - // misskey.strawberry.pasta => misskey - // dev.misskey.arisu.tachibana => dev - let app = url.host == 'localhost' - ? 'misskey' - : url.host.split('.')[0]; + //#region Detect app name + let app = null; + + if (url.pathname == '/docs') app = 'docs'; + if (url.pathname == '/dev') app = 'dev'; + if (url.pathname == '/auth') app = 'auth'; + //#endregion // Detect the user language - // Note: The default language is English + // Note: The default language is Japanese let lang = navigator.language.split('-')[0]; - if (!/^(en|ja)$/.test(lang)) lang = 'en'; + if (!/^(en|ja)$/.test(lang)) lang = 'ja'; + if (localStorage.getItem('lang')) lang = localStorage.getItem('lang'); // Detect the user agent const ua = navigator.userAgent.toLowerCase(); @@ -57,20 +56,40 @@ } // Switch desktop or mobile version - if (app == 'misskey') { + if (app == null) { app = isMobile ? 'mobile' : 'desktop'; } + // Dark/Light + if (localStorage.getItem('darkmode') == 'true') { + document.documentElement.setAttribute('data-darkmode', 'true'); + } + + // Script version + const ver = localStorage.getItem('v') || VERSION; + + // Whether in debug mode + const isDebug = localStorage.getItem('debug') == 'true'; + + // Whether use raw version script + const raw = (localStorage.getItem('useRawScript') == 'true' && isDebug) + || ENV != 'production'; + + // Get salt query + const salt = localStorage.getItem('salt') + ? '?salt=' + localStorage.getItem('salt') + : ''; + // Load an app script // Note: 'async' make it possible to load the script asyncly. // 'defer' make it possible to run the script when the dom loaded. const script = document.createElement('script'); - script.setAttribute('src', `/assets/${app}.${VERSION}.${lang}.js`); + script.setAttribute('src', `/assets/${app}.${ver}.${lang}.${raw ? 'raw' : 'min'}.js${salt}`); script.setAttribute('async', 'true'); script.setAttribute('defer', 'true'); head.appendChild(script); - // 1秒経ってもスクリプトがロードされない場合はバージョンが古くて + // 3秒経ってもスクリプトがロードされない場合はバージョンが古くて // 404になっているせいかもしれないので、バージョンを確認して古ければ更新する // // 読み込まれたスクリプトからこのタイマーを解除できるように、 @@ -86,21 +105,36 @@ const meta = await res.json(); // Compare versions - if (meta.version != VERSION) { + if (meta.clientVersion != ver) { + localStorage.setItem('v', meta.clientVersion); + alert( 'Misskeyの新しいバージョンがあります。ページを再度読み込みします。' + '\n\n' + 'New version of Misskey available. The page will be reloaded.'); - // Clear cache (serive worker) - try { - navigator.serviceWorker.controller.postMessage('clear'); - } catch (e) { - console.error(e); - } - - // Force reload - location.reload(true); + refresh(); } - }, 1000); -} + }, 3000); + + function refresh() { + localStorage.setItem('shouldFlush', 'false'); + + // Random + localStorage.setItem('salt', Math.random().toString()); + + // Clear cache (serive worker) + try { + navigator.serviceWorker.controller.postMessage('clear'); + + navigator.serviceWorker.getRegistrations().then(registrations => { + registrations.forEach(registration => registration.unregister()); + }); + } catch (e) { + console.error(e); + } + + // Force reload + location.reload(true); + } +})(); diff --git a/src/web/app/ch/script.ts b/src/client/app/ch/script.ts similarity index 69% rename from src/web/app/ch/script.ts rename to src/client/app/ch/script.ts index e23558037..4c6b6dfd1 100644 --- a/src/web/app/ch/script.ts +++ b/src/client/app/ch/script.ts @@ -7,12 +7,9 @@ import './style.styl'; require('./tags'); import init from '../init'; -import route from './router'; /** * init */ init(() => { - // Start routing - route(); }); diff --git a/src/web/app/ch/style.styl b/src/client/app/ch/style.styl similarity index 100% rename from src/web/app/ch/style.styl rename to src/client/app/ch/style.styl diff --git a/src/web/app/ch/tags/channel.tag b/src/client/app/ch/tags/channel.tag similarity index 63% rename from src/web/app/ch/tags/channel.tag rename to src/client/app/ch/tags/channel.tag index 716d61cde..74b1a9ba1 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/client/app/ch/tags/channel.tag @@ -1,12 +1,12 @@
-
+

{ channel.title }

-
-

このチャンネルをウォッチしています ウォッチ解除

-

このチャンネルをウォッチする

+
+

このチャンネルをウォッチしています ウォッチ解除

+

このチャンネルをウォッチする

-

読み込み中

-
-

まだ投稿がありません

- - - +

読み込み中

+
+

まだ投稿がありません

+

- -
+ +

参加するにはログインまたは新規登録してください


@@ -33,7 +33,7 @@ Misskey ver { _VERSION_ } (葵 aoi)
- - - +
- { post.index }: - { post.user.name } - - - ID:{ post.user.username } + { note.index }: + { getUserName(note.user) } + + + ID:{ acct }
- >>{ post.reply.index } - { post.text } -
- + >>{ note.reply.index } + { note.text } +
+
- - - + -

>>{ reply.index } ({ reply.user.name }): [x]

+

>>{ reply.index } ({ getUserName(reply.user) }): [x]

- - - + +
-
    +
    1. { name }
    - - - + diff --git a/src/web/app/ch/tags/index.tag b/src/client/app/ch/tags/index.tag similarity index 59% rename from src/web/app/ch/tags/index.tag rename to src/client/app/ch/tags/index.tag index 5f3871802..529b83b2c 100644 --- a/src/web/app/ch/tags/index.tag +++ b/src/client/app/ch/tags/index.tag @@ -1,21 +1,21 @@
    - +
    -
      + - - + + diff --git a/src/client/app/common/views/components/avatar.vue b/src/client/app/common/views/components/avatar.vue new file mode 100644 index 000000000..6ff00e798 --- /dev/null +++ b/src/client/app/common/views/components/avatar.vue @@ -0,0 +1,39 @@ + + + + + diff --git a/src/client/app/common/views/components/connect-failed.troubleshooter.vue b/src/client/app/common/views/components/connect-failed.troubleshooter.vue new file mode 100644 index 000000000..6a922676b --- /dev/null +++ b/src/client/app/common/views/components/connect-failed.troubleshooter.vue @@ -0,0 +1,146 @@ + + + + + diff --git a/src/client/app/common/views/components/connect-failed.vue b/src/client/app/common/views/components/connect-failed.vue new file mode 100644 index 000000000..6c194ff98 --- /dev/null +++ b/src/client/app/common/views/components/connect-failed.vue @@ -0,0 +1,103 @@ + + + + + + diff --git a/src/client/app/common/views/components/ellipsis.vue b/src/client/app/common/views/components/ellipsis.vue new file mode 100644 index 000000000..07349902d --- /dev/null +++ b/src/client/app/common/views/components/ellipsis.vue @@ -0,0 +1,26 @@ + + + diff --git a/src/client/app/common/views/components/file-type-icon.vue b/src/client/app/common/views/components/file-type-icon.vue new file mode 100644 index 000000000..b7e868d1f --- /dev/null +++ b/src/client/app/common/views/components/file-type-icon.vue @@ -0,0 +1,17 @@ + + + diff --git a/src/client/app/common/views/components/forkit.vue b/src/client/app/common/views/components/forkit.vue new file mode 100644 index 000000000..2a463ebfd --- /dev/null +++ b/src/client/app/common/views/components/forkit.vue @@ -0,0 +1,42 @@ + + + diff --git a/src/client/app/common/views/components/google.vue b/src/client/app/common/views/components/google.vue new file mode 100644 index 000000000..92817d3c1 --- /dev/null +++ b/src/client/app/common/views/components/google.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/src/client/app/common/views/components/index.ts b/src/client/app/common/views/components/index.ts new file mode 100644 index 000000000..69fed00c7 --- /dev/null +++ b/src/client/app/common/views/components/index.ts @@ -0,0 +1,53 @@ +import Vue from 'vue'; + +import signin from './signin.vue'; +import signup from './signup.vue'; +import forkit from './forkit.vue'; +import avatar from './avatar.vue'; +import nav from './nav.vue'; +import noteHtml from './note-html'; +import poll from './poll.vue'; +import pollEditor from './poll-editor.vue'; +import reactionIcon from './reaction-icon.vue'; +import reactionsViewer from './reactions-viewer.vue'; +import time from './time.vue'; +import timer from './timer.vue'; +import mediaList from './media-list.vue'; +import uploader from './uploader.vue'; +import specialMessage from './special-message.vue'; +import streamIndicator from './stream-indicator.vue'; +import ellipsis from './ellipsis.vue'; +import messaging from './messaging.vue'; +import messagingRoom from './messaging-room.vue'; +import urlPreview from './url-preview.vue'; +import twitterSetting from './twitter-setting.vue'; +import fileTypeIcon from './file-type-icon.vue'; +import Switch from './switch.vue'; +import Othello from './othello.vue'; +import welcomeTimeline from './welcome-timeline.vue'; + +Vue.component('mk-signin', signin); +Vue.component('mk-signup', signup); +Vue.component('mk-forkit', forkit); +Vue.component('mk-avatar', avatar); +Vue.component('mk-nav', nav); +Vue.component('mk-note-html', noteHtml); +Vue.component('mk-poll', poll); +Vue.component('mk-poll-editor', pollEditor); +Vue.component('mk-reaction-icon', reactionIcon); +Vue.component('mk-reactions-viewer', reactionsViewer); +Vue.component('mk-time', time); +Vue.component('mk-timer', timer); +Vue.component('mk-media-list', mediaList); +Vue.component('mk-uploader', uploader); +Vue.component('mk-special-message', specialMessage); +Vue.component('mk-stream-indicator', streamIndicator); +Vue.component('mk-ellipsis', ellipsis); +Vue.component('mk-messaging', messaging); +Vue.component('mk-messaging-room', messagingRoom); +Vue.component('mk-url-preview', urlPreview); +Vue.component('mk-twitter-setting', twitterSetting); +Vue.component('mk-file-type-icon', fileTypeIcon); +Vue.component('mk-switch', Switch); +Vue.component('mk-othello', Othello); +Vue.component('mk-welcome-timeline', welcomeTimeline); diff --git a/src/client/app/common/views/components/media-list.vue b/src/client/app/common/views/components/media-list.vue new file mode 100644 index 000000000..64172ad0b --- /dev/null +++ b/src/client/app/common/views/components/media-list.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/src/client/app/common/views/components/messaging-room.form.vue b/src/client/app/common/views/components/messaging-room.form.vue new file mode 100644 index 000000000..32a43ace5 --- /dev/null +++ b/src/client/app/common/views/components/messaging-room.form.vue @@ -0,0 +1,305 @@ + + + + + diff --git a/src/client/app/common/views/components/messaging-room.message.vue b/src/client/app/common/views/components/messaging-room.message.vue new file mode 100644 index 000000000..ba0ab3209 --- /dev/null +++ b/src/client/app/common/views/components/messaging-room.message.vue @@ -0,0 +1,257 @@ + + + + + diff --git a/src/client/app/common/views/components/messaging-room.vue b/src/client/app/common/views/components/messaging-room.vue new file mode 100644 index 000000000..a45114e6b --- /dev/null +++ b/src/client/app/common/views/components/messaging-room.vue @@ -0,0 +1,377 @@ + + + + + diff --git a/src/client/app/common/views/components/messaging.vue b/src/client/app/common/views/components/messaging.vue new file mode 100644 index 000000000..11f9c366d --- /dev/null +++ b/src/client/app/common/views/components/messaging.vue @@ -0,0 +1,470 @@ + + + + + diff --git a/src/client/app/common/views/components/nav.vue b/src/client/app/common/views/components/nav.vue new file mode 100644 index 000000000..cd1f99288 --- /dev/null +++ b/src/client/app/common/views/components/nav.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/src/client/app/common/views/components/note-html.ts b/src/client/app/common/views/components/note-html.ts new file mode 100644 index 000000000..f86b50659 --- /dev/null +++ b/src/client/app/common/views/components/note-html.ts @@ -0,0 +1,174 @@ +import Vue from 'vue'; +import * as emojilib from 'emojilib'; +import parse from '../../../../../text/parse'; +import getAcct from '../../../../../acct/render'; +import { url } from '../../../config'; +import MkUrl from './url.vue'; +import MkGoogle from './google.vue'; + +const flatten = list => list.reduce( + (a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), [] +); + +export default Vue.component('mk-note-html', { + props: { + text: { + type: String, + required: true + }, + ast: { + type: [], + required: false + }, + shouldBreak: { + type: Boolean, + default: true + }, + i: { + type: Object, + default: null + } + }, + + render(createElement) { + let ast; + + if (this.ast == null) { + // Parse text to ast + ast = parse(this.text); + } else { + ast = this.ast; + } + + // Parse ast to DOM + const els = flatten(ast.map(token => { + switch (token.type) { + case 'text': + const text = token.content.replace(/(\r\n|\n|\r)/g, '\n'); + + if (this.shouldBreak) { + const x = text.split('\n') + .map(t => t == '' ? [createElement('br')] : [createElement('span', t), createElement('br')]); + x[x.length - 1].pop(); + return x; + } else { + return createElement('span', text.replace(/\n/g, ' ')); + } + + case 'bold': + return createElement('strong', token.bold); + + case 'url': + return createElement(MkUrl, { + props: { + url: token.content, + target: '_blank' + } + }); + + case 'link': + return createElement('a', { + attrs: { + class: 'link', + href: token.url, + target: '_blank', + title: token.url + } + }, token.title); + + case 'mention': + return (createElement as any)('a', { + attrs: { + href: `${url}/@${getAcct(token)}`, + target: '_blank', + dataIsMe: (this as any).i && getAcct((this as any).i) == getAcct(token) + }, + directives: [{ + name: 'user-preview', + value: token.content + }] + }, token.content); + + case 'hashtag': + return createElement('a', { + attrs: { + href: `${url}/search?q=${token.content}`, + target: '_blank' + } + }, token.content); + + case 'code': + return createElement('pre', { + class: 'code' + }, [ + createElement('code', { + domProps: { + innerHTML: token.html + } + }) + ]); + + case 'inline-code': + return createElement('code', { + domProps: { + innerHTML: token.html + } + }); + + case 'quote': + const text2 = token.quote.replace(/(\r\n|\n|\r)/g, '\n'); + + if (this.shouldBreak) { + const x = text2.split('\n') + .map(t => [createElement('span', t), createElement('br')]); + x[x.length - 1].pop(); + return createElement('div', { + attrs: { + class: 'quote' + } + }, x); + } else { + return createElement('span', { + attrs: { + class: 'quote' + } + }, text2.replace(/\n/g, ' ')); + } + + case 'title': + return createElement('div', { + attrs: { + class: 'title' + } + }, token.title); + + case 'emoji': + const emoji = emojilib.lib[token.emoji]; + return createElement('span', emoji ? emoji.char : token.content); + + case 'search': + return createElement(MkGoogle, { + props: { + q: token.query + } + }); + + default: + console.log('unknown ast type:', token.type); + } + })); + + const _els = []; + els.forEach((el, i) => { + if (el.tag == 'br') { + if (!['div', 'pre'].includes(els[i - 1].tag)) { + _els.push(el); + } + } else { + _els.push(el); + } + }); + + return createElement('span', _els); + } +}); diff --git a/src/client/app/common/views/components/note-menu.vue b/src/client/app/common/views/components/note-menu.vue new file mode 100644 index 000000000..88dc22aaf --- /dev/null +++ b/src/client/app/common/views/components/note-menu.vue @@ -0,0 +1,165 @@ + + + + + diff --git a/src/client/app/common/views/components/othello.game.vue b/src/client/app/common/views/components/othello.game.vue new file mode 100644 index 000000000..8c646cce0 --- /dev/null +++ b/src/client/app/common/views/components/othello.game.vue @@ -0,0 +1,324 @@ + + + + + diff --git a/src/client/app/common/views/components/othello.gameroom.vue b/src/client/app/common/views/components/othello.gameroom.vue new file mode 100644 index 000000000..dba9ccd16 --- /dev/null +++ b/src/client/app/common/views/components/othello.gameroom.vue @@ -0,0 +1,42 @@ + + + diff --git a/src/client/app/common/views/components/othello.room.vue b/src/client/app/common/views/components/othello.room.vue new file mode 100644 index 000000000..86368b3cc --- /dev/null +++ b/src/client/app/common/views/components/othello.room.vue @@ -0,0 +1,297 @@ + + + + + + + + + diff --git a/src/client/app/common/views/components/othello.vue b/src/client/app/common/views/components/othello.vue new file mode 100644 index 000000000..8f7d9dfd6 --- /dev/null +++ b/src/client/app/common/views/components/othello.vue @@ -0,0 +1,311 @@ + + + + + diff --git a/src/client/app/common/views/components/poll-editor.vue b/src/client/app/common/views/components/poll-editor.vue new file mode 100644 index 000000000..95bcba996 --- /dev/null +++ b/src/client/app/common/views/components/poll-editor.vue @@ -0,0 +1,150 @@ + + + + + diff --git a/src/client/app/common/views/components/poll.vue b/src/client/app/common/views/components/poll.vue new file mode 100644 index 000000000..46e41cbcd --- /dev/null +++ b/src/client/app/common/views/components/poll.vue @@ -0,0 +1,133 @@ + + + + + diff --git a/src/client/app/common/views/components/reaction-icon.vue b/src/client/app/common/views/components/reaction-icon.vue new file mode 100644 index 000000000..7d24f4f9e --- /dev/null +++ b/src/client/app/common/views/components/reaction-icon.vue @@ -0,0 +1,28 @@ + + + + + diff --git a/src/client/app/common/views/components/reaction-picker.vue b/src/client/app/common/views/components/reaction-picker.vue new file mode 100644 index 000000000..e2c8a6ed3 --- /dev/null +++ b/src/client/app/common/views/components/reaction-picker.vue @@ -0,0 +1,198 @@ + + + + + diff --git a/src/client/app/common/views/components/reactions-viewer.vue b/src/client/app/common/views/components/reactions-viewer.vue new file mode 100644 index 000000000..97cb6be17 --- /dev/null +++ b/src/client/app/common/views/components/reactions-viewer.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/src/client/app/common/views/components/signin.vue b/src/client/app/common/views/components/signin.vue new file mode 100644 index 000000000..7fb9fc3fd --- /dev/null +++ b/src/client/app/common/views/components/signin.vue @@ -0,0 +1,142 @@ + + + + + diff --git a/src/client/app/common/views/components/signup.vue b/src/client/app/common/views/components/signup.vue new file mode 100644 index 000000000..516979acd --- /dev/null +++ b/src/client/app/common/views/components/signup.vue @@ -0,0 +1,287 @@ + + + + + diff --git a/src/client/app/common/views/components/special-message.vue b/src/client/app/common/views/components/special-message.vue new file mode 100644 index 000000000..deac757c5 --- /dev/null +++ b/src/client/app/common/views/components/special-message.vue @@ -0,0 +1,42 @@ + + + + + diff --git a/src/client/app/common/views/components/stream-indicator.vue b/src/client/app/common/views/components/stream-indicator.vue new file mode 100644 index 000000000..d573db32e --- /dev/null +++ b/src/client/app/common/views/components/stream-indicator.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/src/client/app/common/views/components/switch.vue b/src/client/app/common/views/components/switch.vue new file mode 100644 index 000000000..32caab638 --- /dev/null +++ b/src/client/app/common/views/components/switch.vue @@ -0,0 +1,199 @@ + + + + + diff --git a/src/client/app/common/views/components/time.vue b/src/client/app/common/views/components/time.vue new file mode 100644 index 000000000..533958697 --- /dev/null +++ b/src/client/app/common/views/components/time.vue @@ -0,0 +1,76 @@ + + + diff --git a/src/client/app/common/views/components/timer.vue b/src/client/app/common/views/components/timer.vue new file mode 100644 index 000000000..a3c4f01b7 --- /dev/null +++ b/src/client/app/common/views/components/timer.vue @@ -0,0 +1,49 @@ + + + diff --git a/src/client/app/common/views/components/twitter-setting.vue b/src/client/app/common/views/components/twitter-setting.vue new file mode 100644 index 000000000..ab07e6d09 --- /dev/null +++ b/src/client/app/common/views/components/twitter-setting.vue @@ -0,0 +1,64 @@ + + + + + diff --git a/src/client/app/common/views/components/uploader.vue b/src/client/app/common/views/components/uploader.vue new file mode 100644 index 000000000..a6caa80f3 --- /dev/null +++ b/src/client/app/common/views/components/uploader.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/src/client/app/common/views/components/url-preview.vue b/src/client/app/common/views/components/url-preview.vue new file mode 100644 index 000000000..c2dc07b41 --- /dev/null +++ b/src/client/app/common/views/components/url-preview.vue @@ -0,0 +1,149 @@ +