From 95721a2f0aafe022d330d0828e3fd0e16dacca62 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 09:10:05 +0900 Subject: [PATCH 01/43] wip --- src/api/models/access-token.ts | 18 +++++-- src/api/models/app.ts | 20 ++++--- src/api/models/appdata.ts | 3 -- src/api/models/auth-session.ts | 9 ++-- src/api/models/channel-watching.ts | 13 ++++- src/api/models/channel.ts | 11 ++-- src/api/models/drive-file.ts | 14 ++--- src/api/models/drive-folder.ts | 14 ++--- src/api/models/drive-tag.ts | 3 -- src/api/models/favorite.ts | 11 +++- src/api/models/following.ts | 12 ++++- tools/migration/shell.camel-case.js | 81 +++++++++++++++++++++++++++++ 12 files changed, 166 insertions(+), 43 deletions(-) delete mode 100644 src/api/models/appdata.ts delete mode 100644 src/api/models/drive-tag.ts create mode 100644 tools/migration/shell.camel-case.js diff --git a/src/api/models/access-token.ts b/src/api/models/access-token.ts index 9985be501..9e1cb6474 100644 --- a/src/api/models/access-token.ts +++ b/src/api/models/access-token.ts @@ -1,8 +1,16 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -const collection = db.get('access_tokens'); +const AccessToken = db.get('accessTokens'); +AccessToken.createIndex('token'); +AccessToken.createIndex('hash'); +export default AccessToken; -(collection as any).createIndex('token'); // fuck type definition -(collection as any).createIndex('hash'); // fuck type definition - -export default collection as any; // fuck type definition +export type IAccessTokens = { + _id: mongo.ObjectID; + createdAt: Date; + appId: mongo.ObjectID; + userId: mongo.ObjectID; + token: string; + hash: string; +}; diff --git a/src/api/models/app.ts b/src/api/models/app.ts index 34e9867db..20af049b2 100644 --- a/src/api/models/app.ts +++ b/src/api/models/app.ts @@ -5,16 +5,22 @@ import db from '../../db/mongodb'; import config from '../../conf'; const App = db.get('apps'); -App.createIndex('name_id'); -App.createIndex('name_id_lower'); +App.createIndex('nameId'); +App.createIndex('nameIdLower'); App.createIndex('secret'); export default App; export type IApp = { _id: mongo.ObjectID; - created_at: Date; - user_id: mongo.ObjectID; + createdAt: Date; + userId: mongo.ObjectID; secret: string; + name: string; + nameId: string; + nameIdLower: string; + description: string; + permission: string; + callbackUrl: string; }; export function isValidNameId(nameId: string): boolean { @@ -70,7 +76,7 @@ export const pack = ( _app.id = _app._id; delete _app._id; - delete _app.name_id_lower; + delete _app.nameIdLower; // Visible by only owner if (!opts.includeSecret) { @@ -84,8 +90,8 @@ export const pack = ( if (me) { // 既に連携しているか const exist = await AccessToken.count({ - app_id: _app.id, - user_id: me, + appId: _app.id, + userId: me, }, { limit: 1 }); diff --git a/src/api/models/appdata.ts b/src/api/models/appdata.ts deleted file mode 100644 index 3e68354fa..000000000 --- a/src/api/models/appdata.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('appdata') as any; // fuck type definition diff --git a/src/api/models/auth-session.ts b/src/api/models/auth-session.ts index 997ec61c2..e6b8b2318 100644 --- a/src/api/models/auth-session.ts +++ b/src/api/models/auth-session.ts @@ -3,11 +3,15 @@ import deepcopy = require('deepcopy'); import db from '../../db/mongodb'; import { pack as packApp } from './app'; -const AuthSession = db.get('auth_sessions'); +const AuthSession = db.get('authSessions'); export default AuthSession; export interface IAuthSession { _id: mongo.ObjectID; + createdAt: Date; + appId: mongo.ObjectID; + userId: mongo.ObjectID; + token: string; } /** @@ -24,7 +28,6 @@ export const pack = ( let _session: any; // TODO: Populate session if it ID - _session = deepcopy(session); // Me @@ -39,7 +42,7 @@ export const pack = ( delete _session._id; // Populate app - _session.app = await packApp(_session.app_id, me); + _session.app = await packApp(_session.appId, me); resolve(_session); }); diff --git a/src/api/models/channel-watching.ts b/src/api/models/channel-watching.ts index 6184ae408..23886d0c7 100644 --- a/src/api/models/channel-watching.ts +++ b/src/api/models/channel-watching.ts @@ -1,3 +1,14 @@ +import * as mongo from 'mongodb'; + import db from '../../db/mongodb'; -export default db.get('channel_watching') as any; // fuck type definition +const ChannelWatching = db.get('channelWatching'); +export default ChannelWatching; + +export interface IChannelWatching { + _id: mongo.ObjectID; + createdAt: Date; + deletedAt: Date; + channel_id: mongo.ObjectID; + userId: mongo.ObjectID; +} diff --git a/src/api/models/channel.ts b/src/api/models/channel.ts index 815d53593..a753a4eba 100644 --- a/src/api/models/channel.ts +++ b/src/api/models/channel.ts @@ -9,10 +9,11 @@ export default Channel; export type IChannel = { _id: mongo.ObjectID; - created_at: Date; + createdAt: Date; title: string; - user_id: mongo.ObjectID; + userId: mongo.ObjectID; index: number; + watchingCount: number; }; /** @@ -47,7 +48,7 @@ export const pack = ( delete _channel._id; // Remove needless properties - delete _channel.user_id; + delete _channel.userId; // Me const meId: mongo.ObjectID = me @@ -61,9 +62,9 @@ export const pack = ( if (me) { //#region Watchしているかどうか const watch = await Watching.findOne({ - user_id: meId, + userId: meId, channel_id: _channel.id, - deleted_at: { $exists: false } + deletedAt: { $exists: false } }); _channel.is_watching = watch !== null; diff --git a/src/api/models/drive-file.ts b/src/api/models/drive-file.ts index 2a46d8dc4..b0e4d1db0 100644 --- a/src/api/models/drive-file.ts +++ b/src/api/models/drive-file.ts @@ -4,14 +4,14 @@ import { pack as packFolder } from './drive-folder'; import config from '../../conf'; import monkDb, { nativeDbConn } from '../../db/mongodb'; -const DriveFile = monkDb.get('drive_files.files'); +const DriveFile = monkDb.get('driveFiles.files'); export default DriveFile; const getGridFSBucket = async (): Promise => { const db = await nativeDbConn(); const bucket = new mongodb.GridFSBucket(db, { - bucketName: 'drive_files' + bucketName: 'driveFiles' }); return bucket; }; @@ -26,8 +26,8 @@ export type IDriveFile = { contentType: string; metadata: { properties: any; - user_id: mongodb.ObjectID; - folder_id: mongodb.ObjectID; + userId: mongodb.ObjectID; + folderId: mongodb.ObjectID; } }; @@ -79,7 +79,7 @@ export const pack = ( let _target: any = {}; _target.id = _file._id; - _target.created_at = _file.uploadDate; + _target.createdAt = _file.uploadDate; _target.name = _file.filename; _target.type = _file.contentType; _target.datasize = _file.length; @@ -92,9 +92,9 @@ export const pack = ( if (_target.properties == null) _target.properties = {}; if (opts.detail) { - if (_target.folder_id) { + if (_target.folderId) { // Populate folder - _target.folder = await packFolder(_target.folder_id, { + _target.folder = await packFolder(_target.folderId, { detail: true }); } diff --git a/src/api/models/drive-folder.ts b/src/api/models/drive-folder.ts index 54b45049b..52f784e06 100644 --- a/src/api/models/drive-folder.ts +++ b/src/api/models/drive-folder.ts @@ -8,10 +8,10 @@ export default DriveFolder; export type IDriveFolder = { _id: mongo.ObjectID; - created_at: Date; + createdAt: Date; name: string; - user_id: mongo.ObjectID; - parent_id: mongo.ObjectID; + userId: mongo.ObjectID; + parentId: mongo.ObjectID; }; export function isValidFolderName(name: string): boolean { @@ -55,20 +55,20 @@ export const pack = ( if (opts.detail) { const childFoldersCount = await DriveFolder.count({ - parent_id: _folder.id + parentId: _folder.id }); const childFilesCount = await DriveFile.count({ - 'metadata.folder_id': _folder.id + 'metadata.folderId': _folder.id }); _folder.folders_count = childFoldersCount; _folder.files_count = childFilesCount; } - if (opts.detail && _folder.parent_id) { + if (opts.detail && _folder.parentId) { // Populate parent folder - _folder.parent = await pack(_folder.parent_id, { + _folder.parent = await pack(_folder.parentId, { detail: true }); } diff --git a/src/api/models/drive-tag.ts b/src/api/models/drive-tag.ts deleted file mode 100644 index 991c935e8..000000000 --- a/src/api/models/drive-tag.ts +++ /dev/null @@ -1,3 +0,0 @@ -import db from '../../db/mongodb'; - -export default db.get('drive_tags') as any; // fuck type definition diff --git a/src/api/models/favorite.ts b/src/api/models/favorite.ts index e01d9e343..5ba55c4c9 100644 --- a/src/api/models/favorite.ts +++ b/src/api/models/favorite.ts @@ -1,3 +1,12 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -export default db.get('favorites') as any; // fuck type definition +const Favorites = db.get('favorites'); +export default Favorites; + +export type IFavorites = { + _id: mongo.ObjectID; + createdAt: Date; + userId: mongo.ObjectID; + postId: mongo.ObjectID; +}; diff --git a/src/api/models/following.ts b/src/api/models/following.ts index cb3db9b53..1163bf6b3 100644 --- a/src/api/models/following.ts +++ b/src/api/models/following.ts @@ -1,3 +1,13 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -export default db.get('following') as any; // fuck type definition +const Following = db.get('following'); +export default Following; + +export type IFollowing = { + _id: mongo.ObjectID; + createdAt: Date; + deletedAt: Date; + followeeId: mongo.ObjectID; + followerId: mongo.ObjectID; +}; diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js new file mode 100644 index 000000000..6d6b01a07 --- /dev/null +++ b/tools/migration/shell.camel-case.js @@ -0,0 +1,81 @@ +db.access_tokens.renameCollection('accessTokens'); +db.accessTokens.update({}, { + $rename: { + created_at: 'createdAt', + app_id: 'appId', + user_id: 'userId', + } +}, false, true); + +db.apps.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + name_id: 'nameId', + name_id_lower: 'nameIdLower', + callback_url: 'callbackUrl', + } +}, false, true); + +db.auth_sessions.renameCollection('authSessions'); +db.authSessions.update({}, { + $rename: { + created_at: 'createdAt', + app_id: 'appId', + user_id: 'userId', + } +}, false, true); + +db.channel_watching.renameCollection('channelWatching'); +db.channelWatching.update({}, { + $rename: { + created_at: 'createdAt', + deleted_at: 'deletedAt', + channel_id: 'channelId', + user_id: 'userId', + } +}, false, true); + +db.channels.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + watching_count: 'watchingCount' + } +}, false, true); + +db.drive_files.files.renameCollection('driveFiles.files'); +db.drive_files.chunks.renameCollection('driveFiles.chunks'); +db.driveFiles.files.update({}, { + $rename: { + 'metadata.user_id': 'metadata.userId', + 'metadata.folder_id': 'metadata.folderId', + 'metadata.properties.average_color': 'metadata.properties.avgColor' + } +}, false, true); + +db.drive_folders.renameCollection('driveFolders'); +db.driveFolders.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + parent_id: 'parentId', + } +}, false, true); + +db.favorites.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + post_id: 'postId', + } +}, false, true); + +db.following.update({}, { + $rename: { + created_at: 'createdAt', + deleted_at: 'deletedAt', + followee_id: 'followeeId', + follower_id: 'followerId', + } +}, false, true); From af192f8ab14ffc26b493a8c2b26648e1be063fe5 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 09:15:58 +0900 Subject: [PATCH 02/43] Update dependencies :rocket: --- package.json | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index d9ed80b47..4e3da7d0b 100644 --- a/package.json +++ b/package.json @@ -44,11 +44,11 @@ "@types/express": "4.11.1", "@types/gm": "1.17.33", "@types/gulp": "3.8.36", - "@types/gulp-htmlmin": "1.3.31", - "@types/gulp-mocha": "0.0.31", + "@types/gulp-htmlmin": "1.3.32", + "@types/gulp-mocha": "0.0.32", "@types/gulp-rename": "0.0.33", "@types/gulp-replace": "0.0.31", - "@types/gulp-uglify": "3.0.4", + "@types/gulp-uglify": "3.0.5", "@types/gulp-util": "3.0.34", "@types/inquirer": "0.0.38", "@types/is-root": "1.0.0", @@ -56,13 +56,13 @@ "@types/js-yaml": "3.10.1", "@types/license-checker": "15.0.0", "@types/mkdirp": "0.5.2", - "@types/mocha": "2.2.48", - "@types/mongodb": "3.0.8", + "@types/mocha": "5.0.0", + "@types/mongodb": "3.0.9", "@types/monk": "6.0.0", "@types/morgan": "1.7.35", "@types/ms": "0.7.30", "@types/multer": "1.3.6", - "@types/node": "9.4.7", + "@types/node": "9.6.0", "@types/proxy-addr": "2.0.0", "@types/pug": "2.0.4", "@types/qrcode": "0.8.1", @@ -76,13 +76,13 @@ "@types/speakeasy": "2.0.2", "@types/tmp": "0.0.33", "@types/uuid": "3.4.3", - "@types/webpack": "4.1.1", + "@types/webpack": "4.1.2", "@types/webpack-stream": "3.2.10", "@types/websocket": "0.0.38", "@types/ws": "4.0.1", "accesses": "2.5.0", "animejs": "2.2.0", - "autosize": "4.0.0", + "autosize": "4.0.1", "autwh": "0.0.1", "bcryptjs": "2.4.3", "body-parser": "1.18.2", @@ -114,7 +114,7 @@ "fuckadblock": "3.2.1", "gm": "1.23.1", "gulp": "3.9.1", - "gulp-cssnano": "2.1.2", + "gulp-cssnano": "2.1.3", "gulp-htmlmin": "4.0.0", "gulp-imagemin": "4.1.0", "gulp-mocha": "5.0.0", @@ -130,25 +130,25 @@ "hard-source-webpack-plugin": "0.6.4", "highlight.js": "9.12.0", "html-minifier": "3.5.12", - "inquirer": "5.1.0", + "inquirer": "5.2.0", "is-root": "2.0.0", - "is-url": "1.2.3", + "is-url": "1.2.4", "js-yaml": "3.11.0", - "jsdom": "^11.6.2", + "jsdom": "11.6.2", "license-checker": "18.0.0", "loader-utils": "1.1.0", "mecab-async": "0.1.2", "mkdirp": "0.5.1", - "mocha": "5.0.4", + "mocha": "5.0.5", "moji": "0.5.1", - "mongodb": "3.0.4", + "mongodb": "3.0.5", "monk": "6.0.5", "morgan": "1.9.0", "ms": "2.1.1", "multer": "1.3.0", - "nan": "^2.10.0", - "node-sass": "4.7.2", - "node-sass-json-importer": "3.1.5", + "nan": "2.10.0", + "node-sass": "4.8.3", + "node-sass-json-importer": "3.1.6", "nprogress": "0.2.0", "object-assign-deep": "0.3.1", "on-build-webpack": "0.1.0", @@ -157,7 +157,7 @@ "prominence": "0.2.0", "proxy-addr": "2.0.3", "pug": "2.0.3", - "punycode": "^2.1.0", + "punycode": "2.1.0", "qrcode": "1.2.0", "ratelimiter": "3.0.3", "recaptcha-promise": "0.1.3", @@ -181,10 +181,10 @@ "tcp-port-used": "0.1.2", "textarea-caret": "3.1.0", "tmp": "0.0.33", - "ts-loader": "4.0.1", + "ts-loader": "4.1.0", "ts-node": "5.0.1", "tslint": "5.9.1", - "typescript": "2.7.2", + "typescript": "2.8.1", "typescript-eslint-parser": "14.0.0", "uglify-es": "3.3.9", "url-loader": "1.0.1", @@ -195,13 +195,13 @@ "vue-cropperjs": "2.2.0", "vue-js-modal": "1.3.12", "vue-json-tree-view": "2.1.3", - "vue-loader": "14.2.1", + "vue-loader": "14.2.2", "vue-router": "3.0.1", "vue-template-compiler": "2.5.16", "vuedraggable": "2.16.0", "web-push": "3.3.0", - "webfinger.js": "^2.6.6", - "webpack": "4.2.0", + "webfinger.js": "2.6.6", + "webpack": "4.3.0", "webpack-cli": "2.0.13", "webpack-replace-loader": "1.3.0", "websocket": "1.0.25", From a1bc0e6769b8a447653cd13a9a320fd7579c55a3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 09:27:57 +0900 Subject: [PATCH 03/43] Prepare new codename --- package.json | 1 + src/index.ts | 1 - src/web/app/common/views/widgets/version.vue | 7 ++++--- src/web/app/config.ts | 4 ++-- src/web/app/init.ts | 4 ++-- src/web/app/mobile/views/pages/settings.vue | 7 ++++--- swagger.js | 6 +++--- webpack.config.ts | 3 ++- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 4e3da7d0b..3f9e49738 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "misskey", "author": "syuilo ", "version": "0.0.4224", + "codename": "nighthike", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", diff --git a/src/index.ts b/src/index.ts index 218455d6f..a8181acda 100644 --- a/src/index.ts +++ b/src/index.ts @@ -89,7 +89,6 @@ function workerMain() { */ async function init(): Promise { Logger.info('Welcome to Misskey!'); - Logger.info(chalk.bold('Misskey ')); Logger.info('Initializing...'); EnvironmentInfo.show(); diff --git a/src/web/app/common/views/widgets/version.vue b/src/web/app/common/views/widgets/version.vue index 5072d9b74..30b632b39 100644 --- a/src/web/app/common/views/widgets/version.vue +++ b/src/web/app/common/views/widgets/version.vue @@ -1,16 +1,17 @@