Compare commits

..

33 Commits

Author SHA1 Message Date
0ce64f8c33 10.58.2 2018-11-29 06:34:07 +09:00
2cd6ccb85c Fix test 2018-11-29 06:33:23 +09:00
3dcf5374c2 Mark chart apis as stable 2018-11-29 06:06:07 +09:00
1c7d5f3f64 Update ts-loader requirement from 5.3.0 to 5.3.1 (#3426)
Updates the requirements on [ts-loader](https://github.com/TypeStrong/ts-loader) to permit the latest version.
- [Release notes](https://github.com/TypeStrong/ts-loader/releases)
- [Changelog](https://github.com/TypeStrong/ts-loader/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TypeStrong/ts-loader/commits/v5.3.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-29 05:31:41 +09:00
bb0cb0a866 Fix bad style in deck column options and other things (#3412)
* Fix wrong text color in empty timeline (#3268)

* Whoops

* Fix wrong text color in deck options (#3268)

* Some padding to make it look less ugly

* Fix wrong text color in user lists menu (#3268)

* Fix wrong text color of footer on welcome screen (mobile) (#3268)

* Fix misalignment of icons and text in menu (mobile) (#3289)

* Fix wrong text color in empty timeline (mobile) (#3268)
2018-11-29 05:02:35 +09:00
362dc29057 Update profile-editor.vue (#3424) 2018-11-29 04:54:36 +09:00
8af0218e4c ✌️🤔✌️ 2018-11-28 18:57:22 +09:00
09af9968b5 🎨 2018-11-28 16:29:18 +09:00
7d0b819c5a Merge branch 'develop' of https://github.com/syuilo/misskey into develop 2018-11-28 16:19:09 +09:00
4bbb7eded3 Cookieを使わないように 2018-11-28 16:19:02 +09:00
72ea9e5522 Update systeminformation requirement from 3.49.3 to 3.51.3 (#3419)
Updates the requirements on [systeminformation](https://github.com/sebhildebrandt/systeminformation) to permit the latest version.
- [Release notes](https://github.com/sebhildebrandt/systeminformation/releases)
- [Changelog](https://github.com/sebhildebrandt/systeminformation/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sebhildebrandt/systeminformation/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-28 16:01:16 +09:00
743e5d947d Update autobind-decorator requirement from 2.2.1 to 2.3.1 (#3418)
Updates the requirements on [autobind-decorator](https://github.com/andreypopp/autobind-decorator) to permit the latest version.
- [Release notes](https://github.com/andreypopp/autobind-decorator/releases)
- [Changelog](https://github.com/andreypopp/autobind-decorator/blob/master/CHANGELOG.md)
- [Commits](https://github.com/andreypopp/autobind-decorator/commits/v2.3.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-28 16:00:58 +09:00
f257853906 Update signin.ts 2018-11-28 05:27:34 +09:00
bdef33e88d Add theme_color and 512x512 icon to app manifest (#3417)
As per Chrome Lighthouse PWA suggestions.
2018-11-28 04:38:50 +09:00
ab92762320 Update webfinger.js requirement from 2.6.6 to 2.7.0 (#3414)
Updates the requirements on [webfinger.js](https://github.com/silverbucket/webfinger.js) to permit the latest version.
- [Release notes](https://github.com/silverbucket/webfinger.js/releases)
- [Changelog](https://github.com/silverbucket/webfinger.js/blob/master/RELEASE_CHECKLIST)
- [Commits](https://github.com/silverbucket/webfinger.js/commits/v2.7.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-27 15:49:50 +09:00
04942c8477 Update README.md [AUTOGEN] (#3415) 2018-11-27 15:49:39 +09:00
e62fad7bc6 Update README.md [AUTOGEN] (#3413) 2018-11-27 03:08:08 +09:00
2c6bad2501 [MFM] Improve hashtag detection 2018-11-27 02:08:51 +09:00
24ef98eb01 10.58.1 2018-11-27 01:26:07 +09:00
7ed50b90bd [Client] Resolve #3323 2018-11-27 01:21:16 +09:00
b6fd5d7282 No caching /api/ (#3411) 2018-11-27 01:16:25 +09:00
33243e7176 Fix #3409 (#3410)
* Update Dockerfile

* Update Dockerfile
2018-11-27 00:32:56 +09:00
e8439679a5 Add yarn.lock to .gitignore (#3408) 2018-11-26 21:55:16 +09:00
06124dbbd5 Return 404 for undefined .well-known (#3404) 2018-11-26 04:49:24 +09:00
857940f402 10.58.0 2018-11-26 04:33:39 +09:00
bcb04924ff Image for web publish (#3402)
* Image for Web

* Add comment

* Make main to original
2018-11-26 04:25:48 +09:00
0863e5d379 🎨 2018-11-25 13:47:42 +09:00
55dcd25df1 Improve MFM 2018-11-25 13:36:52 +09:00
f3155ea180 [MFM] Add center syntax
Resolve #1775
2018-11-25 13:36:40 +09:00
2c5162671c Improve MFM 2018-11-25 13:23:18 +09:00
fc8aeb5a66 [Client] Fix bug 2018-11-25 13:21:47 +09:00
995cf503eb Add MFM test 2018-11-25 13:21:39 +09:00
0e49c11a4c Refactoring 2018-11-25 13:19:33 +09:00
56 changed files with 530 additions and 151 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ api-docs.json
/mongo
/elasticsearch
*.code-workspace
yarn.lock

View File

@ -8,18 +8,20 @@ WORKDIR /misskey
FROM base AS builder
RUN unlink /usr/bin/free
RUN apk add --no-cache \
gcc \
g++ \
libc-dev \
python \
autoconf \
automake \
file \
g++ \
gcc \
libc-dev \
libtool \
make \
nasm \
pkgconfig \
libtool \
procps \
python \
zlib-dev
RUN npm i -g node-gyp

View File

@ -73,46 +73,50 @@ Please see [Contribution guide](./CONTRIBUTING.md).
----------------------------------------------------------------
<!-- PATREON_START -->
<table><tr>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/12190916/fb7fa7983c14425f890369535b1506a4/1?token-time=2145916800&token-hash=Zeh1u6l_Vmgoy8A1eT1Sltea-_SZSq8t8uOWDRZRh94%3D" alt="weep"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/13376668/71f3cf87ec6c4393a44b1b9df5ee3d12/1?token-time=2145916800&token-hash=7pSmWqgMfMSJHVIEcNsuuQoKeU3TRluew5p0EGTzWA4%3D" alt="Arctic"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/12731202/0995c46cdcb54153ab5f073f5869b70a/1?token-time=2145916800&token-hash=Yd60FK_SWfQO56SeiJpy1tDHOnCV4xdEywQe8gn5_Wo%3D" alt="negao"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/12913507/f7181eacafe8469a93033d85f5969c29/2?token-time=2145916800&token-hash=mgPdX9TqZxEg4TTPuc477dxhIgYk9246qafjWZEqZ7g%3D" alt="Melilot"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/3384329/8b713330cb27404ea6e9fac50ff96efe/1?token-time=2145916800&token-hash=0eu4-m1gTWA9PhptVZt6rdKcusqcD7RB87rJT23VVFI%3D" alt="べすれい"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/12021162/963128bb8d14476dbd8407943db8f31a/1?token-time=2145916800&token-hash=GgJ_NmUB6_nnRNLVGUWjV-WX91On7BOu59LKncYV9fE%3D" alt="gutfuckllc"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/11357794/923ce94cd8c44ba788ee931907881839/1?token-time=2145916800&token-hash=I8lJVM8LeW6TSo5W6uIIRZ42cw83zp1wK_FsbzY0mcQ%3D" alt="mydarkstar"></td>
<td><img src="https://c8.patreon.com/2/100/12718187" alt="Peter G."></td>
</tr><tr>
<td><a href="https://www.patreon.com/weepjp">weep</a></td>
<td><a href="https://www.patreon.com/user?u=13376668">Arctic</a></td>
<td><a href="https://www.patreon.com/negao">negao</a></td>
<td><a href="https://www.patreon.com/user?u=12913507">Melilot</a></td>
<td><a href="https://www.patreon.com/user?u=3384329">べすれい</a></td>
<td><a href="https://www.patreon.com/gutfuckllc">gutfuckllc</a></td>
<td><a href="https://www.patreon.com/mydarkstar">mydarkstar</a></td>
<td><a href="https://www.patreon.com/user?u=12718187">Peter G.</a></td>
</tr></table>
<table><tr>
<td><img src="https://c8.patreon.com/2/100/12718187" alt="Peter G."></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/13039004/509d0c412eb14ae08d6a812a3054f7d6/1?token-time=2145916800&token-hash=zwSu01tOtn5xTUucDZHuPsCxF2HBEMVs9ROJKTlEV_o%3D" alt="nemu"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/5881381/6235ca5d3fb04c8e95ef5b4ff2abcc18/3?token-time=2145916800&token-hash=qsdn0-e6yLaLI6hUX9JAkyTR6a5UdnSp7T1foniBvGQ%3D" alt="YUKIMOCHI"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/8241184/39e18850e87a449e9c9a71acb3310ebd/2?token-time=2145916800&token-hash=iUXOQzRyJDv3PJxwS7Mjwg1459dzh2trOq6NFtXu_OM%3D" alt="Acid Chicken"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/13034746/c711c7f58e204ecfbc2fd646bc8a4eee/1?token-time=2145916800&token-hash=UERBN4OyP7Nh5XwwdDg0N0IE5cD6_qUQMO81Z5Wizso%3D" alt="Hiratake"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/10789744/97175095d8f04c0f86225ff47cb98d40/1?token-time=2145916800&token-hash=P4BIzCX2I1CkEP66ottfhsC8Wr6BUSamjA-vq3pLqFI%3D" alt="Naoki Hirayama"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/4503830/ccf2cc867ea64de0b524bb2e24b9a1cb/1?token-time=2145916800&token-hash=S1zP0QyLU52Dqq6dtc9qNYyWfW86XrYHiR4NMbeOrnA%3D" alt="dansup"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/619786/32cf01444db24e578cd1982c197f6fc6/1?token-time=2145916800&token-hash=tB1e_r8RlZ5sFL0KV_e8dugapxatNBRK1Z3h67TO1g8%3D" alt="Gargron"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/5731881/4b6038e6cda34c04b83a5fcce3806a93/1?token-time=2145916800&token-hash=VZUtwrjQa8Jml4twCjHYQQZ64wHEY4oIlGl7Kc-VYUQ%3D" alt="Nokotaro Takeda"></td>
</tr><tr>
<td><a href="https://www.patreon.com/user?u=12718187">Peter G.</a></td>
<td><a href="https://www.patreon.com/user?u=13039004">nemu</a></td>
<td><a href="https://www.patreon.com/yukimochi">YUKIMOCHI</a></td>
<td><a href="https://www.patreon.com/acid_chicken">Acid Chicken</a></td>
<td><a href="https://www.patreon.com/hiratake">Hiratake</a></td>
<td><a href="https://www.patreon.com/spinlock">Naoki Hirayama</a></td>
<td><a href="https://www.patreon.com/dansup">dansup</a></td>
<td><a href="https://www.patreon.com/mastodon">Gargron</a></td>
<td><a href="https://www.patreon.com/takenoko">Nokotaro Takeda</a></td>
</tr></table>
<table><tr>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/619786/32cf01444db24e578cd1982c197f6fc6/1?token-time=2145916800&token-hash=tB1e_r8RlZ5sFL0KV_e8dugapxatNBRK1Z3h67TO1g8%3D" alt="Gargron"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/5731881/4b6038e6cda34c04b83a5fcce3806a93/1?token-time=2145916800&token-hash=VZUtwrjQa8Jml4twCjHYQQZ64wHEY4oIlGl7Kc-VYUQ%3D" alt="Nokotaro Takeda"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJoIjoxMDAsInciOjEwMH0%3D/patreon-media/p/user/12531784/93a45137841849329ba692da92ac7c60/1?token-time=2145916800&token-hash=tMosUojzUYJCH_3t--tvYA-SMCyrS__hzSndyaRSnbo%3D" alt="Takashi Shibuya"></td>
</tr><tr>
<td><a href="https://www.patreon.com/mastodon">Gargron</a></td>
<td><a href="https://www.patreon.com/takenoko">Nokotaro Takeda</a></td>
<td><a href="https://www.patreon.com/user?u=12531784">Takashi Shibuya</a></td>
</tr></table>
**Last updated:** Fri, 23 Nov 2018 14:09:04 UTC
**Last updated:** Tue, 27 Nov 2018 06:24:05 UTC
<!-- PATREON_END -->
:four_leaf_clover: Copyright

View File

@ -1092,17 +1092,17 @@ admin/views/instance.vue:
recaptcha-site-key: "reCAPTCHA site key"
recaptcha-secret-key: "reCAPTCHA secret key"
twitter-integration-config: "Twitter連携の設定"
twitter-integration-info: "コールバックURLは /api/tw/cb に設定します。"
twitter-integration-info: "コールバックURLは {url} に設定します。"
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 に設定します。"
github-integration-info: "コールバックURLは {url} に設定します。"
enable-github-integration: "GitHub連携を有効にする"
github-integration-client-id: "Client ID"
github-integration-client-secret: "Client Secret"
discord-integration-config: "Discord連携の設定"
discord-integration-info: "コールバックURLは /api/dc/cb に設定します。"
discord-integration-info: "コールバックURLは {url} に設定します。"
enable-discord-integration: "Discord連携を有効にする"
discord-integration-client-id: "Client ID"
discord-integration-client-secret: "Client Secret"

View File

@ -1,8 +1,8 @@
{
"name": "misskey",
"author": "syuilo <i@syuilo.com>",
"version": "10.57.3",
"clientVersion": "2.0.12095",
"version": "10.58.2",
"clientVersion": "2.0.12127",
"codename": "nighthike",
"main": "./built/index.js",
"private": true,
@ -88,7 +88,7 @@
"@types/ws": "6.0.1",
"animejs": "2.2.0",
"apexcharts": "2.2.3",
"autobind-decorator": "2.2.1",
"autobind-decorator": "2.3.1",
"autosize": "4.0.2",
"autwh": "0.1.0",
"bcryptjs": "2.4.3",
@ -201,13 +201,13 @@
"stylus": "0.54.5",
"stylus-loader": "3.0.2",
"summaly": "2.2.0",
"systeminformation": "3.49.3",
"systeminformation": "3.51.3",
"syuilo-password-strength": "0.0.1",
"terser-webpack-plugin": "1.1.0",
"textarea-caret": "3.1.0",
"tinycolor2": "1.4.1",
"tmp": "0.0.33",
"ts-loader": "5.3.0",
"ts-loader": "5.3.1",
"ts-node": "7.0.1",
"tslint": "5.10.0",
"typescript": "3.1.6",
@ -233,7 +233,7 @@
"vuex": "3.0.1",
"vuex-persistedstate": "2.5.4",
"web-push": "3.3.3",
"webfinger.js": "2.6.6",
"webfinger.js": "2.7.0",
"webpack": "4.26.0",
"webpack-cli": "3.1.2",
"websocket": "1.0.28",

View File

@ -69,7 +69,7 @@
<div slot="title"><fa :icon="['fab', 'twitter']"/> {{ $t('twitter-integration-config') }}</div>
<section>
<ui-switch v-model="enableTwitterIntegration">{{ $t('enable-twitter-integration') }}</ui-switch>
<ui-info>{{ $t('twitter-integration-info') }}</ui-info>
<ui-info>{{ $t('twitter-integration-info', { url: `${url}/api/tw/cb` }) }}</ui-info>
<ui-input v-model="twitterConsumerKey" :disabled="!enableTwitterIntegration"><i slot="icon"><fa icon="key"/></i>{{ $t('twitter-integration-consumer-key') }}</ui-input>
<ui-input v-model="twitterConsumerSecret" :disabled="!enableTwitterIntegration"><i slot="icon"><fa icon="key"/></i>{{ $t('twitter-integration-consumer-secret') }}</ui-input>
<ui-button @click="updateMeta">{{ $t('save') }}</ui-button>
@ -80,7 +80,7 @@
<div slot="title"><fa :icon="['fab', 'github']"/> {{ $t('github-integration-config') }}</div>
<section>
<ui-switch v-model="enableGithubIntegration">{{ $t('enable-github-integration') }}</ui-switch>
<ui-info>{{ $t('github-integration-info') }}</ui-info>
<ui-info>{{ $t('github-integration-info', { url: `${url}/api/gh/cb` }) }}</ui-info>
<ui-input v-model="githubClientId" :disabled="!enableGithubIntegration"><i slot="icon"><fa icon="key"/></i>{{ $t('github-integration-client-id') }}</ui-input>
<ui-input v-model="githubClientSecret" :disabled="!enableGithubIntegration"><i slot="icon"><fa icon="key"/></i>{{ $t('github-integration-client-secret') }}</ui-input>
<ui-button @click="updateMeta">{{ $t('save') }}</ui-button>
@ -91,7 +91,7 @@
<div slot="title"><fa :icon="['fab', 'discord']"/> {{ $t('discord-integration-config') }}</div>
<section>
<ui-switch v-model="enableDiscordIntegration">{{ $t('enable-discord-integration') }}</ui-switch>
<ui-info>{{ $t('discord-integration-info') }}</ui-info>
<ui-info>{{ $t('discord-integration-info', { url: `${url}/api/dc/cb` }) }}</ui-info>
<ui-input v-model="discordClientId" :disabled="!enableDiscordIntegration"><i slot="icon"><fa icon="key"/></i>{{ $t('discord-integration-client-id') }}</ui-input>
<ui-input v-model="discordClientSecret" :disabled="!enableDiscordIntegration"><i slot="icon"><fa icon="key"/></i>{{ $t('discord-integration-client-secret') }}</ui-input>
<ui-button @click="updateMeta">{{ $t('save') }}</ui-button>
@ -103,7 +103,7 @@
<script lang="ts">
import Vue from 'vue';
import i18n from '../../i18n';
import { host } from '../../config';
import { url, host } from '../../config';
import { toUnicode } from 'punycode';
import { faHeadset, faShieldAlt, faGhost, faUserPlus } from '@fortawesome/free-solid-svg-icons';
@ -112,6 +112,7 @@ export default Vue.extend({
data() {
return {
url,
host: toUnicode(host),
maintainerName: null,
maintainerEmail: null,

View File

@ -2,7 +2,7 @@ const faces = [
'(=^・・^=)',
'v(\'ω\')v',
'🐡( \'-\' 🐡 )フグパンチ!!!!',
'🖕(´・_・`)🖕',
'✌️(´・_・`)✌️',
'(。><。)',
'(Δ・x・Δ)'
];

View File

@ -80,7 +80,7 @@ export default (opts: Opts = {}) => ({
const ast = parse(this.appearNote.text);
// TODO: 再帰的にURL要素がないか調べる
return unique(ast
.filter(t => ((t.name == 'url' || t.name == 'link') && t.props.url && !t.silent))
.filter(t => ((t.name == 'url' || t.name == 'link') && t.props.url && !t.props.silent))
.map(t => t.props.url));
} else {
return null;

View File

@ -180,6 +180,7 @@ export default Vue.extend({
padding 8px 16px
width 100%
color var(--popupFg)
white-space nowrap
&:hover
color var(--primaryForeground)

View File

@ -111,6 +111,14 @@ export default Vue.component('misskey-flavored-markdown', {
}, genEl(token.children));
}
case 'center': {
return [createElement('div', {
attrs: {
style: 'text-align:center;'
}
}, genEl(token.children))];
}
case 'motion': {
motionCount++;
const isLong = getTextCount(token.children) > 10 || getChildrenCount(token.children) > 5;

View File

@ -29,7 +29,7 @@ export default Vue.extend({
>>> .quote
margin 8px
padding 6px 12px
padding 6px 0 6px 12px
color var(--mfmQuote)
border-left solid 3px var(--mfmQuoteLine)

View File

@ -179,8 +179,8 @@ export default Vue.extend({
location: this.location || null,
description: this.description || null,
birthday: this.birthday || null,
avatarId: this.avatarId,
bannerId: this.bannerId,
avatarId: this.avatarId || undefined,
bannerId: this.bannerId || undefined,
isCat: !!this.isCat,
isBot: !!this.isBot,
isLocked: !!this.isLocked,

View File

@ -67,7 +67,8 @@ export default Vue.extend({
username: this.username,
password: this.password,
token: this.user && this.user.twoFactorEnabled ? this.token : undefined
}, true).then(() => {
}, true).then(res => {
localStorage.setItem('i', res.i);
location.reload();
}).catch(() => {
alert(this.$t('login-failed'));

View File

@ -123,7 +123,7 @@ export default Vue.extend({
> span
display block
line-height 20px
color currentColor
color var(--text)
transition inherit
> p

View File

@ -54,7 +54,25 @@ export default Vue.extend({
padding 16px
> button
display block
margin-bottom 16px
color var(--primaryForeground)
background var(--primary)
width 100%
border-radius 38px
user-select none
cursor pointer
padding 0 16px
min-width 100px
line-height 38px
font-size 14px
font-weight 700
&:hover
background var(--primaryLighten10)
&:active
background var(--primaryDarken10)
> a
display block

View File

@ -10,7 +10,7 @@
<span>{{ name }}</span>
</span>
<div class="editor" style="padding:0 12px" v-if="edit">
<div class="editor" style="padding:12px" v-if="edit">
<ui-switch v-model="column.isMediaOnly" @change="onChangeSettings">{{ $t('is-media-only') }}</ui-switch>
<ui-switch v-model="column.isMediaView" @change="onChangeSettings">{{ $t('is-media-view') }}</ui-switch>
</div>

View File

@ -151,18 +151,20 @@ export default Vue.extend({
&:hover
color var(--desktopTimelineSrcHover)
> .empty
display block
margin 0 auto
padding 32px
max-width 400px
text-align center
color #999
> .mk-notes
> [data-icon]
> .empty
display block
margin-bottom 16px
font-size 3em
color #ccc
margin 0 auto
padding 32px
max-width 400px
text-align center
color var(--text)
> [data-icon]
display block
margin-bottom 16px
font-size 3em
color var(--faceHeaderText);
</style>

View File

@ -371,7 +371,6 @@ export default Vue.extend({
> .main
grid-row 1
grid-column 1 / 3
border-top solid 5px var(--primary)
> div
padding 32px

View File

@ -190,8 +190,8 @@ export default class MiOS extends EventEmitter {
this.store.dispatch('mergeMe', freshData);
});
} else {
// Get token from cookie
const i = (document.cookie.match(/i=(!\w+)/) || [null, null])[1];
// Get token from cookie or localStorage
const i = (document.cookie.match(/i=(!\w+)/) || [null, null])[1] || localStorage.getItem('i');
fetchme(i, me => {
if (me) {

View File

@ -334,6 +334,7 @@ main
max-width 680px
margin 0 auto
padding 8px
color var(--text)
@media (min-width 500px)
padding 16px

View File

@ -306,6 +306,7 @@ export default Vue.extend({
padding 16px 0
border solid 2px rgba(0, 0, 0, 0.1)
border-radius 8px
color var(--text)
> *
margin 0 16px

View File

@ -11,11 +11,3 @@ if (!('fetch' in window)) {
'Your browser (or your OS) seems outdated. ' +
'To run Misskey, please update your browser to latest version or try other browsers.');
}
// Check whether cookie enabled
if (!navigator.cookieEnabled) {
alert(
'Misskeyを利用するにはCookieを有効にしてください。' +
'\n\n' +
'To use Misskey, please enable Cookie.');
}

View File

@ -129,6 +129,7 @@ export default (os: MiOS) => new Vuex.Store({
logout(ctx) {
ctx.commit('updateI', null);
document.cookie = `i=; domain=${hostname}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
localStorage.removeItem('i');
},
mergeMe(ctx, me) {

View File

@ -4,6 +4,7 @@
"start_url": "/",
"display": "standalone",
"background_color": "#313a42",
"theme_color": "#fb4e4e",
"icons": [
{
"src": "/assets/icons/16.png",
@ -34,6 +35,11 @@
"src": "/assets/icons/256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "/assets/icons/512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"share_target": {

View File

@ -45,6 +45,12 @@ export default (tokens: Node[], mentionedRemoteUsers: INote['mentionedRemoteUser
return pre;
},
center(token) {
const el = doc.createElement('div');
dive(token.children).forEach(child => el.appendChild(child));
return el;
},
emoji(token) {
return doc.createTextNode(token.props.emoji ? token.props.emoji : `:${token.props.name}:`);
},

View File

@ -41,7 +41,7 @@ export default (source: string): Node[] => {
}
function isBlockNode(node: Node): boolean {
return ['blockCode', 'quote', 'title'].includes(node.name);
return ['blockCode', 'center', 'quote', 'title'].includes(node.name);
}
/**

View File

@ -29,6 +29,32 @@ function makeNodeWithChildren(name: string, children: Node[], props?: any): Node
return _makeNode(name, children, props);
}
function getTrailingPosition(x: string): number {
const brackets = [
['(', ')'],
['「', '」'],
];
const pendingBrackets = [] as any;
const end = x.split('').findIndex(char => {
const closeMatch = brackets.map(x => x[1]).indexOf(char);
const openMatch = brackets.map(x => x[0]).indexOf(char);
if (closeMatch != -1) {
if (pendingBrackets[closeMatch] > 0) {
pendingBrackets[closeMatch]--;
return false;
} else {
return true;
}
} else if (openMatch != -1) {
pendingBrackets[openMatch] = (pendingBrackets[openMatch] || 0) + 1;
return false;
} else {
return false;
}
});
return end > 0 ? end : x.length;
}
const newline = P((input, i) => {
if (i == 0 || input[i] == '\n' || input[i - 1] == '\n') {
return P.makeSuccess(i, null);
@ -53,6 +79,7 @@ const mfm = P.createLanguage({
r.math,
r.search,
r.title,
r.center,
r.text
).atLeast(1),
@ -65,6 +92,7 @@ const mfm = P.createLanguage({
r.mention,
r.hashtag,
r.emoji,
r.math,
r.text
).atLeast(1).tryParse(x))),
//#endregion
@ -87,11 +115,30 @@ const mfm = P.createLanguage({
.map(x => makeNodeWithChildren('bold', P.alt(
r.mention,
r.hashtag,
r.url,
r.link,
r.emoji,
r.text
).atLeast(1).tryParse(x))),
//#endregion
//#region Center
center: r =>
P.regexp(/<center>([\s\S]+?)<\/center>/, 1)
.map(x => makeNodeWithChildren('center', P.alt(
r.big,
r.bold,
r.motion,
r.mention,
r.hashtag,
r.emoji,
r.math,
r.url,
r.link,
r.text
).atLeast(1).tryParse(x))),
//#endregion
//#region Emoji
emoji: r =>
P.alt(
@ -113,25 +160,9 @@ const mfm = P.createLanguage({
const match = text.match(/^#([^\s\.,!\?#]+)/i);
if (!match) return P.makeFailure(i, 'not a hashtag');
let hashtag = match[1];
let pendingBracket = 0;
const end = hashtag.split('').findIndex(char => {
if (char == ')') {
if (pendingBracket > 0) {
pendingBracket--;
return false;
} else {
return true;
}
} else if (char == '(') {
pendingBracket++;
return false;
} else {
return false;
}
});
if (end > 0) hashtag = hashtag.substr(0, end);
hashtag = hashtag.substr(0, getTrailingPosition(hashtag));
if (hashtag.match(/^[0-9]+$/)) return P.makeFailure(i, 'not a hashtag');
if (!['\n', ' ', '(', null, undefined].includes(input[i - 1])) return P.makeFailure(i, 'require space before "#"');
if (!['\n', ' ', '(', '「', null, undefined].includes(input[i - 1])) return P.makeFailure(i, 'require space before "#"');
return P.makeSuccess(i + ('#' + hashtag).length, makeNode('hashtag', { hashtag: hashtag }));
}),
//#endregion
@ -199,6 +230,9 @@ const mfm = P.createLanguage({
r.mention,
r.hashtag,
r.emoji,
r.url,
r.link,
r.math,
r.text
).atLeast(1).tryParse(x))),
//#endregion
@ -264,23 +298,7 @@ const mfm = P.createLanguage({
const match = text.match(/^https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.,=\+\-]+/);
if (!match) return P.makeFailure(i, 'not a url');
let url = match[0];
let pendingBracket = 0;
const end = url.split('').findIndex(char => {
if (char == ')') {
if (pendingBracket > 0) {
pendingBracket--;
return false;
} else {
return true;
}
} else if (char == '(') {
pendingBracket++;
return false;
} else {
return false;
}
});
if (end > 0) url = url.substr(0, end);
url = url.substr(0, getTrailingPosition(url));
if (url.endsWith('.')) url = url.substr(0, url.lastIndexOf('.'));
if (url.endsWith(',')) url = url.substr(0, url.lastIndexOf(','));
return P.makeSuccess(i + url.length, url);

View File

@ -6,15 +6,24 @@ export default function(file: IDriveFile, thumbnail = false): string {
if (file.metadata.withoutChunks) {
if (thumbnail) {
return file.metadata.thumbnailUrl || file.metadata.url;
return file.metadata.thumbnailUrl || file.metadata.webpublicUrl || file.metadata.url;
} else {
return file.metadata.url;
return file.metadata.webpublicUrl || file.metadata.url;
}
} else {
if (thumbnail) {
return `${config.drive_url}/${file._id}?thumbnail`;
} else {
return `${config.drive_url}/${file._id}`;
return `${config.drive_url}/${file._id}?web`;
}
}
}
export function getOriginalUrl(file: IDriveFile) {
if (file.metadata && file.metadata.url) {
return file.metadata.url;
}
const accessKey = file.metadata ? file.metadata.accessKey : null;
return `${config.drive_url}/${file._id}${accessKey ? '?original=' + accessKey : ''}`;
}

View File

@ -0,0 +1,29 @@
import * as mongo from 'mongodb';
import monkDb, { nativeDbConn } from '../db/mongodb';
const DriveFileWebpublic = monkDb.get<IDriveFileWebpublic>('driveFileWebpublics.files');
DriveFileWebpublic.createIndex('metadata.originalId', { sparse: true, unique: true });
export default DriveFileWebpublic;
export const DriveFileWebpublicChunk = monkDb.get('driveFileWebpublics.chunks');
export const getDriveFileWebpublicBucket = async (): Promise<mongo.GridFSBucket> => {
const db = await nativeDbConn();
const bucket = new mongo.GridFSBucket(db, {
bucketName: 'driveFileWebpublics'
});
return bucket;
};
export type IMetadata = {
originalId: mongo.ObjectID;
};
export type IDriveFileWebpublic = {
_id: mongo.ObjectID;
uploadDate: Date;
md5: string;
filename: string;
contentType: string;
metadata: IMetadata;
};

View File

@ -3,7 +3,7 @@ const deepcopy = require('deepcopy');
import { pack as packFolder } from './drive-folder';
import monkDb, { nativeDbConn } from '../db/mongodb';
import isObjectId from '../misc/is-objectid';
import getDriveFileUrl from '../misc/get-drive-file-url';
import getDriveFileUrl, { getOriginalUrl } from '../misc/get-drive-file-url';
const DriveFile = monkDb.get<IDriveFile>('driveFiles.files');
DriveFile.createIndex('md5');
@ -28,21 +28,48 @@ export type IMetadata = {
_user: any;
folderId: mongo.ObjectID;
comment: string;
/**
* リモートインスタンスから取得した場合の元URL
*/
uri?: string;
/**
* URL for web(生成されている場合) or original
* * オブジェクトストレージを利用している or リモートサーバーへの直リンクである 場合のみ
*/
url?: string;
/**
* URL for thumbnail (thumbnailがなければなし)
* * オブジェクトストレージを利用している or リモートサーバーへの直リンクである 場合のみ
*/
thumbnailUrl?: string;
/**
* URL for original (web用が生成されてない場合はurlがoriginalを指す)
* * オブジェクトストレージを利用している or リモートサーバーへの直リンクである 場合のみ
*/
webpublicUrl?: string;
accessKey?: string;
src?: string;
deletedAt?: Date;
/**
* このファイルの中身データがMongoDB内に保存されているのか否か
* このファイルの中身データがMongoDB内に保存されていないか否か
* オブジェクトストレージを利用している or リモートサーバーへの直リンクである
* な場合は false になります
* な場合は true になります
*/
withoutChunks?: boolean;
storage?: string;
storageProps?: any;
/***
* ObjectStorage の格納先の情報
*/
storageProps?: IStorageProps;
isSensitive?: boolean;
/**
@ -56,6 +83,25 @@ export type IMetadata = {
isRemote?: boolean;
};
export type IStorageProps = {
/**
* ObjectStorage key for original
*/
key: string;
/***
* ObjectStorage key for thumbnail (thumbnailがなければなし)
*/
thumbnailKey?: string;
/***
* ObjectStorage key for webpublic (webpublicがなければなし)
*/
webpublicKey?: string;
id?: string;
};
export type IDriveFile = {
_id: mongo.ObjectID;
uploadDate: Date;
@ -83,7 +129,8 @@ export function validateFileName(name: string): boolean {
export const packMany = (
files: any[],
options?: {
detail: boolean
detail?: boolean
self?: boolean,
}
) => {
return Promise.all(files.map(f => pack(f, options)));
@ -95,11 +142,13 @@ export const packMany = (
export const pack = (
file: any,
options?: {
detail: boolean
detail?: boolean,
self?: boolean,
}
) => new Promise<any>(async (resolve, reject) => {
const opts = Object.assign({
detail: false
detail: false,
self: false
}, options);
let _file: any;
@ -165,5 +214,9 @@ export const pack = (
delete _target.isRemote;
delete _target._user;
if (opts.self) {
_target.url = getOriginalUrl(_file);
}
resolve(_target);
});

View File

@ -4,21 +4,24 @@ import config from '../../../config';
import { ILocalUser } from '../../../models/user';
export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
const expires = 1000 * 60 * 60 * 24 * 365; // One Year
ctx.cookies.set('i', user.token, {
path: '/',
domain: config.hostname,
// SEE: https://github.com/koajs/koa/issues/974
// When using a SSL proxy it should be configured to add the "X-Forwarded-Proto: https" header
secure: config.url.startsWith('https'),
httpOnly: false,
expires: new Date(Date.now() + expires),
maxAge: expires
});
if (redirect) {
//#region Cookie
const expires = 1000 * 60 * 60 * 24 * 365; // One Year
ctx.cookies.set('i', user.token, {
path: '/',
domain: config.hostname,
// SEE: https://github.com/koajs/koa/issues/974
// When using a SSL proxy it should be configured to add the "X-Forwarded-Proto: https" header
secure: config.url.startsWith('https'),
httpOnly: false,
expires: new Date(Date.now() + expires),
maxAge: expires
});
//#endregion
ctx.redirect(config.url);
} else {
ctx.status = 204;
ctx.body = { i: user.token };
ctx.status = 200;
}
}

View File

@ -3,6 +3,8 @@ import define from '../../define';
import driveChart from '../../../../chart/drive';
export const meta = {
stability: 'stable',
desc: {
'ja-JP': 'ドライブのチャートを取得します。'
},

View File

@ -3,6 +3,8 @@ import define from '../../define';
import federationChart from '../../../../chart/federation';
export const meta = {
stability: 'stable',
desc: {
'ja-JP': 'フェデレーションのチャートを取得します。'
},

View File

@ -3,6 +3,8 @@ import define from '../../define';
import hashtagChart from '../../../../chart/hashtag';
export const meta = {
stability: 'stable',
desc: {
'ja-JP': 'ハッシュタグごとのチャートを取得します。'
},

View File

@ -3,6 +3,8 @@ import define from '../../define';
import networkChart from '../../../../chart/network';
export const meta = {
stability: 'stable',
desc: {
'ja-JP': 'ネットワークのチャートを取得します。'
},

View File

@ -3,6 +3,8 @@ import define from '../../define';
import notesChart from '../../../../chart/notes';
export const meta = {
stability: 'stable',
desc: {
'ja-JP': '投稿のチャートを取得します。'
},

View File

@ -4,6 +4,8 @@ import perUserDriveChart from '../../../../../chart/per-user-drive';
import ID, { transform } from '../../../../../misc/cafy-id';
export const meta = {
stability: 'stable',
desc: {
'ja-JP': 'ユーザーごとのドライブのチャートを取得します。'
},

View File

@ -4,6 +4,8 @@ import perUserFollowingChart from '../../../../../chart/per-user-following';
import ID, { transform } from '../../../../../misc/cafy-id';
export const meta = {
stability: 'stable',
desc: {
'ja-JP': 'ユーザーごとのフォロー/フォロワーのチャートを取得します。'
},

View File

@ -4,6 +4,8 @@ import perUserNotesChart from '../../../../../chart/per-user-notes';
import ID, { transform } from '../../../../../misc/cafy-id';
export const meta = {
stability: 'stable',
desc: {
'ja-JP': 'ユーザーごとの投稿のチャートを取得します。'
},

View File

@ -4,6 +4,8 @@ import perUserReactionsChart from '../../../../../chart/per-user-reactions';
import ID, { transform } from '../../../../../misc/cafy-id';
export const meta = {
stability: 'stable',
desc: {
'ja-JP': 'ユーザーごとの被リアクション数のチャートを取得します。'
},

View File

@ -3,6 +3,8 @@ import define from '../../define';
import usersChart from '../../../../chart/users';
export const meta = {
stability: 'stable',
desc: {
'ja-JP': 'ユーザーのチャートを取得します。'
},

View File

@ -77,5 +77,5 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
sort: sort
});
res(await packMany(files));
res(await packMany(files, { detail: false, self: true }));
}));

View File

@ -32,6 +32,6 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
if (file === null) {
res({ file: null });
} else {
res({ file: await pack(file) });
res({ file: await pack(file, { self: true }) });
}
}));

View File

@ -74,7 +74,7 @@ export default define(meta, (ps, user, app, file, cleanup) => new Promise(async
cleanup();
res(pack(driveFile));
res(pack(driveFile, { self: true }));
} catch (e) {
console.error(e);

View File

@ -31,5 +31,5 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
'metadata.folderId': ps.folderId
});
res(await Promise.all(files.map(file => pack(file))));
res(await Promise.all(files.map(file => pack(file, { self: true }))));
}));

View File

@ -41,7 +41,8 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
// Serialize
const _file = await pack(file, {
detail: true
detail: true,
self: true
});
res(_file);

View File

@ -111,7 +111,7 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
});
// Serialize
const fileObj = await pack(file);
const fileObj = await pack(file, { self: true });
// Response
res(fileObj);

View File

@ -50,5 +50,5 @@ export const meta = {
};
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
res(pack(await uploadFromUrl(ps.url, user, ps.folderId, null, ps.isSensitive, ps.force)));
res(pack(await uploadFromUrl(ps.url, user, ps.folderId, null, ps.isSensitive, ps.force), { self: true }));
}));

View File

@ -65,5 +65,5 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
sort: sort
});
res(await packMany(files));
res(await packMany(files, { self: true }));
}));

View File

@ -19,6 +19,12 @@ app.use(cors({
origin: '*'
}));
// No caching
app.use(async (ctx, next) => {
ctx.set('Cache-Control', 'private, max-age=0, must-revalidate');
await next();
});
app.use(bodyParser({
// リクエストが multipart/form-data でない限りはJSONだと見なす
detectJSON: ctx => !ctx.is('multipart/form-data')

View File

@ -3,6 +3,7 @@ import * as send from 'koa-send';
import * as mongodb from 'mongodb';
import DriveFile, { getDriveFileBucket } from '../../models/drive-file';
import DriveFileThumbnail, { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
import DriveFileWebpublic, { getDriveFileWebpublicBucket } from '../../models/drive-file-webpublic';
const assets = `${__dirname}/../../server/file/assets/`;
@ -41,6 +42,11 @@ export default async function(ctx: Koa.Context) {
}
const sendRaw = async () => {
if (file.metadata && file.metadata.accessKey && file.metadata.accessKey != ctx.query['original']) {
ctx.status = 403;
return;
}
const bucket = await getDriveFileBucket();
const readable = bucket.openDownloadStream(fileId);
readable.on('error', commonReadableHandlerGenerator(ctx));
@ -60,6 +66,19 @@ export default async function(ctx: Koa.Context) {
} else {
await sendRaw();
}
} else if ('web' in ctx.query) {
const web = await DriveFileWebpublic.findOne({
'metadata.originalId': fileId
});
if (web != null) {
ctx.set('Content-Type', file.contentType);
const bucket = await getDriveFileWebpublicBucket();
ctx.body = bucket.openDownloadStream(web._id);
} else {
await sendRaw();
}
} else {
if ('download' in ctx.query) {
ctx.set('Content-Disposition', 'attachment');

View File

@ -59,6 +59,11 @@ const router = new Router();
router.use(activityPub.routes());
router.use(webFinger.routes());
// Return 404 for other .well-known
router.all('/.well-known/*', async ctx => {
ctx.status = 404;
});
// Register router
app.use(router.routes());

View File

@ -16,6 +16,7 @@ import { publishMainStream, publishDriveStream } from '../../stream';
import { isLocalUser, IUser, IRemoteUser } from '../../models/user';
import delFile from './delete-file';
import config from '../../config';
import { getDriveFileWebpublicBucket } from '../../models/drive-file-webpublic';
import { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
import driveChart from '../../chart/drive';
import perUserDriveChart from '../../chart/per-user-drive';
@ -23,7 +24,71 @@ import fetchMeta from '../../misc/fetch-meta';
const log = debug('misskey:drive:add-file');
async function save(path: string, name: string, type: string, hash: string, size: number, metadata: any): Promise<IDriveFile> {
/***
* Save file
* @param path Path for original
* @param name Name for original
* @param type Content-Type for original
* @param hash Hash for original
* @param size Size for original
* @param metadata
*/
async function save(path: string, name: string, type: string, hash: string, size: number, metadata: IMetadata): Promise<IDriveFile> {
// #region webpublic
let webpublic: Buffer;
let webpublicExt = 'jpg';
let webpublicType = 'image/jpeg';
if (!metadata.uri) { // from local instance
log(`creating web image`);
if (['image/jpeg'].includes(type)) {
webpublic = await sharp(path)
.resize(2048, 2048, {
fit: 'inside',
withoutEnlargement: true
})
.rotate()
.jpeg({
quality: 85,
progressive: true
})
.toBuffer();
} else if (['image/webp'].includes(type)) {
webpublic = await sharp(path)
.resize(2048, 2048, {
fit: 'inside',
withoutEnlargement: true
})
.rotate()
.webp({
quality: 85
})
.toBuffer();
webpublicExt = 'webp';
webpublicType = 'image/webp';
} else if (['image/png'].includes(type)) {
webpublic = await sharp(path)
.resize(2048, 2048, {
fit: 'inside',
withoutEnlargement: true
})
.rotate()
.png()
.toBuffer();
webpublicExt = 'png';
webpublicType = 'image/png';
} else {
log(`web image not created (not an image)`);
}
} else {
log(`web image not created (from remote)`);
}
// #endregion webpublic
// #region thumbnail
let thumbnail: Buffer;
let thumbnailExt = 'jpg';
let thumbnailType = 'image/jpeg';
@ -53,10 +118,9 @@ async function save(path: string, name: string, type: string, hash: string, size
thumbnailExt = 'png';
thumbnailType = 'image/png';
}
// #endregion thumbnail
if (config.drive && config.drive.storage == 'minio') {
const minio = new Minio.Client(config.drive.config);
let [ext] = (name.match(/\.([a-zA-Z0-9_-]+)$/) || ['']);
if (ext === '') {
@ -66,33 +130,41 @@ async function save(path: string, name: string, type: string, hash: string, size
}
const key = `${config.drive.prefix}/${uuid.v4()}${ext}`;
const webpublicKey = `${config.drive.prefix}/${uuid.v4()}.${webpublicExt}`;
const thumbnailKey = `${config.drive.prefix}/${uuid.v4()}.${thumbnailExt}`;
log(`uploading original: ${key}`);
const uploads = [
upload(key, fs.createReadStream(path), type)
];
if (webpublic) {
log(`uploading webpublic: ${webpublicKey}`);
uploads.push(upload(webpublicKey, webpublic, webpublicType));
}
if (thumbnail) {
log(`uploading thumbnail: ${thumbnailKey}`);
uploads.push(upload(thumbnailKey, thumbnail, thumbnailType));
}
await Promise.all(uploads);
const baseUrl = config.drive.baseUrl
|| `${ config.drive.config.useSSL ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? `:${config.drive.config.port}` : '' }/${ config.drive.bucket }`;
await minio.putObject(config.drive.bucket, key, fs.createReadStream(path), size, {
'Content-Type': type,
'Cache-Control': 'max-age=31536000, immutable'
});
if (thumbnail) {
await minio.putObject(config.drive.bucket, thumbnailKey, thumbnail, size, {
'Content-Type': thumbnailType,
'Cache-Control': 'max-age=31536000, immutable'
});
}
Object.assign(metadata, {
withoutChunks: true,
storage: 'minio',
storageProps: {
key: key,
thumbnailKey: thumbnailKey
webpublicKey: webpublic ? webpublicKey : null,
thumbnailKey: thumbnail ? thumbnailKey : null,
},
url: `${ baseUrl }/${ key }`,
webpublicUrl: webpublic ? `${ baseUrl }/${ webpublicKey }` : null,
thumbnailUrl: thumbnail ? `${ baseUrl }/${ thumbnailKey }` : null
});
} as IMetadata);
const file = await DriveFile.insert({
length: size,
@ -105,29 +177,55 @@ async function save(path: string, name: string, type: string, hash: string, size
return file;
} else {
// Get MongoDB GridFS bucket
const bucket = await getDriveFileBucket();
// #region store original
const originalDst = await getDriveFileBucket();
const file = await new Promise<IDriveFile>((resolve, reject) => {
const writeStream = bucket.openUploadStream(name, {
// web用(Exif削除済み)がある場合はオリジナルにアクセス制限
if (webpublic) metadata.accessKey = uuid.v4();
const originalFile = await new Promise<IDriveFile>((resolve, reject) => {
const writeStream = originalDst.openUploadStream(name, {
contentType: type,
metadata
});
writeStream.once('finish', resolve);
writeStream.on('error', reject);
fs.createReadStream(path).pipe(writeStream);
});
log(`original stored to ${originalFile._id}`);
// #endregion store original
// #region store webpublic
if (webpublic) {
const webDst = await getDriveFileWebpublicBucket();
const webFile = await new Promise<IDriveFile>((resolve, reject) => {
const writeStream = webDst.openUploadStream(name, {
contentType: webpublicType,
metadata: {
originalId: originalFile._id
}
});
writeStream.once('finish', resolve);
writeStream.on('error', reject);
writeStream.end(webpublic);
});
log(`web stored ${webFile._id}`);
}
// #endregion store webpublic
if (thumbnail) {
const thumbnailBucket = await getDriveFileThumbnailBucket();
await new Promise<IDriveFile>((resolve, reject) => {
const tuhmFile = await new Promise<IDriveFile>((resolve, reject) => {
const writeStream = thumbnailBucket.openUploadStream(name, {
contentType: thumbnailType,
metadata: {
originalId: file._id
originalId: originalFile._id
}
});
@ -135,12 +233,23 @@ async function save(path: string, name: string, type: string, hash: string, size
writeStream.on('error', reject);
writeStream.end(thumbnail);
});
log(`thumbnail stored ${tuhmFile._id}`);
}
return file;
return originalFile;
}
}
async function upload(key: string, stream: fs.ReadStream | Buffer, type: string) {
const minio = new Minio.Client(config.drive.config);
await minio.putObject(config.drive.bucket, key, stream, null, {
'Content-Type': type,
'Cache-Control': 'max-age=31536000, immutable'
});
}
async function deleteOldFile(user: IRemoteUser) {
const oldFile = await DriveFile.findOne({
_id: {

View File

@ -4,6 +4,7 @@ import DriveFileThumbnail, { DriveFileThumbnailChunk } from '../../models/drive-
import config from '../../config';
import driveChart from '../../chart/drive';
import perUserDriveChart from '../../chart/per-user-drive';
import DriveFileWebpublic, { DriveFileWebpublicChunk } from '../../models/drive-file-webpublic';
export default async function(file: IDriveFile, isExpired = false) {
if (file.metadata.storage == 'minio') {
@ -20,6 +21,11 @@ export default async function(file: IDriveFile, isExpired = false) {
const thumbnailObj = file.metadata.storageProps.thumbnailKey ? file.metadata.storageProps.thumbnailKey : `${config.drive.prefix}/${file.metadata.storageProps.id}-thumbnail`;
await minio.removeObject(config.drive.bucket, thumbnailObj);
}
if (file.metadata.webpublicUrl) {
const webpublicObj = file.metadata.storageProps.webpublicKey ? file.metadata.storageProps.webpublicKey : `${config.drive.prefix}/${file.metadata.storageProps.id}-original`;
await minio.removeObject(config.drive.bucket, webpublicObj);
}
}
// チャンクをすべて削除
@ -48,6 +54,20 @@ export default async function(file: IDriveFile, isExpired = false) {
}
//#endregion
//#region Web公開用もあれば削除
const webpublic = await DriveFileWebpublic.findOne({
'metadata.originalId': file._id
});
if (webpublic) {
await DriveFileWebpublicChunk.remove({
files_id: webpublic._id
});
await DriveFileWebpublic.remove({ _id: webpublic._id });
}
//#endregion
// 統計を更新
driveChart.update(file, false);
perUserDriveChart.update(file, false);

View File

@ -192,7 +192,7 @@ describe('API', () => {
password: 'foo'
});
expect(res).have.status(204);
expect(res).have.status(200);
}));
});

View File

@ -213,21 +213,44 @@ describe('Text', () => {
});
it('with brackets', () => {
const tokens = analyze('(#foo)');
const tokens1 = analyze('(#foo)');
assert.deepEqual([
text('('),
node('hashtag', { hashtag: 'foo' }),
text(')'),
], tokens1);
const tokens2 = analyze('「#foo」');
assert.deepEqual([
text('「'),
node('hashtag', { hashtag: 'foo' }),
text('」'),
], tokens2);
});
it('with mixed brackets', () => {
const tokens = analyze('「#foo(bar)」');
assert.deepEqual([
text('「'),
node('hashtag', { hashtag: 'foo(bar)' }),
text('」'),
], tokens);
});
it('with brackets (space before)', () => {
const tokens = analyze('(bar #foo)');
const tokens1 = analyze('(bar #foo)');
assert.deepEqual([
text('(bar '),
node('hashtag', { hashtag: 'foo' }),
text(')'),
], tokens);
], tokens1);
const tokens2 = analyze('「bar #foo」');
assert.deepEqual([
text('「bar '),
node('hashtag', { hashtag: 'foo' }),
text('」'),
], tokens2);
});
it('disallow number only', () => {
@ -449,6 +472,15 @@ describe('Text', () => {
], tokens);
});
it('simple (with silent flag)', () => {
const tokens = analyze('?[foo](https://example.com)');
assert.deepEqual([
nodeWithChildren('link', [
text('foo')
], { url: 'https://example.com', silent: true })
], tokens);
});
it('in text', () => {
const tokens = analyze('before[foo](https://example.com)after');
assert.deepEqual([
@ -632,6 +664,17 @@ describe('Text', () => {
], tokens);
});
});
describe('center', () => {
it('simple', () => {
const tokens = analyze('<center>foo</center>');
assert.deepEqual([
nodeWithChildren('center', [
text('foo')
]),
], tokens);
});
});
});
describe('toHtml', () => {