From 6b7f8b151e7a0a172dc046874f83730aeb6e5a9c 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 7d302279e0..b39cbbd47e 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 9a9124c6ea02696e251069491de2ed266746c5f2 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 fe04ee0e20..12c1bee91e 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 c79aa36c63c4a3bdae66464c32db8fd62424d913 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 a7c84d022a..1b3220d23d 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 30adc590a411a33488b8b791d2903a29e97e2c4b 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 7dbd7797e9..7bb8578961 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 b39cbbd47e..3200b457c2 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 f82c4e533ab0d5678f97b7c384924f5935375810 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 3200b457c2..8b6769b52c 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 183e6ba0cd2cdc30ad5611ca3733da983a760b70 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 3200b457c2..6a8247c78b 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 706bb550b3517ddda00e8757aec9171eec565e2e 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 3200b457c2..97697ee11d 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 66e76d9aa271415fb272822a1092224a07d455ec 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 d8a4713290..e368d3e62d 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 5f4f046cd6c45dc770981397f50b0b00cee66527 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 e27ca39e7e..1370ead3c5 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 607836331103cae089487e4d517f3de5c02ed1bc 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 4a8ea030a1..a5f0e04d31 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 e62447b0a0..2008e6f5ac 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 79be1d3687..154b1ba0f0 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 10c943d28aca42f8540eadd9dc173e864b7d1741 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 1b3220d23d..2074ee39c4 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 305a620aed181302907dca884aa69caf12769ed2 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 a5f0e04d31..0a3154ad88 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 2074ee39c4..669703b16c 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 0000000000..475c506789 --- /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 e368d3e62d..791b75ce09 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 8ed4e5422b6f7711b20c4ac032affac06617c3fa 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 c447a517fa..1540924510 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 94434bd69ee7e540df355f17f6d6f36256671afe 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 7bb8578961..155e403715 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 3200b457c2..7260167403 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 c157644110b68de7c05882e6645495db7bfa5fc6 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 475c506789..46fd004f14 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 0000000000..8042d438c4 --- /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 791b75ce09..1d3687f89e 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 4b3a804d45b02b640c136863367cbc880088c3e7 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 8042d438c4..91c0141fa6 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 cbfdbe2dec316eec661304ff8be3dccb915ab587 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 91c0141fa6..019f57b2e7 100644 --- a/src/web/assets/recover.html +++ b/src/web/assets/recover.html @@ -6,7 +6,7 @@ Misskeyのリカバリ