Compare commits

..

35 Commits

Author SHA1 Message Date
syuilo
d779e18546 10.45.0 2018-11-08 02:10:36 +09:00
syuilo
3261d54cd3 Resolve #2320 2018-11-08 02:09:15 +09:00
syuilo
e0ec56abb5 Fix bug 2018-11-08 01:42:02 +09:00
syuilo
1056a7167d [Client] Improve usabiliy 2018-11-07 23:04:59 +09:00
syuilo
b8e1162e2d Fix test 2018-11-07 21:30:28 +09:00
syuilo
4c81e400c4 [MFM] Fix title parsing 2018-11-07 21:17:27 +09:00
syuilo
a29d7a0475 10.44.2 2018-11-07 21:14:16 +09:00
syuilo
d5408c429b Fix bug 2018-11-07 20:59:40 +09:00
syuilo
501b07c383 [Test] Add MFM test 2018-11-07 19:58:05 +09:00
syuilo
9dd21a19ff 10.44.1 2018-11-07 19:49:46 +09:00
syuilo
a8d05cba5a Fix #3149 2018-11-07 19:43:21 +09:00
syuilo
f5ddfb29f2 10.44.0 2018-11-07 13:16:29 +09:00
syuilo
ba228a6b10 Clean up 2018-11-07 13:15:09 +09:00
syuilo
cb6f390fb6 GitHub / Twitter連携の設定をDBに保存するように 2018-11-07 13:14:52 +09:00
syuilo
5675ecead9 Fix 2018-11-07 12:30:56 +09:00
syuilo
001bb7bbcd インスタンスの対象言語の設定を実装 2018-11-07 12:28:53 +09:00
syuilo
1585bb12cf 🎨 2018-11-07 12:17:57 +09:00
syuilo
26b47c18fd [Client] Fix #2737 2018-11-07 12:15:28 +09:00
syuilo
665fa7f2aa [API] Improve drive/files/upload_from_url 2018-11-07 12:12:43 +09:00
syuilo
0068dc30d3 Merge branch 'develop' of https://github.com/syuilo/misskey into develop 2018-11-07 12:09:33 +09:00
syuilo
8f39655fef Fix bug 2018-11-07 12:09:24 +09:00
dependabot[bot]
b1a4fc03bc Update @types/koa-router requirement from 7.0.32 to 7.0.33 (#3147)
Updates the requirements on [@types/koa-router](https://github.com/DefinitelyTyped/DefinitelyTyped) to permit the latest version.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-07 09:24:13 +09:00
dependabot[bot]
05d20f1044 Update @types/request requirement from 2.48.0 to 2.48.1 (#3146)
Updates the requirements on [@types/request](https://github.com/DefinitelyTyped/DefinitelyTyped) to permit the latest version.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-07 09:24:04 +09:00
dependabot[bot]
66a90b3fb1 Update qrcode requirement from 1.3.0 to 1.3.2 (#3145)
Updates the requirements on [qrcode](https://github.com/soldair/node-qrcode) to permit the latest version.
- [Release notes](https://github.com/soldair/node-qrcode/releases)
- [Commits](https://github.com/soldair/node-qrcode/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-07 09:23:47 +09:00
dependabot[bot]
826d9d9fdf Update typescript requirement from 3.1.5 to 3.1.6 (#3144)
Updates the requirements on [typescript](https://github.com/Microsoft/TypeScript) to permit the latest version.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/commits/v3.1.6)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-07 09:23:38 +09:00
syuilo
4a9a61f108 10.43.1 2018-11-07 03:57:08 +09:00
syuilo
b72d15b56c [Client] Improve usability 2018-11-07 03:48:58 +09:00
Acid Chicken (硫酸鶏)
8c68992594 Fix deploy fails on CircleCI 2018-11-07 02:06:32 +09:00
syuilo
c052028fc3 10.43.0 2018-11-07 01:19:03 +09:00
syuilo
c46fbcf345 Clean up 2018-11-07 01:18:21 +09:00
syuilo
06b66f0209 メンテナ情報をDBに保存するように 2018-11-07 01:12:26 +09:00
syuilo
2de48110bb ghostの設定をDBに保存するように 2018-11-07 00:44:56 +09:00
syuilo
87d4452d19 Clean up 2018-11-07 00:16:32 +09:00
syuilo
328fc64ca9 🎨 2018-11-07 00:16:08 +09:00
syuilo
a6f8327aa2 reCAPTCHAの設定をDBに保存するように 2018-11-07 00:08:21 +09:00
40 changed files with 965 additions and 626 deletions

View File

@@ -102,7 +102,7 @@ jobs:
- run:
name: Build
command: |
docker build . | tee docker.log
docker build -t misskey/misskey .
- when:
condition: <<parameters.with_deploy>>
steps:
@@ -111,8 +111,6 @@ jobs:
command: |
if [ "$DOCKERHUB_USERNAME$DOCKERHUB_PASSWORD" ]
then
tail -n 1 docker.log | read __Successfully __built tag
docker tag $tag misskey/misskey
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
docker push misskey/misskey
else

View File

@@ -1,6 +1,3 @@
maintainer:
name: syuilo
url: 'https://syuilo.com'
url: 'http://misskey.local'
port: 80
mongodb:

View File

@@ -1,6 +1,3 @@
maintainer:
name: syuilo
url: 'https://syuilo.com'
url: 'http://misskey.local'
port: 80
mongodb:

View File

@@ -1,10 +1,3 @@
maintainer:
name: example-maitainer-name # Your name
url: http://example.com/ # Your contact (http or mailto)
repository_url: https://github.com/syuilo/misskey # Repository URL
feedback_url: https://github.com/syuilo/misskey/issues # Feedback URL (e.g. github issue)
# Final accessible URL seen by a user.
url: https://example.tld/
@@ -115,11 +108,6 @@ autoAdmin: true
# port: 9200
# pass: null
# reCAPTCHA
#recaptcha:
# site_key: example-site-key
# secret_key: example-secret-key
# ServiceWorker
#sw:
# # Public key of VAPID
@@ -128,23 +116,6 @@ autoAdmin: true
# # Private key of VAPID
# private_key: example-sw-private-key
# Twitter integration
# You need to set the oauth callback url as : https://<your-misskey-instance>/api/tw/cb
#twitter:
# consumer_key: example-twitter-consumer-key
# consumer_secret: example-twitter-consumer-secret-key
# GitHub integration
# You need to set the oauth callback url as : https://<your-misskey-instance>/api/gh/cb
#github:
# client_id: example-github-client-id
# client_secret: example-github-client-secret
# Ghost
# Ghost account is an account used for the purpose of delegating
# followers when putting users in the list.
#ghost: user-id-of-your-ghost-account
# Clustering
#clusterLimit: 1

View File

@@ -47,11 +47,6 @@ In root :
4. `git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)` Checkout to the [latest release](https://github.com/syuilo/misskey/releases/latest)
5. `npm install` Install misskey dependencies.
*(optional)* reCAPTCHA tokens
----------------------------------------------------------------
If you want to enable reCAPTCHA, you need to generate reCAPTCHA tokens:
Please visit https://www.google.com/recaptcha/intro/ and generate keys.
*(optional)* Generating VAPID keys
----------------------------------------------------------------
If you want to enable ServiceWorker, you need to generate VAPID keys:
@@ -62,13 +57,6 @@ npm install web-push -g
web-push generate-vapid-keys
```
*(optional)* Create a twitter application
----------------------------------------------------------------
If you want to enable the twitter integration, you need to create a twitter app at [https://developer.twitter.com/en/apply/user](https://developer.twitter.com/en/apply/user).
In the app you need to set the oauth callback url as : https://misskey-instance/api/tw/cb
*5.* Make configuration file
----------------------------------------------------------------
1. `cp .config/example.yml .config/default.yml` Copy the `.config/example.yml` and rename it to `default.yml`.

View File

@@ -53,11 +53,6 @@ adduser --disabled-password --disabled-login misskey
4. `git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)` [最新のリリース](https://github.com/syuilo/misskey/releases/latest)を確認
5. `npm install` Misskeyの依存パッケージをインストール
*(オプション)* reCAPTCHAトークン
----------------------------------------------------------------
reCAPTCHAを有効にする場合、reCAPTCHAトークンを取得する必要があります。
https://www.google.com/recaptcha/intro/ にアクセスしてトークンを取得してください。
*(オプション)* VAPIDキーペアの生成
----------------------------------------------------------------
ServiceWorkerを有効にする場合、VAPIDキーペアを生成する必要があります:

View File

@@ -1079,12 +1079,37 @@ admin/views/instance.vue:
instance-name: "インスタンス名"
instance-description: "インスタンスの紹介"
banner-url: "バナー画像URL"
languages: "インスタンスの対象言語"
languages-desc: "スペースで区切って複数設定できます。"
maintainer-config: "管理者情報"
maintainer-name: "管理者名"
maintainer-email: "管理者の連絡先"
drive-config: "ドライブの設定"
cache-remote-files: "リモートのファイルをキャッシュする"
cache-remote-files-desc: "この設定を無効にすると、リモートファイルをキャッシュせず直リンクするようになります。そのためサーバーのストレージを節約できますが、プライバシー設定で直リンクを無効にしているユーザーにはファイルが見えなくなったり、サムネイルが生成されないので通信量が増加します。通常はこの設定をオンにしておくことをおすすめします。"
local-drive-capacity-mb: "ローカルユーザーひとりあたりのドライブ容量"
remote-drive-capacity-mb: "リモートユーザーひとりあたりのドライブ容量"
mb: "メガバイト単位"
recaptcha-config: "reCAPTCHAの設定"
recaptcha-info: "reCAPTCHAを有効にする場合、reCAPTCHAトークンを取得する必要があります。https://www.google.com/recaptcha/intro/ にアクセスしてトークンを取得してください。"
enable-recaptcha: "reCAPTCHAを有効にする"
recaptcha-site-key: "reCAPTCHA site key"
recaptcha-secret-key: "reCAPTCHA secret key"
twitter-integration-config: "Twitter連携の設定"
twitter-integration-info: "コールバックURLは /api/tw/cb に設定します。"
enable-twitter-integration: "Twitter連携を有効にする"
twitter-integration-consumer-key: "Consumer key"
twitter-integration-consumer-secret: "Consumer secret"
github-integration-config: "GitHub連携の設定"
github-integration-info: "コールバックURLは /api/gh/cb に設定します。"
enable-github-integration: "GitHub連携を有効にする"
github-integration-client-id: "Client ID"
github-integration-client-secret: "Client secret"
proxy-account-config: "プロキシアカウントの設定"
proxy-account-info: "プロキシアカウントは、特定の条件下でユーザーのリモートフォローを代行するアカウントです。例えば、ユーザーがリモートユーザーをリストに入れたとき、リストに入れられたユーザーを誰もフォローしていないとアクティビティがサーバーに配達されないため、代わりにプロキシアカウントがフォローするようにします。"
proxy-account-username: "プロキシアカウントのユーザー名"
proxy-account-username-desc: "プロキシとして使用するアカウントのユーザー名を指定してください。"
proxy-account-warn: "アカウントは自動で作られないため、そのユーザー名のアカウントを予め作成しておく必要があります。"
max-note-text-length: "投稿の最大文字数"
disable-registration: "ユーザー登録の受付を停止する"
disable-local-timeline: "ローカルタイムラインを無効にする"

View File

@@ -1,8 +1,8 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "10.42.2",
"clientVersion": "1.0.11604",
"version": "10.45.0",
"clientVersion": "1.0.11641",
"codename": "nighthike",
"main": "./built/index.js",
"private": true,
@@ -53,7 +53,7 @@
"@types/koa-logger": "3.1.1",
"@types/koa-mount": "3.0.1",
"@types/koa-multer": "1.0.0",
"@types/koa-router": "7.0.32",
"@types/koa-router": "7.0.33",
"@types/koa-send": "4.1.1",
"@types/koa-views": "2.0.3",
"@types/koa__cors": "2.2.3",
@@ -69,7 +69,7 @@
"@types/qrcode": "1.3.0",
"@types/ratelimiter": "2.1.28",
"@types/redis": "2.8.7",
"@types/request": "2.48.0",
"@types/request": "2.48.1",
"@types/request-promise-native": "1.0.15",
"@types/rimraf": "2.0.2",
"@types/seedrandom": "2.4.27",
@@ -174,7 +174,7 @@
"promise-sequential": "1.1.1",
"pug": "2.0.3",
"punycode": "2.1.1",
"qrcode": "1.3.0",
"qrcode": "1.3.2",
"ratelimiter": "3.2.0",
"recaptcha-promise": "0.1.3",
"reconnecting-websocket": "4.1.10",
@@ -205,7 +205,7 @@
"ts-loader": "5.3.0",
"ts-node": "7.0.1",
"tslint": "5.10.0",
"typescript": "3.1.5",
"typescript": "3.1.6",
"typescript-eslint-parser": "20.1.1",
"uglify-es": "3.3.9",
"url-loader": "1.1.2",

View File

@@ -6,6 +6,12 @@
<ui-input v-model="name">%i18n:@instance-name%</ui-input>
<ui-textarea v-model="description">%i18n:@instance-description%</ui-textarea>
<ui-input v-model="bannerUrl"><i slot="icon"><fa icon="link"/></i>%i18n:@banner-url%</ui-input>
<ui-input v-model="languages"><i slot="icon"><fa icon="language"/></i>%i18n:@languages%<span slot="desc">%i18n:@languages-desc%</span></ui-input>
</section>
<section class="fit-bottom">
<header><fa icon="headset"/> %i18n:@maintainer-config%</header>
<ui-input v-model="maintainerName">%i18n:@maintainer-name%</ui-input>
<ui-input v-model="maintainerEmail" type="email"><i slot="icon"><fa :icon="['far', 'envelope']"/></i>%i18n:@maintainer-email%</ui-input>
</section>
<section class="fit-top fit-bottom">
<ui-input v-model="maxNoteTextLength">%i18n:@max-note-text-length%</ui-input>
@@ -13,8 +19,27 @@
<section class="fit-bottom">
<header><fa icon="cloud"/> %i18n:@drive-config%</header>
<ui-switch v-model="cacheRemoteFiles">%i18n:@cache-remote-files%<span slot="desc">%i18n:@cache-remote-files-desc%</span></ui-switch>
<ui-input v-model="localDriveCapacityMb">%i18n:@local-drive-capacity-mb%<span slot="desc">%i18n:@mb%</span><span slot="suffix">MB</span></ui-input>
<ui-input v-model="remoteDriveCapacityMb" :disabled="!cacheRemoteFiles">%i18n:@remote-drive-capacity-mb%<span slot="desc">%i18n:@mb%</span><span slot="suffix">MB</span></ui-input>
<ui-input v-model="localDriveCapacityMb" type="number">%i18n:@local-drive-capacity-mb%<span slot="suffix">MB</span><span slot="desc">%i18n:@mb%</span></ui-input>
<ui-input v-model="remoteDriveCapacityMb" type="number" :disabled="!cacheRemoteFiles">%i18n:@remote-drive-capacity-mb%<span slot="suffix">MB</span><span slot="desc">%i18n:@mb%</span></ui-input>
</section>
<section class="fit-bottom">
<header><fa icon="shield-alt"/> %i18n:@recaptcha-config%</header>
<ui-switch v-model="enableRecaptcha">%i18n:@enable-recaptcha%</ui-switch>
<ui-info>%i18n:@recaptcha-info%</ui-info>
<ui-input v-model="recaptchaSiteKey" :disabled="!enableRecaptcha"><i slot="icon"><fa icon="key"/></i>%i18n:@recaptcha-site-key%</ui-input>
<ui-input v-model="recaptchaSecretKey" :disabled="!enableRecaptcha"><i slot="icon"><fa icon="key"/></i>%i18n:@recaptcha-secret-key%</ui-input>
</section>
<section>
<header><fa icon="ghost"/> %i18n:@proxy-account-config%</header>
<ui-info>%i18n:@proxy-account-info%</ui-info>
<ui-input v-model="proxyAccount"><span slot="prefix">@</span>%i18n:@proxy-account-username%<span slot="desc">%i18n:@proxy-account-username-desc%</span></ui-input>
<ui-info warn>%i18n:@proxy-account-warn%</ui-info>
</section>
<section>
<ui-switch v-model="disableRegistration">%i18n:@disable-registration%</ui-switch>
</section>
<section>
<ui-switch v-model="disableLocalTimeline">%i18n:@disable-local-timeline%</ui-switch>
</section>
<section>
<ui-button @click="updateMeta">%i18n:@save%</ui-button>
@@ -22,18 +47,32 @@
</ui-card>
<ui-card>
<div slot="title">%i18n:@disable-registration%</div>
<div slot="title">%i18n:@invite%</div>
<section>
<input type="checkbox" v-model="disableRegistration" @change="updateMeta">
<button class="ui" @click="invite">%i18n:@invite%</button>
<ui-button @click="invite">%i18n:@invite%</ui-button>
<p v-if="inviteCode">Code: <code>{{ inviteCode }}</code></p>
</section>
</ui-card>
<ui-card>
<div slot="title">%i18n:@disable-local-timeline%</div>
<div slot="title"><fa :icon="['fab', 'twitter']"/> %i18n:@twitter-integration-config%</div>
<section>
<input type="checkbox" v-model="disableLocalTimeline" @change="updateMeta">
<ui-switch v-model="enableTwitterIntegration">%i18n:@enable-twitter-integration%</ui-switch>
<ui-info>%i18n:@twitter-integration-info%</ui-info>
<ui-input v-model="twitterConsumerKey" :disabled="!enableTwitterIntegration"><i slot="icon"><fa icon="key"/></i>%i18n:@twitter-integration-consumer-key%</ui-input>
<ui-input v-model="twitterConsumerSecret" :disabled="!enableTwitterIntegration"><i slot="icon"><fa icon="key"/></i>%i18n:@twitter-integration-consumer-secret%</ui-input>
<ui-button @click="updateMeta">%i18n:@save%</ui-button>
</section>
</ui-card>
<ui-card>
<div slot="title"><fa :icon="['fab', 'github']"/> %i18n:@github-integration-config%</div>
<section>
<ui-switch v-model="enableGithubIntegration">%i18n:@enable-github-integration%</ui-switch>
<ui-info>%i18n:@github-integration-info%</ui-info>
<ui-input v-model="githubClientId" :disabled="!enableGithubIntegration"><i slot="icon"><fa icon="key"/></i>%i18n:@github-integration-client-id%</ui-input>
<ui-input v-model="githubClientSecret" :disabled="!enableGithubIntegration"><i slot="icon"><fa icon="key"/></i>%i18n:@github-integration-client-secret%</ui-input>
<ui-button @click="updateMeta">%i18n:@save%</ui-button>
</section>
</ui-card>
</div>
@@ -45,28 +84,54 @@ import Vue from "vue";
export default Vue.extend({
data() {
return {
maintainerName: null,
maintainerEmail: null,
disableRegistration: false,
disableLocalTimeline: false,
bannerUrl: null,
name: null,
description: null,
languages: null,
cacheRemoteFiles: false,
localDriveCapacityMb: null,
remoteDriveCapacityMb: null,
maxNoteTextLength: null,
enableRecaptcha: false,
recaptchaSiteKey: null,
recaptchaSecretKey: null,
enableTwitterIntegration: false,
twitterConsumerKey: null,
twitterConsumerSecret: null,
enableGithubIntegration: false,
githubClientId: null,
githubClientSecret: null,
proxyAccount: null,
inviteCode: null,
};
},
created() {
(this as any).os.getMeta().then(meta => {
this.maintainerName = meta.maintainer.name;
this.maintainerEmail = meta.maintainer.email;
this.bannerUrl = meta.bannerUrl;
this.name = meta.name;
this.description = meta.description;
this.languages = meta.langs.join(' ');
this.cacheRemoteFiles = meta.cacheRemoteFiles;
this.localDriveCapacityMb = meta.driveCapacityPerLocalUserMb;
this.remoteDriveCapacityMb = meta.driveCapacityPerRemoteUserMb;
this.maxNoteTextLength = meta.maxNoteTextLength;
this.enableRecaptcha = meta.enableRecaptcha;
this.recaptchaSiteKey = meta.recaptchaSiteKey;
this.recaptchaSecretKey = meta.recaptchaSecretKey;
this.proxyAccount = meta.proxyAccount;
this.enableTwitterIntegration = meta.enableTwitterIntegration;
this.twitterConsumerKey = meta.twitterConsumerKey;
this.twitterConsumerSecret = meta.twitterConsumerSecret;
this.enableGithubIntegration = meta.enableGithubIntegration;
this.githubClientId = meta.githubClientId;
this.githubClientSecret = meta.githubClientSecret;
});
},
@@ -84,15 +149,28 @@ export default Vue.extend({
updateMeta() {
(this as any).api('admin/update-meta', {
maintainerName: this.maintainerName,
maintainerEmail: this.maintainerEmail,
disableRegistration: this.disableRegistration,
disableLocalTimeline: this.disableLocalTimeline,
bannerUrl: this.bannerUrl,
name: this.name,
description: this.description,
langs: this.languages.split(' '),
cacheRemoteFiles: this.cacheRemoteFiles,
localDriveCapacityMb: parseInt(this.localDriveCapacityMb, 10),
remoteDriveCapacityMb: parseInt(this.remoteDriveCapacityMb, 10),
maxNoteTextLength: parseInt(this.maxNoteTextLength, 10)
maxNoteTextLength: parseInt(this.maxNoteTextLength, 10),
enableRecaptcha: this.enableRecaptcha,
recaptchaSiteKey: this.recaptchaSiteKey,
recaptchaSecretKey: this.recaptchaSecretKey,
proxyAccount: this.proxyAccount,
enableTwitterIntegration: this.enableTwitterIntegration,
twitterConsumerKey: this.twitterConsumerKey,
twitterConsumerSecret: this.twitterConsumerSecret,
enableGithubIntegration: this.enableGithubIntegration,
githubClientId: this.githubClientId,
githubClientSecret: this.githubClientSecret,
}).then(() => {
this.$swal({
type: 'success',

View File

@@ -1,5 +1,5 @@
<template>
<div class="mk-media-image-dialog">
<div class="dkjvrdxtkvqrwmhfickhndpmnncsgacq">
<div class="bg" @click="close"></div>
<img :src="image.url" :alt="image.name" :title="image.name" @click="close"/>
</div>
@@ -34,7 +34,7 @@ export default Vue.extend({
</script>
<style lang="stylus" scoped>
.mk-media-image-dialog
.dkjvrdxtkvqrwmhfickhndpmnncsgacq
display block
position fixed
z-index 2048

View File

@@ -179,6 +179,9 @@ export default Vue.extend({
font-size 10px
color var(--messagingRoomMessageInfo)
> .read
margin 0 8px
> [data-icon]
margin-left 4px

View File

@@ -4,7 +4,7 @@
<ui-input v-if="meta.disableRegistration" v-model="invitationCode" type="text" :autocomplete="Math.random()" spellcheck="false" required styl="fill">
<span>%i18n:@invitation-code%</span>
<span slot="prefix"><fa icon="id-card-alt"/></span>
<p slot="desc" v-html="'%i18n:@invitation-info%'.replace('{}', meta.maintainer.url)"></p>
<p slot="desc" v-html="'%i18n:@invitation-info%'.replace('{}', 'mailto:' + meta.maintainer.email)"></p>
</ui-input>
<ui-input v-model="username" type="text" pattern="^[a-zA-Z0-9_]{1,20}$" :autocomplete="Math.random()" spellcheck="false" required @input="onChangeUsername" styl="fill">
<span>%i18n:@username%</span>
@@ -35,7 +35,7 @@
<p v-if="passwordRetypeState == 'not-match'" style="color:#FF1161"><fa icon="exclamation-triangle" fixed-width/> %i18n:@password-not-matched%</p>
</div>
</ui-input>
<div v-if="meta.recaptchaSitekey != null" class="g-recaptcha" :data-sitekey="meta.recaptchaSitekey" style="margin: 16px 0;"></div>
<div v-if="meta.enableRecaptcha" class="g-recaptcha" :data-sitekey="meta.recaptchaSiteKey" style="margin: 16px 0;"></div>
<ui-button type="submit">%i18n:@create%</ui-button>
</template>
</form>
@@ -130,7 +130,7 @@ export default Vue.extend({
username: this.username,
password: this.password,
invitationCode: this.invitationCode,
'g-recaptcha-response': this.meta.recaptchaSitekey != null ? (window as any).grecaptcha.getResponse() : null
'g-recaptcha-response': this.meta.enableRecaptcha ? (window as any).grecaptcha.getResponse() : null
}, true).then(() => {
(this as any).api('signin', {
username: this.username,
@@ -141,7 +141,7 @@ export default Vue.extend({
}).catch(() => {
alert('%i18n:@some-error%');
if (this.meta.recaptchaSitekey != null) {
if (this.meta.enableRecaptcha) {
(window as any).grecaptcha.reset();
}
});

View File

@@ -5,7 +5,7 @@
<h1><fa icon="heart"/>%i18n:@title%</h1>
<p v-if="meta">
{{ '%i18n:@text%'.substr(0, '%i18n:@text%'.indexOf('{')) }}
<a :href="meta.maintainer.url">{{ meta.maintainer.name }}</a>
<a :href="'mailto:' + meta.maintainer.email">{{ meta.maintainer.name }}</a>
{{ '%i18n:@text%'.substr('%i18n:@text%'.indexOf('}') + 1) }}
</p>
</article>

View File

@@ -1,6 +1,6 @@
<template>
<div class="info">
<p>Maintainer: <b><a :href="meta.maintainer.url" target="_blank">{{ meta.maintainer.name }}</a></b></p>
<p>Maintainer: <b><a :href="'mailto:' + meta.maintainer.email" target="_blank">{{ meta.maintainer.name }}</a></b></p>
<p>Machine: {{ meta.machine }}</p>
<p>Node: {{ meta.node }}</p>
</div>

View File

@@ -359,7 +359,7 @@ export default Vue.extend({
}).then(name => {
(this as any).api('drive/folders/create', {
name: name,
folderId: this.folder ? this.folder.id : undefined
parentId: this.folder ? this.folder.id : undefined
}).then(folder => {
this.addFolder(folder, true);
});

View File

@@ -10,7 +10,6 @@ import window from './window.vue';
import noteFormWindow from './post-form-window.vue';
import renoteFormWindow from './renote-form-window.vue';
import mediaImage from './media-image.vue';
import mediaImageDialog from './media-image-dialog.vue';
import mediaVideo from './media-video.vue';
import notifications from './notifications.vue';
import noteForm from './post-form.vue';
@@ -39,7 +38,6 @@ Vue.component('mk-window', window);
Vue.component('mk-post-form-window', noteFormWindow);
Vue.component('mk-renote-form-window', renoteFormWindow);
Vue.component('mk-media-image', mediaImage);
Vue.component('mk-media-image-dialog', mediaImageDialog);
Vue.component('mk-media-video', mediaVideo);
Vue.component('mk-notifications', notifications);
Vue.component('mk-post-form', noteForm);

View File

@@ -17,7 +17,7 @@
<script lang="ts">
import Vue from 'vue';
import MkMediaImageDialog from './media-image-dialog.vue';
import ImageViewer from '../../../common/views/components/image-viewer.vue';
export default Vue.extend({
props: {
@@ -58,7 +58,7 @@ export default Vue.extend({
},
onClick() {
(this as any).os.new(MkMediaImageDialog, {
(this as any).os.new(ImageViewer, {
image: this.image
});
}

View File

@@ -247,7 +247,7 @@
<ui-card class="other" v-show="page == 'other'">
<div slot="title"><fa icon="info-circle"/> %i18n:@about%</div>
<section>
<p v-if="meta">%i18n:@operator%: <i><a :href="meta.maintainer.url" target="_blank">{{ meta.maintainer.name }}</a></i></p>
<p v-if="meta">%i18n:@operator%: <i><a :href="'mailto:' + meta.maintainer.email" target="_blank">{{ meta.maintainer.name }}</a></i></p>
</section>
</ui-card>

View File

@@ -87,7 +87,7 @@
<div>
<div v-if="meta" class="body">
<p>Version: <b>{{ meta.version }}</b></p>
<p>Maintainer: <b><a :href="meta.maintainer.url" target="_blank">{{ meta.maintainer.name }}</a></b></p>
<p>Maintainer: <b><a :href="'mailto:' + meta.maintainer.email" target="_blank">{{ meta.maintainer.name }}</a></b></p>
</div>
</div>
</div>

View File

@@ -5,11 +5,12 @@
<span>%i18n:@click-to-show%</span>
</div>
</div>
<a class="gqnyydlzavusgskkfvwvjiattxdzsqlf" v-else :href="image.url" target="_blank" :style="style" :title="image.name"></a>
<a class="gqnyydlzavusgskkfvwvjiattxdzsqlf" v-else :href="image.url" target="_blank" :style="style" :title="image.name" @click.prevent="onClick"></a>
</template>
<script lang="ts">
import Vue from 'vue';
import ImageViewer from '../../../common/views/components/image-viewer.vue';
export default Vue.extend({
props: {
@@ -41,6 +42,13 @@ export default Vue.extend({
'background-image': url
};
}
},
methods: {
onClick() {
(this as any).os.new(ImageViewer, {
image: this.image
});
}
}
});
</script>

View File

@@ -62,7 +62,7 @@
</article>
<div class="info" v-if="meta">
<p>Version: <b>{{ meta.version }}</b></p>
<p>Maintainer: <b><a :href="meta.maintainer.url" target="_blank">{{ meta.maintainer.name }}</a></b></p>
<p>Maintainer: <b><a :href="'mailto:' + meta.maintainer.email" target="_blank">{{ meta.maintainer.name }}</a></b></p>
</div>
<footer>
<small>{{ copyright }}</small>

View File

@@ -2,23 +2,8 @@
* ユーザーが設定する必要のある情報
*/
export type Source = {
/**
* メンテナ情報
*/
maintainer: {
/**
* メンテナの名前
*/
name: string;
/**
* メンテナの連絡先(URLかmailto形式のURL)
*/
url: string;
email?: string;
repository_url?: string;
feedback_url?: string;
};
languages?: string[];
repository_url?: string;
feedback_url?: string;
url: string;
port: number;
https?: { [x: string]: string };
@@ -40,11 +25,6 @@ export type Source = {
port: number;
pass: string;
};
recaptcha?: {
site_key: string;
secret_key: string;
};
drive?: {
storage: string;
bucket?: string;
@@ -55,24 +35,12 @@ export type Source = {
autoAdmin?: boolean;
/**
* ゴーストアカウントのID
*/
ghost?: string;
proxy?: string;
summalyProxy?: string;
accesslog?: string;
twitter?: {
consumer_key: string;
consumer_secret: string;
};
github?: {
client_id: string;
client_secret: string;
};
github_bot?: {
hook_secret: string;
username: string;

View File

@@ -11,10 +11,9 @@ export type TextElementTitle = {
export default function(text: string, isBegin: boolean) {
const match = isBegin ? text.match(/^(【|\[)(.+?)(】|])\n/) : text.match(/^\n(【|\[)(.+?)(】|])\n/);
if (!match) return null;
const title = match[0];
return {
type: 'title',
content: title,
title: title.substr(1, title.length - 3)
content: match[0],
title: match[2]
} as TextElementTitle;
}

View File

@@ -2,6 +2,8 @@ import Meta, { IMeta } from '../models/meta';
const defaultMeta: any = {
name: 'Misskey',
maintainer: {},
langs: [],
cacheRemoteFiles: true,
localDriveCapacityMb: 256,
remoteDriveCapacityMb: 8,
@@ -10,7 +12,9 @@ const defaultMeta: any = {
originalNotesCount: 0,
originalUsersCount: 0
},
maxNoteTextLength: 1000
maxNoteTextLength: 1000,
enableTwitterIntegration: false,
enableGithubIntegration: false,
};
export default async function(): Promise<IMeta> {

View File

@@ -1,5 +1,7 @@
import db from '../db/mongodb';
import config from '../config';
import User from './user';
import { transform } from '../misc/cafy-id';
const Meta = db.get<IMeta>('meta');
export default Meta;
@@ -61,17 +63,99 @@ if ((config as any).preventCacheRemoteFiles) {
}
});
}
if ((config as any).recaptcha) {
Meta.findOne({}).then(m => {
if (m != null && m.enableRecaptcha == null) {
Meta.update({}, {
$set: {
enableRecaptcha: (config as any).recaptcha != null,
recaptchaSiteKey: (config as any).recaptcha.site_key,
recaptchaSecretKey: (config as any).recaptcha.secret_key,
}
});
}
});
}
if ((config as any).ghost) {
Meta.findOne({}).then(async m => {
if (m != null && m.proxyAccount == null) {
const account = await User.findOne({ _id: transform((config as any).ghost) });
Meta.update({}, {
$set: {
proxyAccount: account.username
}
});
}
});
}
if ((config as any).maintainer) {
Meta.findOne({}).then(m => {
if (m != null && m.maintainer == null) {
Meta.update({}, {
$set: {
maintainer: (config as any).maintainer
}
});
}
});
}
if ((config as any).twitter) {
Meta.findOne({}).then(m => {
if (m != null && m.enableTwitterIntegration == null) {
Meta.update({}, {
$set: {
enableTwitterIntegration: true,
twitterConsumerKey: (config as any).twitter.consumer_key,
twitterConsumerSecret: (config as any).twitter.consumer_secret
}
});
}
});
}
if ((config as any).github) {
Meta.findOne({}).then(m => {
if (m != null && m.enableGithubIntegration == null) {
Meta.update({}, {
$set: {
enableGithubIntegration: true,
githubClientId: (config as any).github.client_id,
githubClientSecret: (config as any).github.client_secret
}
});
}
});
}
export type IMeta = {
name?: string;
description?: string;
/**
* メンテナ情報
*/
maintainer: {
/**
* メンテナの名前
*/
name: string;
/**
* メンテナの連絡先
*/
email?: string;
};
langs?: string[];
broadcasts?: any[];
stats?: {
notesCount: number;
originalNotesCount: number;
usersCount: number;
originalUsersCount: number;
};
disableRegistration?: boolean;
disableLocalTimeline?: boolean;
hidedTags?: string[];
@@ -79,6 +163,12 @@ export type IMeta = {
cacheRemoteFiles?: boolean;
proxyAccount?: string;
enableRecaptcha?: boolean;
recaptchaSiteKey?: string;
recaptchaSecretKey?: string;
/**
* Drive capacity of a local user (MB)
*/
@@ -93,4 +183,12 @@ export type IMeta = {
* Max allowed note text length in charactors
*/
maxNoteTextLength?: number;
enableTwitterIntegration?: boolean;
twitterConsumerKey?: string;
twitterConsumerSecret?: string;
enableGithubIntegration?: boolean;
githubClientId?: string;
githubClientSecret?: string;
};

View File

@@ -10,6 +10,7 @@ import Mute from './mute';
import { getFriendIds } from '../server/api/common/get-friends';
import config from '../config';
import FollowRequest from './follow-request';
import fetchMeta from '../misc/fetch-meta';
const User = db.get<IUser>('users');
@@ -376,6 +377,7 @@ function img(url) {
}
*/
export function getGhost(): Promise<ILocalUser> {
return User.findOne({ _id: new mongo.ObjectId(config.ghost) });
export async function fetchProxyAccount(): Promise<ILocalUser> {
const meta = await fetchMeta();
return await User.findOne({ username: meta.proxyAccount, host: null }) as ILocalUser;
}

View File

@@ -6,7 +6,7 @@ import config from './config';
if (config.sw) {
// アプリケーションの連絡先と、サーバーサイドの鍵ペアの情報を登録
push.setVapidDetails(
config.maintainer.url,
config.url,
config.sw.public_key,
config.sw.private_key);
}

View File

@@ -4,6 +4,7 @@ import uploadFromUrl from '../../../services/drive/upload-from-url';
import { IRemoteUser } from '../../../models/user';
import DriveFile, { IDriveFile } from '../../../models/drive-file';
import Resolver from '../resolver';
import fetchMeta from '../../../misc/fetch-meta';
const log = debug('misskey:activitypub');
@@ -24,7 +25,10 @@ export async function createImage(actor: IRemoteUser, value: any): Promise<IDriv
log(`Creating the Image: ${image.url}`);
let file = await uploadFromUrl(image.url, actor, null, image.url, image.sensitive);
const instance = await fetchMeta();
const cache = instance.cacheRemoteFiles;
let file = await uploadFromUrl(image.url, actor, null, image.url, image.sensitive, false, !cache);
if (file.metadata.isRemote) {
// URLが異なっている場合、同じ画像が以前に異なるURLで登録されていたということなので、

View File

@@ -88,7 +88,98 @@ export const meta = {
desc: {
'ja-JP': 'リモートのファイルをキャッシュするか否か'
}
}
},
enableRecaptcha: {
validator: $.bool.optional,
desc: {
'ja-JP': 'reCAPTCHAを使用するか否か'
}
},
recaptchaSiteKey: {
validator: $.str.optional.nullable,
desc: {
'ja-JP': 'reCAPTCHA site key'
}
},
recaptchaSecretKey: {
validator: $.str.optional.nullable,
desc: {
'ja-JP': 'reCAPTCHA secret key'
}
},
proxyAccount: {
validator: $.str.optional.nullable,
desc: {
'ja-JP': 'プロキシアカウントのユーザー名'
}
},
maintainerName: {
validator: $.str.optional,
desc: {
'ja-JP': 'インスタンスの管理者名'
}
},
maintainerEmail: {
validator: $.str.optional.nullable,
desc: {
'ja-JP': 'インスタンス管理者の連絡先メールアドレス'
}
},
langs: {
validator: $.arr($.str).optional,
desc: {
'ja-JP': 'インスタンスの対象言語'
}
},
enableTwitterIntegration: {
validator: $.bool.optional,
desc: {
'ja-JP': 'Twitter連携機能を有効にするか否か'
}
},
twitterConsumerKey: {
validator: $.str.optional.nullable,
desc: {
'ja-JP': 'TwitterアプリのConsumer key'
}
},
twitterConsumerSecret: {
validator: $.str.optional.nullable,
desc: {
'ja-JP': 'TwitterアプリのConsumer secret'
}
},
enableGithubIntegration: {
validator: $.bool.optional,
desc: {
'ja-JP': 'GitHub連携機能を有効にするか否か'
}
},
githubClientId: {
validator: $.str.optional.nullable,
desc: {
'ja-JP': 'GitHubアプリのClient ID'
}
},
githubClientSecret: {
validator: $.str.optional.nullable,
desc: {
'ja-JP': 'GitHubアプリのClient secret'
}
},
}
};
@@ -139,6 +230,58 @@ export default define(meta, (ps) => new Promise(async (res, rej) => {
set.cacheRemoteFiles = ps.cacheRemoteFiles;
}
if (ps.enableRecaptcha !== undefined) {
set.enableRecaptcha = ps.enableRecaptcha;
}
if (ps.recaptchaSiteKey !== undefined) {
set.recaptchaSiteKey = ps.recaptchaSiteKey;
}
if (ps.recaptchaSecretKey !== undefined) {
set.recaptchaSecretKey = ps.recaptchaSecretKey;
}
if (ps.proxyAccount !== undefined) {
set.proxyAccount = ps.proxyAccount;
}
if (ps.maintainerName !== undefined) {
set['maintainer.name'] = ps.maintainerName;
}
if (ps.maintainerEmail !== undefined) {
set['maintainer.email'] = ps.maintainerEmail;
}
if (ps.langs !== undefined) {
set.langs = ps.langs;
}
if (ps.enableTwitterIntegration !== undefined) {
set.enableTwitterIntegration = ps.enableTwitterIntegration;
}
if (ps.twitterConsumerKey !== undefined) {
set.twitterConsumerKey = ps.twitterConsumerKey;
}
if (ps.twitterConsumerSecret !== undefined) {
set.twitterConsumerSecret = ps.twitterConsumerSecret;
}
if (ps.enableGithubIntegration !== undefined) {
set.enableGithubIntegration = ps.enableGithubIntegration;
}
if (ps.githubClientId !== undefined) {
set.githubClientId = ps.githubClientId;
}
if (ps.githubClientSecret !== undefined) {
set.githubClientSecret = ps.githubClientSecret;
}
await Meta.update({}, {
$set: set
}, { upsert: true });

View File

@@ -11,7 +11,7 @@ export const meta = {
limit: {
duration: ms('1hour'),
max: 10
max: 60
},
requireCredential: true,
@@ -29,9 +29,26 @@ export const meta = {
default: null as any as any,
transform: transform
},
isSensitive: {
validator: $.bool.optional,
default: false,
desc: {
'ja-JP': 'このメディアが「閲覧注意」(NSFW)かどうか',
'en-US': 'Whether this media is NSFW'
}
},
force: {
validator: $.bool.optional,
default: false,
desc: {
'ja-JP': 'true にすると、同じハッシュを持つファイルが既にアップロードされていても強制的にファイルを作成します。',
}
}
}
};
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
res(pack(await uploadFromUrl(ps.url, user, ps.folderId)));
res(pack(await uploadFromUrl(ps.url, user, ps.folderId, null, ps.isSensitive, ps.force)));
}));

View File

@@ -35,14 +35,15 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
}
});
res({
maintainer: config.maintainer,
const response: any = {
maintainer: instance.maintainer,
version: pkg.version,
clientVersion: client.version,
name: instance.name,
description: instance.description,
langs: instance.langs,
secure: config.https != null,
machine: os.hostname(),
@@ -60,24 +61,40 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
driveCapacityPerLocalUserMb: instance.localDriveCapacityMb,
driveCapacityPerRemoteUserMb: instance.remoteDriveCapacityMb,
cacheRemoteFiles: instance.cacheRemoteFiles,
recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null,
enableRecaptcha: instance.enableRecaptcha,
recaptchaSiteKey: instance.recaptchaSiteKey,
swPublickey: config.sw ? config.sw.public_key : null,
hidedTags: (me && me.isAdmin) ? instance.hidedTags : undefined,
bannerUrl: instance.bannerUrl,
maxNoteTextLength: instance.maxNoteTextLength,
emojis: emojis,
};
features: ps.detail ? {
if (ps.detail) {
response.features = {
registration: !instance.disableRegistration,
localTimeLine: !instance.disableLocalTimeline,
elasticsearch: config.elasticsearch ? true : false,
recaptcha: config.recaptcha ? true : false,
recaptcha: instance.enableRecaptcha,
objectStorage: config.drive && config.drive.storage === 'minio',
twitter: config.twitter ? true : false,
github: config.github ? true : false,
twitter: instance.enableTwitterIntegration,
github: instance.enableGithubIntegration,
serviceWorker: config.sw ? true : false,
userRecommendation: config.user_recommendation ? config.user_recommendation : {}
} : undefined
});
};
}
if (me && me.isAdmin) {
response.hidedTags = instance.hidedTags;
response.recaptchaSecretKey = instance.recaptchaSecretKey;
response.proxyAccount = instance.proxyAccount;
response.enableTwitterIntegration = instance.enableTwitterIntegration;
response.twitterConsumerKey = instance.twitterConsumerKey;
response.twitterConsumerSecret = instance.twitterConsumerSecret;
response.enableGithubIntegration = instance.enableGithubIntegration;
response.githubClientId = instance.githubClientId;
response.githubClientSecret = instance.githubClientSecret;
}
res(response);
}));

View File

@@ -1,6 +1,6 @@
import $ from 'cafy'; import ID, { transform } from '../../../../../misc/cafy-id';
import UserList from '../../../../../models/user-list';
import User, { pack as packUser, isRemoteUser, getGhost } from '../../../../../models/user';
import User, { pack as packUser, isRemoteUser, fetchProxyAccount } from '../../../../../models/user';
import { publishUserListStream } from '../../../../../stream';
import ap from '../../../../../remote/activitypub/renderer';
import renderFollow from '../../../../../remote/activitypub/renderer/follow';
@@ -71,8 +71,8 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
// このインスタンス内にこのリモートユーザーをフォローしているユーザーがいなくても投稿を受け取るためにダミーのユーザーがフォローしたということにする
if (isRemoteUser(user)) {
const ghost = await getGhost();
const content = ap(renderFollow(ghost, user));
deliver(ghost, content, user.inbox);
const proxy = await fetchProxyAccount();
const content = ap(renderFollow(proxy, user));
deliver(proxy, content, user.inbox);
}
}));

View File

@@ -44,6 +44,7 @@ router.post('/signup', require('./private/signup').default);
router.post('/signin', require('./private/signin').default);
router.use(require('./service/github').routes());
router.use(require('./service/github-bot').routes());
router.use(require('./service/twitter').routes());
router.use(require('./mastodon').routes());

View File

@@ -48,7 +48,7 @@ router.get('/v1/instance', async ctx => { // TODO: This is a temporary implement
uri: config.hostname,
title: meta.name || 'Misskey',
description: meta.description || '',
email: config.maintainer.email || config.maintainer.url.startsWith('mailto:') ? config.maintainer.url.slice(7) : '',
email: meta.maintainer.email,
version: `0.0.0:compatible:misskey:${pkg.version}`, // TODO: How to tell about that this is an api for compatibility?
thumbnail: meta.bannerUrl,
/*
@@ -60,7 +60,7 @@ router.get('/v1/instance', async ctx => { // TODO: This is a temporary implement
status_count: originalNotesCount,
domain_count: domains.length
},
languages: config.languages || [ 'ja' ],
languages: meta.langs || [ 'ja' ],
contact_account: {
id: maintainer._id,
username: maintainer.username,

View File

@@ -1,7 +1,6 @@
import * as Koa from 'koa';
import * as bcrypt from 'bcryptjs';
import { generate as generateKeypair } from '../../../crypto_key';
const recaptcha = require('recaptcha-promise');
import User, { IUser, validateUsername, validatePassword, pack } from '../../../models/user';
import generateUserToken from '../common/generate-native-user-token';
import config from '../../../config';
@@ -10,18 +9,20 @@ import RegistrationTicket from '../../../models/registration-tickets';
import usersChart from '../../../chart/users';
import fetchMeta from '../../../misc/fetch-meta';
if (config.recaptcha) {
recaptcha.init({
secret_key: config.recaptcha.secret_key
});
}
export default async (ctx: Koa.Context) => {
const body = ctx.request.body as any;
const instance = await fetchMeta();
const recaptcha = require('recaptcha-promise');
// Verify recaptcha
// ただしテスト時はこの機構は障害となるため無効にする
if (process.env.NODE_ENV !== 'test' && config.recaptcha != null) {
if (process.env.NODE_ENV !== 'test' && instance.enableRecaptcha) {
recaptcha.init({
secret_key: instance.recaptchaSecretKey
});
const success = await recaptcha(body['g-recaptcha-response']);
if (!success) {
@@ -34,8 +35,6 @@ export default async (ctx: Koa.Context) => {
const password = body['password'];
const invitationCode = body['invitationCode'];
const instance = await fetchMeta();
if (instance && instance.disableRegistration) {
if (invitationCode == null || typeof invitationCode != 'string') {
ctx.status = 400;

View File

@@ -0,0 +1,156 @@
import * as EventEmitter from 'events';
import * as Router from 'koa-router';
import * as request from 'request';
import User, { IUser } from '../../../models/user';
import createNote from '../../../services/note/create';
import config from '../../../config';
const crypto = require('crypto');
const handler = new EventEmitter();
let bot: IUser;
const post = async (text: string, home = true) => {
if (bot == null) {
const account = await User.findOne({
usernameLower: config.github_bot.username.toLowerCase()
});
if (account == null) {
console.warn(`GitHub hook bot specified, but not found: @${config.github_bot.username}`);
return;
} else {
bot = account;
}
}
createNote(bot, { text, visibility: home ? 'home' : 'public' });
};
// Init router
const router = new Router();
if (config.github_bot) {
const secret = config.github_bot.hook_secret;
router.post('/hooks/github', ctx => {
const body = JSON.stringify(ctx.request.body);
const hash = crypto.createHmac('sha1', secret).update(body).digest('hex');
const sig1 = new Buffer(ctx.headers['x-hub-signature']);
const sig2 = new Buffer(`sha1=${hash}`);
// シグネチャ比較
if (sig1.equals(sig2)) {
handler.emit(ctx.headers['x-github-event'], ctx.request.body);
ctx.status = 204;
} else {
ctx.status = 400;
}
});
}
module.exports = router;
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`,
proxy: config.proxy,
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: any[] = 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}** (((⭐️)))`, false);
});
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);
});

View File

@@ -1,37 +1,14 @@
import * as EventEmitter from 'events';
import * as Koa from 'koa';
import * as Router from 'koa-router';
import * as request from 'request';
import { OAuth2 } from 'oauth';
import User, { IUser, pack, ILocalUser } from '../../../models/user';
import createNote from '../../../services/note/create';
import User, { pack, ILocalUser } from '../../../models/user';
import config from '../../../config';
import { publishMainStream } from '../../../stream';
import redis from '../../../db/redis';
import uuid = require('uuid');
import signin from '../common/signin';
const crypto = require('crypto');
const handler = new EventEmitter();
let bot: IUser;
const post = async (text: string, home = true) => {
if (bot == null) {
const account = await User.findOne({
usernameLower: config.github_bot.username.toLowerCase()
});
if (account == null) {
console.warn(`GitHub hook bot specified, but not found: @${config.github_bot.username}`);
return;
} else {
bot = account;
}
}
createNote(bot, { text, visibility: home ? 'home' : 'public' });
};
import fetchMeta from '../../../misc/fetch-meta';
function getUserToken(ctx: Koa.Context) {
return ((ctx.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1];
@@ -80,337 +57,218 @@ router.get('/disconnect/github', async ctx => {
}));
});
if (!config.github || !redis) {
router.get('/connect/github', ctx => {
ctx.body = '現在GitHubへ接続できません (このインスタンスではGitHubはサポートされていません)';
async function getOath2() {
const meta = await fetchMeta();
if (meta.enableGithubIntegration) {
return new OAuth2(
meta.githubClientId,
meta.githubClientSecret,
'https://github.com/',
'login/oauth/authorize',
'login/oauth/access_token');
} else {
return null;
}
}
router.get('/connect/github', async ctx => {
if (!compareOrigin(ctx)) {
ctx.throw(400, 'invalid origin');
return;
}
const userToken = getUserToken(ctx);
if (!userToken) {
ctx.throw(400, 'signin required');
return;
}
const params = {
redirect_uri: `${config.url}/api/gh/cb`,
scope: ['read:user'],
state: uuid()
};
redis.set(userToken, JSON.stringify(params));
const oauth2 = await getOath2();
ctx.redirect(oauth2.getAuthorizeUrl(params));
});
router.get('/signin/github', async ctx => {
const sessid = uuid();
const params = {
redirect_uri: `${config.url}/api/gh/cb`,
scope: ['read:user'],
state: uuid()
};
const expires = 1000 * 60 * 60; // 1h
ctx.cookies.set('signin_with_github_session_id', sessid, {
path: '/',
domain: config.host,
secure: config.url.startsWith('https'),
httpOnly: true,
expires: new Date(Date.now() + expires),
maxAge: expires
});
router.get('/signin/github', ctx => {
ctx.body = '現在GitHubへ接続できません (このインスタンスではGitHubはサポートされていません)';
});
} else {
const oauth2 = new OAuth2(
config.github.client_id,
config.github.client_secret,
'https://github.com/',
'login/oauth/authorize',
'login/oauth/access_token');
redis.set(sessid, JSON.stringify(params));
router.get('/connect/github', async ctx => {
if (!compareOrigin(ctx)) {
ctx.throw(400, 'invalid origin');
const oauth2 = await getOath2();
ctx.redirect(oauth2.getAuthorizeUrl(params));
});
router.get('/gh/cb', async ctx => {
const userToken = getUserToken(ctx);
const oauth2 = await getOath2();
if (!userToken) {
const sessid = ctx.cookies.get('signin_with_github_session_id');
if (!sessid) {
ctx.throw(400, 'invalid session');
return;
}
const userToken = getUserToken(ctx);
if (!userToken) {
ctx.throw(400, 'signin required');
const code = ctx.query.code;
if (!code) {
ctx.throw(400, 'invalid session');
return;
}
const params = {
redirect_uri: `${config.url}/api/gh/cb`,
scope: ['read:user'],
state: uuid()
};
redis.set(userToken, JSON.stringify(params));
ctx.redirect(oauth2.getAuthorizeUrl(params));
});
router.get('/signin/github', async ctx => {
const sessid = uuid();
const params = {
redirect_uri: `${config.url}/api/gh/cb`,
scope: ['read:user'],
state: uuid()
};
const expires = 1000 * 60 * 60; // 1h
ctx.cookies.set('signin_with_github_session_id', sessid, {
path: '/',
domain: config.host,
secure: config.url.startsWith('https'),
httpOnly: true,
expires: new Date(Date.now() + expires),
maxAge: expires
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
redis.get(sessid, async (_, state) => {
res(JSON.parse(state));
});
});
redis.set(sessid, JSON.stringify(params));
ctx.redirect(oauth2.getAuthorizeUrl(params));
});
if (ctx.query.state !== state) {
ctx.throw(400, 'invalid session');
return;
}
router.get('/gh/cb', async ctx => {
const userToken = getUserToken(ctx);
if (!userToken) {
const sessid = ctx.cookies.get('signin_with_github_session_id');
if (!sessid) {
ctx.throw(400, 'invalid session');
return;
}
const code = ctx.query.code;
if (!code) {
ctx.throw(400, 'invalid session');
return;
}
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
redis.get(sessid, async (_, state) => {
res(JSON.parse(state));
});
});
if (ctx.query.state !== state) {
ctx.throw(400, 'invalid session');
return;
}
const { accessToken } = await new Promise<any>((res, rej) =>
oauth2.getOAuthAccessToken(
code,
{ redirect_uri },
(err, accessToken, refresh, result) => {
if (err)
rej(err);
else if (result.error)
rej(result.error);
else
res({ accessToken });
}));
const { login, id } = await new Promise<any>((res, rej) =>
request({
url: 'https://api.github.com/user',
headers: {
'Accept': 'application/vnd.github.v3+json',
'Authorization': `bearer ${accessToken}`,
'User-Agent': config.user_agent
}
}, (err, response, body) => {
const { accessToken } = await new Promise<any>((res, rej) =>
oauth2.getOAuthAccessToken(
code,
{ redirect_uri },
(err, accessToken, refresh, result) => {
if (err)
rej(err);
else if (result.error)
rej(result.error);
else
res(JSON.parse(body));
res({ accessToken });
}));
if (!login || !id) {
ctx.throw(400, 'invalid session');
return;
}
const user = await User.findOne({
host: null,
'github.id': id
}) as ILocalUser;
if (!user) {
ctx.throw(404, `@${login}と連携しているMisskeyアカウントはありませんでした...`);
return;
}
signin(ctx, user, true);
} else {
const code = ctx.query.code;
if (!code) {
ctx.throw(400, 'invalid session');
return;
}
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
redis.get(userToken, async (_, state) => {
res(JSON.parse(state));
});
});
if (ctx.query.state !== state) {
ctx.throw(400, 'invalid session');
return;
}
const { accessToken } = await new Promise<any>((res, rej) =>
oauth2.getOAuthAccessToken(
code,
{ redirect_uri },
(err, accessToken, refresh, result) => {
if (err)
rej(err);
else if (result.error)
rej(result.error);
else
res({ accessToken });
}));
const { login, id } = await new Promise<any>((res, rej) =>
request({
url: 'https://api.github.com/user',
headers: {
'Accept': 'application/vnd.github.v3+json',
'Authorization': `bearer ${accessToken}`,
'User-Agent': config.user_agent
}
}, (err, response, body) => {
if (err)
rej(err);
else
res(JSON.parse(body));
}));
if (!login || !id) {
ctx.throw(400, 'invalid session');
return;
}
const user = await User.findOneAndUpdate({
host: null,
token: userToken
}, {
$set: {
github: {
accessToken,
id,
login
}
const { login, id } = await new Promise<any>((res, rej) =>
request({
url: 'https://api.github.com/user',
headers: {
'Accept': 'application/vnd.github.v3+json',
'Authorization': `bearer ${accessToken}`,
'User-Agent': config.user_agent
}
});
ctx.body = `GitHub: @${login} を、Misskey: @${user.username} に接続しました!`;
// Publish i updated event
publishMainStream(user._id, 'meUpdated', await pack(user, user, {
detail: true,
includeSecrets: true
}, (err, response, body) => {
if (err)
rej(err);
else
res(JSON.parse(body));
}));
if (!login || !id) {
ctx.throw(400, 'invalid session');
return;
}
});
}
if (config.github_bot) {
const secret = config.github_bot.hook_secret;
const user = await User.findOne({
host: null,
'github.id': id
}) as ILocalUser;
router.post('/hooks/github', ctx => {
const body = JSON.stringify(ctx.request.body);
const hash = crypto.createHmac('sha1', secret).update(body).digest('hex');
const sig1 = new Buffer(ctx.headers['x-hub-signature']);
const sig2 = new Buffer(`sha1=${hash}`);
// シグネチャ比較
if (sig1.equals(sig2)) {
handler.emit(ctx.headers['x-github-event'], ctx.request.body);
ctx.status = 204;
} else {
ctx.status = 400;
if (!user) {
ctx.throw(404, `@${login}と連携しているMisskeyアカウントはありませんでした...`);
return;
}
});
}
signin(ctx, user, true);
} else {
const code = ctx.query.code;
if (!code) {
ctx.throw(400, 'invalid session');
return;
}
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
redis.get(userToken, async (_, state) => {
res(JSON.parse(state));
});
});
if (ctx.query.state !== state) {
ctx.throw(400, 'invalid session');
return;
}
const { accessToken } = await new Promise<any>((res, rej) =>
oauth2.getOAuthAccessToken(
code,
{ redirect_uri },
(err, accessToken, refresh, result) => {
if (err)
rej(err);
else if (result.error)
rej(result.error);
else
res({ accessToken });
}));
const { login, id } = await new Promise<any>((res, rej) =>
request({
url: 'https://api.github.com/user',
headers: {
'Accept': 'application/vnd.github.v3+json',
'Authorization': `bearer ${accessToken}`,
'User-Agent': config.user_agent
}
}, (err, response, body) => {
if (err)
rej(err);
else
res(JSON.parse(body));
}));
if (!login || !id) {
ctx.throw(400, 'invalid session');
return;
}
const user = await User.findOneAndUpdate({
host: null,
token: userToken
}, {
$set: {
github: {
accessToken,
id,
login
}
}
});
ctx.body = `GitHub: @${login} を、Misskey: @${user.username} に接続しました!`;
// Publish i updated event
publishMainStream(user._id, 'meUpdated', await pack(user, user, {
detail: true,
includeSecrets: true
}));
}
});
module.exports = router;
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`,
proxy: config.proxy,
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: any[] = 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}** (((⭐️)))`, false);
});
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);
});

View File

@@ -7,6 +7,7 @@ import User, { pack, ILocalUser } from '../../../models/user';
import { publishMainStream } from '../../../stream';
import config from '../../../config';
import signin from '../common/signin';
import fetchMeta from '../../../misc/fetch-meta';
function getUserToken(ctx: Koa.Context) {
return ((ctx.headers['cookie'] || '').match(/i=(!\w+)/) || [null, null])[1];
@@ -55,131 +56,133 @@ router.get('/disconnect/twitter', async ctx => {
}));
});
if (config.twitter == null || redis == null) {
router.get('/connect/twitter', ctx => {
ctx.body = '現在Twitterへ接続できません (このインスタンスではTwitterはサポートされていません)';
});
async function getTwAuth() {
const meta = await fetchMeta();
router.get('/signin/twitter', ctx => {
ctx.body = '現在Twitterへ接続できません (このインスタンスではTwitterはサポートされていません)';
});
} else {
const twAuth = autwh({
consumerKey: config.twitter.consumer_key,
consumerSecret: config.twitter.consumer_secret,
callbackUrl: `${config.url}/api/tw/cb`
});
router.get('/connect/twitter', async ctx => {
if (!compareOrigin(ctx)) {
ctx.throw(400, 'invalid origin');
return;
}
const userToken = getUserToken(ctx);
if (userToken == null) {
ctx.throw(400, 'signin required');
return;
}
const twCtx = await twAuth.begin();
redis.set(userToken, JSON.stringify(twCtx));
ctx.redirect(twCtx.url);
});
router.get('/signin/twitter', async ctx => {
const twCtx = await twAuth.begin();
const sessid = uuid();
redis.set(sessid, JSON.stringify(twCtx));
const expires = 1000 * 60 * 60; // 1h
ctx.cookies.set('signin_with_twitter_session_id', sessid, {
path: '/',
domain: config.host,
secure: config.url.startsWith('https'),
httpOnly: true,
expires: new Date(Date.now() + expires),
maxAge: expires
if (meta.enableTwitterIntegration) {
return autwh({
consumerKey: meta.twitterConsumerKey,
consumerSecret: meta.twitterConsumerSecret,
callbackUrl: `${config.url}/api/tw/cb`
});
ctx.redirect(twCtx.url);
});
router.get('/tw/cb', async ctx => {
const userToken = getUserToken(ctx);
if (userToken == null) {
const sessid = ctx.cookies.get('signin_with_twitter_session_id');
if (sessid == null) {
ctx.throw(400, 'invalid session');
return;
}
const get = new Promise<any>((res, rej) => {
redis.get(sessid, async (_, twCtx) => {
res(twCtx);
});
});
const twCtx = await get;
const result = await twAuth.done(JSON.parse(twCtx), ctx.query.oauth_verifier);
const user = await User.findOne({
host: null,
'twitter.userId': result.userId
}) as ILocalUser;
if (user == null) {
ctx.throw(404, `@${result.screenName}と連携しているMisskeyアカウントはありませんでした...`);
return;
}
signin(ctx, user, true);
} else {
const verifier = ctx.query.oauth_verifier;
if (verifier == null) {
ctx.throw(400, 'invalid session');
return;
}
const get = new Promise<any>((res, rej) => {
redis.get(userToken, async (_, twCtx) => {
res(twCtx);
});
});
const twCtx = await get;
const result = await twAuth.done(JSON.parse(twCtx), verifier);
const user = await User.findOneAndUpdate({
host: null,
token: userToken
}, {
$set: {
twitter: {
accessToken: result.accessToken,
accessTokenSecret: result.accessTokenSecret,
userId: result.userId,
screenName: result.screenName
}
}
});
ctx.body = `Twitter: @${result.screenName} を、Misskey: @${user.username} に接続しました!`;
// Publish i updated event
publishMainStream(user._id, 'meUpdated', await pack(user, user, {
detail: true,
includeSecrets: true
}));
}
});
} else {
return null;
}
}
router.get('/connect/twitter', async ctx => {
if (!compareOrigin(ctx)) {
ctx.throw(400, 'invalid origin');
return;
}
const userToken = getUserToken(ctx);
if (userToken == null) {
ctx.throw(400, 'signin required');
return;
}
const twAuth = await getTwAuth();
const twCtx = await twAuth.begin();
redis.set(userToken, JSON.stringify(twCtx));
ctx.redirect(twCtx.url);
});
router.get('/signin/twitter', async ctx => {
const twAuth = await getTwAuth();
const twCtx = await twAuth.begin();
const sessid = uuid();
redis.set(sessid, JSON.stringify(twCtx));
const expires = 1000 * 60 * 60; // 1h
ctx.cookies.set('signin_with_twitter_session_id', sessid, {
path: '/',
domain: config.host,
secure: config.url.startsWith('https'),
httpOnly: true,
expires: new Date(Date.now() + expires),
maxAge: expires
});
ctx.redirect(twCtx.url);
});
router.get('/tw/cb', async ctx => {
const userToken = getUserToken(ctx);
const twAuth = await getTwAuth();
if (userToken == null) {
const sessid = ctx.cookies.get('signin_with_twitter_session_id');
if (sessid == null) {
ctx.throw(400, 'invalid session');
return;
}
const get = new Promise<any>((res, rej) => {
redis.get(sessid, async (_, twCtx) => {
res(twCtx);
});
});
const twCtx = await get;
const result = await twAuth.done(JSON.parse(twCtx), ctx.query.oauth_verifier);
const user = await User.findOne({
host: null,
'twitter.userId': result.userId
}) as ILocalUser;
if (user == null) {
ctx.throw(404, `@${result.screenName}と連携しているMisskeyアカウントはありませんでした...`);
return;
}
signin(ctx, user, true);
} else {
const verifier = ctx.query.oauth_verifier;
if (verifier == null) {
ctx.throw(400, 'invalid session');
return;
}
const get = new Promise<any>((res, rej) => {
redis.get(userToken, async (_, twCtx) => {
res(twCtx);
});
});
const twCtx = await get;
const result = await twAuth.done(JSON.parse(twCtx), verifier);
const user = await User.findOneAndUpdate({
host: null,
token: userToken
}, {
$set: {
twitter: {
accessToken: result.accessToken,
accessTokenSecret: result.accessTokenSecret,
userId: result.userId,
screenName: result.screenName
}
}
});
ctx.body = `Twitter: @${result.screenName} を、Misskey: @${user.username} に接続しました!`;
// Publish i updated event
publishMainStream(user._id, 'meUpdated', await pack(user, user, {
detail: true,
includeSecrets: true
}));
}
});
module.exports = router;

View File

@@ -10,11 +10,18 @@ import create from './add-file';
import config from '../../config';
import { IUser } from '../../models/user';
import * as mongodb from 'mongodb';
import fetchMeta from '../../misc/fetch-meta';
const log = debug('misskey:drive:upload-from-url');
export default async (url: string, user: IUser, folderId: mongodb.ObjectID = null, uri: string = null, sensitive = false): Promise<IDriveFile> => {
export default async (
url: string,
user: IUser,
folderId: mongodb.ObjectID = null,
uri: string = null,
sensitive = false,
force = false,
link = false
): Promise<IDriveFile> => {
log(`REQUESTED: ${url}`);
let name = URL.parse(url).pathname.split('/').pop();
@@ -70,13 +77,11 @@ export default async (url: string, user: IUser, folderId: mongodb.ObjectID = nul
});
});
const instance = await fetchMeta();
let driveFile: IDriveFile;
let error;
try {
driveFile = await create(user, path, name, null, folderId, false, !instance.cacheRemoteFiles, url, uri, sensitive);
driveFile = await create(user, path, name, null, folderId, force, link, url, uri, sensitive);
log(`got: ${driveFile._id}`);
} catch (e) {
error = e;

View File

@@ -213,40 +213,47 @@ describe('Text', () => {
it('search', () => {
const tokens1 = analyze('a b c 検索');
assert.deepEqual([
{ type: 'search', content: 'a b c 検索', query: 'a b c'}
{ type: 'search', content: 'a b c 検索', query: 'a b c' }
], tokens1);
const tokens2 = analyze('a b c Search');
assert.deepEqual([
{ type: 'search', content: 'a b c Search', query: 'a b c'}
{ type: 'search', content: 'a b c Search', query: 'a b c' }
], tokens2);
const tokens3 = analyze('a b c search');
assert.deepEqual([
{ type: 'search', content: 'a b c search', query: 'a b c'}
{ type: 'search', content: 'a b c search', query: 'a b c' }
], tokens3);
const tokens4 = analyze('a b c SEARCH');
assert.deepEqual([
{ type: 'search', content: 'a b c SEARCH', query: 'a b c'}
{ type: 'search', content: 'a b c SEARCH', query: 'a b c' }
], tokens4);
});
it('title', () => {
const tokens1 = analyze('【yee】\nhaw');
assert.deepEqual(
{ type: 'title', content: '【yee】\n', title: 'yee'}
{ type: 'title', content: '【yee】\n', title: 'yee' }
, tokens1[0]);
const tokens2 = analyze('[yee]\nhaw');
assert.deepEqual(
{ type: 'title', content: '[yee]\n', title: 'yee'}
{ type: 'title', content: '[yee]\n', title: 'yee' }
, tokens2[0]);
const tokens3 = analyze('a [a]\nb [b]\nc [c]');
assert.deepEqual(
{ type: 'text', content: 'a [a]\nb [b]\nc [c]' }
, tokens3[0]);
const tokens4 = analyze('foo\n【bar】\nbuzz');
assert.deepEqual([
{ type: 'text', content: 'foo' },
{ type: 'title', content: '\n【bar】\n', title: 'bar' },
{ type: 'text', content: 'buzz' },
], tokens4);
});
});