From 1330287b32173a1fc21af611440f89e73717e32f Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 27 Nov 2017 06:39:01 +0900 Subject: [PATCH 01/20] Update dependencies :rocket: --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7d302279e..b39cbbd47 100644 --- a/package.json +++ b/package.json @@ -48,9 +48,9 @@ "@types/inquirer": "0.0.35", "@types/is-root": "1.0.0", "@types/is-url": "1.2.28", - "@types/js-yaml": "3.10.0", + "@types/js-yaml": "3.10.1", "@types/mocha": "2.2.44", - "@types/mongodb": "2.2.15", + "@types/mongodb": "2.2.16", "@types/monk": "1.0.6", "@types/morgan": "1.7.35", "@types/ms": "0.7.30", @@ -60,7 +60,7 @@ "@types/proxy-addr": "2.0.0", "@types/ratelimiter": "2.1.28", "@types/redis": "2.8.1", - "@types/request": "2.0.7", + "@types/request": "2.0.8", "@types/rimraf": "2.0.2", "@types/riot": "3.6.1", "@types/seedrandom": "2.4.27", @@ -69,7 +69,7 @@ "@types/uuid": "3.4.3", "@types/webpack": "3.8.1", "@types/webpack-stream": "3.2.8", - "@types/websocket": "0.0.34", + "@types/websocket": "0.0.35", "accesses": "2.5.0", "animejs": "2.2.0", "autwh": "0.0.1", @@ -113,7 +113,7 @@ "is-root": "1.0.0", "is-url": "1.2.2", "js-yaml": "3.10.0", - "mecab-async": "0.1.0", + "mecab-async": "0.1.2", "mocha": "4.0.1", "moji": "0.5.1", "mongodb": "2.2.33", @@ -154,7 +154,7 @@ "ts-node": "3.3.0", "tslint": "5.8.0", "typescript": "2.6.1", - "uglify-es": "3.1.10", + "uglify-es": "3.2.0", "uglifyjs-webpack-plugin": "1.1.1", "uuid": "3.1.0", "vhost": "3.0.2", From e2a22fc968cfd4528d858af2d229a13b7b23d485 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 27 Nov 2017 06:49:06 +0900 Subject: [PATCH 02/20] no-cache --- src/web/app/desktop/tags/home-widgets/rss-reader.tag | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/web/app/desktop/tags/home-widgets/rss-reader.tag b/src/web/app/desktop/tags/home-widgets/rss-reader.tag index fe04ee0e2..12c1bee91 100644 --- a/src/web/app/desktop/tags/home-widgets/rss-reader.tag +++ b/src/web/app/desktop/tags/home-widgets/rss-reader.tag @@ -86,7 +86,9 @@ }); this.fetch = () => { - fetch(`https://api.rss2json.com/v1/api.json?rss_url=${this.url}`).then(res => { + fetch(`https://api.rss2json.com/v1/api.json?rss_url=${this.url}`, { + cache: 'no-cache' + }).then(res => { res.json().then(feed => { this.update({ initializing: false, From 908c1dc7d607fbba99b5455db428fe47638065cf Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 27 Nov 2017 22:00:48 +0900 Subject: [PATCH 03/20] Cache --- src/web/app/sw.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/web/app/sw.js b/src/web/app/sw.js index a7c84d022..1b3220d23 100644 --- a/src/web/app/sw.js +++ b/src/web/app/sw.js @@ -4,9 +4,39 @@ import composeNotification from './common/scripts/compose-notification'; +// キャッシュするリソース +const cachee = [ + '/' +]; + // インストールされたとき -self.addEventListener('install', () => { +self.addEventListener('install', ev => { console.info('installed'); + + // Cache + ev.waitUntil(caches.open(_VERSION_).then(cache => cache.addAll(cachee))); +}); + +// アクティベートされたとき +self.addEventListener('activate', ev => { + // Clean up old caches + ev.waitUntil( + caches.keys().then(keys => Promise.all( + keys + .filter(key => key != _VERSION_) + .map(key => caches.delete(key)) + )) + ); +}); + +// リクエストが発生したとき +self.addEventListener('fetch', ev => { + ev.respondWith( + // キャッシュがあるか確認してあればそれを返す + caches.match(ev.request).then(response => + response || fetch(ev.request) + ) + ); }); // プッシュ通知を受け取ったとき From 8c2c411cba7aab0ee56970bbec3a1280ba0819d5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 27 Nov 2017 22:01:30 +0900 Subject: [PATCH 04/20] v3212 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dbd7797e..7bb857896 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +3212 (2017/11/27) +----------------- +* なんか + 3201 (2017/11/23) ----------------- * Twitterログインを実装 (#939) diff --git a/package.json b/package.json index b39cbbd47..3200b457c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.3201", + "version": "0.0.3212", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From 7686fd68a759d5a8b04c5c90c54a65fb7e249aa0 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 27 Nov 2017 18:03:43 +0000 Subject: [PATCH 05/20] fix(package): update @types/elasticsearch to version 5.0.18 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3200b457c..8b6769b52 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@types/cors": "2.8.3", "@types/debug": "0.0.30", "@types/deep-equal": "1.0.1", - "@types/elasticsearch": "5.0.17", + "@types/elasticsearch": "5.0.18", "@types/event-stream": "3.3.33", "@types/eventemitter3": "2.0.2", "@types/express": "4.0.39", From 0dcd9047dca5c5d18b51baa27476ed72c67e2fd1 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 27 Nov 2017 19:14:20 +0000 Subject: [PATCH 06/20] fix(package): update typescript to version 2.6.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3200b457c..6a8247c78 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "tmp": "0.0.33", "ts-node": "3.3.0", "tslint": "5.8.0", - "typescript": "2.6.1", + "typescript": "2.6.2", "uglify-es": "3.2.0", "uglifyjs-webpack-plugin": "1.1.1", "uuid": "3.1.0", From 08c7f8bb4bb85e84a9dd202f7b016bd5081b33f5 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Tue, 28 Nov 2017 00:43:33 +0000 Subject: [PATCH 07/20] fix(package): update @types/chai to version 4.0.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3200b457c..97697ee11 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@prezzemolo/zip": "0.0.3", "@types/bcryptjs": "2.4.1", "@types/body-parser": "1.16.8", - "@types/chai": "4.0.5", + "@types/chai": "4.0.6", "@types/chai-http": "3.0.3", "@types/compression": "0.0.35", "@types/cookie": "0.3.1", From a7ad1b9d483baa3b830fc17cfb94bcd8405e501e Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 14:07:00 +0900 Subject: [PATCH 08/20] Send 404 status correctly --- src/web/server.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/web/server.ts b/src/web/server.ts index d8a471329..e368d3e62 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -39,6 +39,9 @@ app.get('/apple-touch-icon.png', (req, res) => res.sendFile(`${__dirname}/assets app.use('/assets', express.static(`${__dirname}/assets`, { maxAge: ms('7 days') })); +app.use('/assets', (req, res) => { + res.sendStatus(404); +}); /** * ServiceWroker From 2dc053f1a04f51863359b03379213e2d7795f046 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 14:57:02 +0900 Subject: [PATCH 09/20] Fix bug --- src/api/endpoints/meta.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/endpoints/meta.ts b/src/api/endpoints/meta.ts index e27ca39e7..1370ead3c 100644 --- a/src/api/endpoints/meta.ts +++ b/src/api/endpoints/meta.ts @@ -45,7 +45,7 @@ module.exports = (params) => new Promise(async (res, rej) => { res({ maintainer: config.maintainer, version: version, - secure: config.https.enable, + secure: config.https != null, machine: os.hostname(), os: os.platform(), node: process.version, From d1ffd3b68fef593b98ebaba2fa95d95b51ad81e3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 15:05:55 +0900 Subject: [PATCH 10/20] :v: --- src/web/app/boot.js | 27 +++++++++++++++++++++++++++ src/web/app/common/scripts/api.ts | 3 ++- src/web/app/init.ts | 4 ++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/web/app/boot.js b/src/web/app/boot.js index 4a8ea030a..a5f0e04d3 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -69,4 +69,31 @@ script.setAttribute('async', 'true'); script.setAttribute('defer', 'true'); head.appendChild(script); + + // 1秒経ってもスクリプトがロードされない場合はバージョンが古くて + // 404になっているせいかもしれないので、バージョンを確認して古ければ更新する + // + // 読み込まれたスクリプトからこのタイマーを解除できるように、 + // グローバルにタイマーIDを代入しておく + window.mkBootTimer = window.setTimeout(async () => { + // Fetch meta + const res = await fetch(API + '/meta', { + method: 'POST', + cache: 'no-cache' + }); + + // Parse + const meta = await res.json(); + + // Compare versions + if (meta.version != VERSION) { + alert( + 'Misskeyの新しいバージョンがあります。ページを再度読み込みします。' + + '\n\n' + + 'New version of Misskey available. The page will be reloaded.'); + + // Force reload + location.reload(true); + } + }, 1000); } diff --git a/src/web/app/common/scripts/api.ts b/src/web/app/common/scripts/api.ts index e62447b0a..2008e6f5a 100644 --- a/src/web/app/common/scripts/api.ts +++ b/src/web/app/common/scripts/api.ts @@ -29,7 +29,8 @@ export default (i, endpoint, data = {}): Promise<{ [x: string]: any }> => { fetch(endpoint.indexOf('://') > -1 ? endpoint : `${_API_URL_}/${endpoint}`, { method: 'POST', body: JSON.stringify(data), - credentials: endpoint === 'signin' ? 'include' : 'omit' + credentials: endpoint === 'signin' ? 'include' : 'omit', + cache: 'no-cache' }).then(res => { if (--pending === 0) spinner.parentNode.removeChild(spinner); if (res.status === 200) { diff --git a/src/web/app/init.ts b/src/web/app/init.ts index 79be1d368..154b1ba0f 100644 --- a/src/web/app/init.ts +++ b/src/web/app/init.ts @@ -19,6 +19,10 @@ require('./common/tags'); console.info(`Misskey v${_VERSION_} (葵 aoi)`); +// BootTimer解除 +window.clearTimeout((window as any).mkBootTimer); +delete (window as any).mkBootTimer; + if (_HOST_ != 'localhost') { document.domain = _HOST_; } From 548937022388d149192bd5a400bef3942da5b0b0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 15:09:58 +0900 Subject: [PATCH 11/20] Force service worker activate --- src/web/app/sw.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/web/app/sw.js b/src/web/app/sw.js index 1b3220d23..2074ee39c 100644 --- a/src/web/app/sw.js +++ b/src/web/app/sw.js @@ -13,8 +13,10 @@ const cachee = [ self.addEventListener('install', ev => { console.info('installed'); - // Cache - ev.waitUntil(caches.open(_VERSION_).then(cache => cache.addAll(cachee))); + ev.waitUntil(Promise.all([ + self.skipWaiting(), // Force activate + caches.open(_VERSION_).then(cache => cache.addAll(cachee)) // Cache + ])); }); // アクティベートされたとき From 8c4f9aa7b0416e3c50220e82425701f4a5364742 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 15:41:41 +0900 Subject: [PATCH 12/20] :v: --- src/web/app/boot.js | 7 +++++++ src/web/app/sw.js | 6 ++++++ src/web/assets/help.js | 8 ++++++++ src/web/server.ts | 1 + 4 files changed, 22 insertions(+) create mode 100644 src/web/assets/help.js diff --git a/src/web/app/boot.js b/src/web/app/boot.js index a5f0e04d3..0a3154ad8 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -92,6 +92,13 @@ '\n\n' + 'New version of Misskey available. The page will be reloaded.'); + // Clear cache (serive worker) + try { + navigator.serviceWorker.controller.postMessage('clear'); + } catch (e) { + console.error(e); + } + // Force reload location.reload(true); } diff --git a/src/web/app/sw.js b/src/web/app/sw.js index 2074ee39c..669703b16 100644 --- a/src/web/app/sw.js +++ b/src/web/app/sw.js @@ -63,3 +63,9 @@ self.addEventListener('push', ev => { }); })); }); + +self.addEventListener('message', ev => { + if (ev.data == 'clear') { + caches.keys().then(keys => keys.forEach(key => caches.delete(key))); + } +}); diff --git a/src/web/assets/help.js b/src/web/assets/help.js new file mode 100644 index 000000000..475c50678 --- /dev/null +++ b/src/web/assets/help.js @@ -0,0 +1,8 @@ +const yn = window.confirm( + 'サーバー上に存在しないスクリプトがリクエストされました。お使いのMisskeyのバージョンが古いことが原因の可能性があります。Misskeyを更新しますか?'); + +if (yn) { + location.reload(true); +} else { + alert('問題が解決しない場合はサーバー管理者までお問い合せください。'); +} diff --git a/src/web/server.ts b/src/web/server.ts index e368d3e62..791b75ce0 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -39,6 +39,7 @@ app.get('/apple-touch-icon.png', (req, res) => res.sendFile(`${__dirname}/assets app.use('/assets', express.static(`${__dirname}/assets`, { maxAge: ms('7 days') })); +app.use('/assets/*.js', (req, res) => res.sendFile(`${__dirname}/assets/help.js`)); app.use('/assets', (req, res) => { res.sendStatus(404); }); From 0bcd54d2d97f4751fbd26a08b12c87bad0e97049 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 15:43:17 +0900 Subject: [PATCH 13/20] :v: --- src/web/app/common/scripts/check-for-update.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/web/app/common/scripts/check-for-update.ts b/src/web/app/common/scripts/check-for-update.ts index c447a517f..154092451 100644 --- a/src/web/app/common/scripts/check-for-update.ts +++ b/src/web/app/common/scripts/check-for-update.ts @@ -7,6 +7,14 @@ export default async function(mios: MiOS) { if (meta.version != _VERSION_) { localStorage.setItem('should-refresh', 'true'); + + // Clear cache (serive worker) + try { + navigator.serviceWorker.controller.postMessage('clear'); + } catch (e) { + console.error(e); + } + alert('%i18n:common.update-available%'.replace('{newer}', meta.version).replace('{current}', _VERSION_)); } } From a71f65e6d1c3a56a15b6cda40381034bdcf4b233 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 15:44:45 +0900 Subject: [PATCH 14/20] v3219 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bb857896..155e40371 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +3219 (2017/11/28) +----------------- +* なんか + 3212 (2017/11/27) ----------------- * なんか diff --git a/package.json b/package.json index 3200b457c..726016740 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.3212", + "version": "0.0.3219", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", From a997df6c8ed6a72b2e814ad6c73feda02ac536df Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 16:10:31 +0900 Subject: [PATCH 15/20] Fix #952 --- src/web/assets/{help.js => 404.js} | 7 +++++++ src/web/assets/recover.html | 32 ++++++++++++++++++++++++++++++ src/web/server.ts | 4 +++- 3 files changed, 42 insertions(+), 1 deletion(-) rename src/web/assets/{help.js => 404.js} (73%) create mode 100644 src/web/assets/recover.html diff --git a/src/web/assets/help.js b/src/web/assets/404.js similarity index 73% rename from src/web/assets/help.js rename to src/web/assets/404.js index 475c50678..46fd004f1 100644 --- a/src/web/assets/help.js +++ b/src/web/assets/404.js @@ -2,6 +2,13 @@ const yn = window.confirm( 'サーバー上に存在しないスクリプトがリクエストされました。お使いのMisskeyのバージョンが古いことが原因の可能性があります。Misskeyを更新しますか?'); if (yn) { + // Clear cache (serive worker) + try { + navigator.serviceWorker.controller.postMessage('clear'); + } catch (e) { + console.error(e); + } + location.reload(true); } else { alert('問題が解決しない場合はサーバー管理者までお問い合せください。'); diff --git a/src/web/assets/recover.html b/src/web/assets/recover.html new file mode 100644 index 000000000..8042d438c --- /dev/null +++ b/src/web/assets/recover.html @@ -0,0 +1,32 @@ + + + + + + Misskeyのリカバリ + + + diff --git a/src/web/server.ts b/src/web/server.ts index 791b75ce0..1d3687f89 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -39,11 +39,13 @@ app.get('/apple-touch-icon.png', (req, res) => res.sendFile(`${__dirname}/assets app.use('/assets', express.static(`${__dirname}/assets`, { maxAge: ms('7 days') })); -app.use('/assets/*.js', (req, res) => res.sendFile(`${__dirname}/assets/help.js`)); +app.use('/assets/*.js', (req, res) => res.sendFile(`${__dirname}/assets/404.js`)); app.use('/assets', (req, res) => { res.sendStatus(404); }); +app.use('/recover', (req, res) => res.sendFile(`${__dirname}/assets/recover.html`)); + /** * ServiceWroker */ From ff20c19aa933e71cec1baae47f9e4863fe849401 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 16:11:57 +0900 Subject: [PATCH 16/20] :v: --- src/web/assets/recover.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/web/assets/recover.html b/src/web/assets/recover.html index 8042d438c..91c0141fa 100644 --- a/src/web/assets/recover.html +++ b/src/web/assets/recover.html @@ -23,6 +23,8 @@ localStorage.setItem('should-refresh', 'true'); alert('キャッシュをクリアしました。'); + + location.href = '/'; } else { alert('問題が解決しない場合はサーバー管理者までお問い合せください。'); } From edeca244359f67f8548c17f6d87bb61c4734e61e Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 28 Nov 2017 16:31:50 +0900 Subject: [PATCH 17/20] typo --- src/web/assets/recover.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/assets/recover.html b/src/web/assets/recover.html index 91c0141fa..019f57b2e 100644 --- a/src/web/assets/recover.html +++ b/src/web/assets/recover.html @@ -6,7 +6,7 @@ Misskeyのリカバリ