summaryrefslogtreecommitdiff
path: root/src/api/models
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2018-04-11 20:27:09 +0900
committerGitHub <noreply@github.com>2018-04-11 20:27:09 +0900
commitd43fe853c3605696e2e57e240845d0fc9c284f61 (patch)
tree838914e262c0fca5737588a7bba64e2b9f3d8e5f /src/api/models
parentUpdate README.md (diff)
parentwip #1443 (diff)
downloadmisskey-d43fe853c3605696e2e57e240845d0fc9c284f61.tar.gz
misskey-d43fe853c3605696e2e57e240845d0fc9c284f61.tar.bz2
misskey-d43fe853c3605696e2e57e240845d0fc9c284f61.zip
Merge pull request #1 from syuilo/master
追従
Diffstat (limited to 'src/api/models')
-rw-r--r--src/api/models/access-token.ts8
-rw-r--r--src/api/models/app.ts13
-rw-r--r--src/api/models/appdata.ts3
-rw-r--r--src/api/models/auth-session.ts3
-rw-r--r--src/api/models/channel-watching.ts3
-rw-r--r--src/api/models/channel.ts14
-rw-r--r--src/api/models/drive-file.ts26
-rw-r--r--src/api/models/drive-folder.ts10
-rw-r--r--src/api/models/drive-tag.ts3
-rw-r--r--src/api/models/favorite.ts3
-rw-r--r--src/api/models/following.ts3
-rw-r--r--src/api/models/messaging-history.ts3
-rw-r--r--src/api/models/messaging-message.ts12
-rw-r--r--src/api/models/meta.ts7
-rw-r--r--src/api/models/notification.ts47
-rw-r--r--src/api/models/poll-vote.ts3
-rw-r--r--src/api/models/post-reaction.ts3
-rw-r--r--src/api/models/post-watching.ts3
-rw-r--r--src/api/models/post.ts22
-rw-r--r--src/api/models/signin.ts3
-rw-r--r--src/api/models/sw-subscription.ts3
-rw-r--r--src/api/models/user.ts85
22 files changed, 0 insertions, 280 deletions
diff --git a/src/api/models/access-token.ts b/src/api/models/access-token.ts
deleted file mode 100644
index 9985be5013..0000000000
--- a/src/api/models/access-token.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import db from '../../db/mongodb';
-
-const collection = db.get('access_tokens');
-
-(collection as any).createIndex('token'); // fuck type definition
-(collection as any).createIndex('hash'); // fuck type definition
-
-export default collection as any; // fuck type definition
diff --git a/src/api/models/app.ts b/src/api/models/app.ts
deleted file mode 100644
index 68f2f448b0..0000000000
--- a/src/api/models/app.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import db from '../../db/mongodb';
-
-const collection = db.get('apps');
-
-(collection as any).createIndex('name_id'); // fuck type definition
-(collection as any).createIndex('name_id_lower'); // fuck type definition
-(collection as any).createIndex('secret'); // fuck type definition
-
-export default collection as any; // fuck type definition
-
-export function isValidNameId(nameId: string): boolean {
- return typeof nameId == 'string' && /^[a-zA-Z0-9\-]{3,30}$/.test(nameId);
-}
diff --git a/src/api/models/appdata.ts b/src/api/models/appdata.ts
deleted file mode 100644
index 3e68354fa4..0000000000
--- 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
deleted file mode 100644
index b264a133e9..0000000000
--- a/src/api/models/auth-session.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('auth_sessions') as any; // fuck type definition
diff --git a/src/api/models/channel-watching.ts b/src/api/models/channel-watching.ts
deleted file mode 100644
index 6184ae408d..0000000000
--- a/src/api/models/channel-watching.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('channel_watching') as any; // fuck type definition
diff --git a/src/api/models/channel.ts b/src/api/models/channel.ts
deleted file mode 100644
index c80e84dbc8..0000000000
--- a/src/api/models/channel.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import * as mongo from 'mongodb';
-import db from '../../db/mongodb';
-
-const collection = db.get('channels');
-
-export default collection as any; // fuck type definition
-
-export type IChannel = {
- _id: mongo.ObjectID;
- created_at: Date;
- title: string;
- user_id: mongo.ObjectID;
- index: number;
-};
diff --git a/src/api/models/drive-file.ts b/src/api/models/drive-file.ts
deleted file mode 100644
index 802ee5a5fe..0000000000
--- a/src/api/models/drive-file.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import * as mongodb from 'mongodb';
-import monkDb, { nativeDbConn } from '../../db/mongodb';
-
-const collection = monkDb.get('drive_files.files');
-
-export default collection as any; // fuck type definition
-
-const getGridFSBucket = async (): Promise<mongodb.GridFSBucket> => {
- const db = await nativeDbConn();
- const bucket = new mongodb.GridFSBucket(db, {
- bucketName: 'drive_files'
- });
- return bucket;
-};
-
-export { getGridFSBucket };
-
-export function validateFileName(name: string): boolean {
- return (
- (name.trim().length > 0) &&
- (name.length <= 200) &&
- (name.indexOf('\\') === -1) &&
- (name.indexOf('/') === -1) &&
- (name.indexOf('..') === -1)
- );
-}
diff --git a/src/api/models/drive-folder.ts b/src/api/models/drive-folder.ts
deleted file mode 100644
index f81ffe855d..0000000000
--- a/src/api/models/drive-folder.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('drive_folders') as any; // fuck type definition
-
-export function isValidFolderName(name: string): boolean {
- return (
- (name.trim().length > 0) &&
- (name.length <= 200)
- );
-}
diff --git a/src/api/models/drive-tag.ts b/src/api/models/drive-tag.ts
deleted file mode 100644
index 991c935e81..0000000000
--- 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
deleted file mode 100644
index e01d9e343c..0000000000
--- a/src/api/models/favorite.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('favorites') as any; // fuck type definition
diff --git a/src/api/models/following.ts b/src/api/models/following.ts
deleted file mode 100644
index cb3db9b539..0000000000
--- a/src/api/models/following.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('following') as any; // fuck type definition
diff --git a/src/api/models/messaging-history.ts b/src/api/models/messaging-history.ts
deleted file mode 100644
index c06987e451..0000000000
--- a/src/api/models/messaging-history.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('messaging_histories') as any; // fuck type definition
diff --git a/src/api/models/messaging-message.ts b/src/api/models/messaging-message.ts
deleted file mode 100644
index 18afa57e44..0000000000
--- a/src/api/models/messaging-message.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import * as mongo from 'mongodb';
-import db from '../../db/mongodb';
-
-export default db.get('messaging_messages') as any; // fuck type definition
-
-export interface IMessagingMessage {
- _id: mongo.ObjectID;
-}
-
-export function isValidText(text: string): boolean {
- return text.length <= 1000 && text.trim() != '';
-}
diff --git a/src/api/models/meta.ts b/src/api/models/meta.ts
deleted file mode 100644
index c7dba8fcba..0000000000
--- a/src/api/models/meta.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('meta') as any; // fuck type definition
-
-export type IMeta = {
- top_image: string;
-};
diff --git a/src/api/models/notification.ts b/src/api/models/notification.ts
deleted file mode 100644
index e3dc6c70a3..0000000000
--- a/src/api/models/notification.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import * as mongo from 'mongodb';
-import db from '../../db/mongodb';
-import { IUser } from './user';
-
-export default db.get('notifications') as any; // fuck type definition
-
-export interface INotification {
- _id: mongo.ObjectID;
- created_at: Date;
-
- /**
- * 通知の受信者
- */
- notifiee?: IUser;
-
- /**
- * 通知の受信者
- */
- notifiee_id: mongo.ObjectID;
-
- /**
- * イニシエータ(initiator)、Origin。通知を行う原因となったユーザー
- */
- notifier?: IUser;
-
- /**
- * イニシエータ(initiator)、Origin。通知を行う原因となったユーザー
- */
- notifier_id: mongo.ObjectID;
-
- /**
- * 通知の種類。
- * follow - フォローされた
- * mention - 投稿で自分が言及された
- * reply - (自分または自分がWatchしている)投稿が返信された
- * repost - (自分または自分がWatchしている)投稿がRepostされた
- * quote - (自分または自分がWatchしている)投稿が引用Repostされた
- * reaction - (自分または自分がWatchしている)投稿にリアクションされた
- * poll_vote - (自分または自分がWatchしている)投稿の投票に投票された
- */
- type: 'follow' | 'mention' | 'reply' | 'repost' | 'quote' | 'reaction' | 'poll_vote';
-
- /**
- * 通知が読まれたかどうか
- */
- is_read: Boolean;
-}
diff --git a/src/api/models/poll-vote.ts b/src/api/models/poll-vote.ts
deleted file mode 100644
index af77a2643e..0000000000
--- a/src/api/models/poll-vote.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('poll_votes') as any; // fuck type definition
diff --git a/src/api/models/post-reaction.ts b/src/api/models/post-reaction.ts
deleted file mode 100644
index 282ae5bd21..0000000000
--- a/src/api/models/post-reaction.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('post_reactions') as any; // fuck type definition
diff --git a/src/api/models/post-watching.ts b/src/api/models/post-watching.ts
deleted file mode 100644
index 41d37e2703..0000000000
--- a/src/api/models/post-watching.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('post_watching') as any; // fuck type definition
diff --git a/src/api/models/post.ts b/src/api/models/post.ts
deleted file mode 100644
index 7584ce182d..0000000000
--- a/src/api/models/post.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import * as mongo from 'mongodb';
-
-import db from '../../db/mongodb';
-
-export default db.get('posts') as any; // fuck type definition
-
-export function isValidText(text: string): boolean {
- return text.length <= 1000 && text.trim() != '';
-}
-
-export type IPost = {
- _id: mongo.ObjectID;
- channel_id: mongo.ObjectID;
- created_at: Date;
- media_ids: mongo.ObjectID[];
- reply_id: mongo.ObjectID;
- repost_id: mongo.ObjectID;
- poll: {}; // todo
- text: string;
- user_id: mongo.ObjectID;
- app_id: mongo.ObjectID;
-};
diff --git a/src/api/models/signin.ts b/src/api/models/signin.ts
deleted file mode 100644
index 385a348f2e..0000000000
--- a/src/api/models/signin.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('signin') as any; // fuck type definition
diff --git a/src/api/models/sw-subscription.ts b/src/api/models/sw-subscription.ts
deleted file mode 100644
index ecca04cb91..0000000000
--- a/src/api/models/sw-subscription.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import db from '../../db/mongodb';
-
-export default db.get('sw_subscriptions') as any; // fuck type definition
diff --git a/src/api/models/user.ts b/src/api/models/user.ts
deleted file mode 100644
index 018979158f..0000000000
--- a/src/api/models/user.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-import * as mongo from 'mongodb';
-
-import db from '../../db/mongodb';
-import { IPost } from './post';
-
-const collection = db.get('users');
-
-(collection as any).createIndex('username'); // fuck type definition
-(collection as any).createIndex('token'); // fuck type definition
-
-export default collection as any; // fuck type definition
-
-export function validateUsername(username: string): boolean {
- return typeof username == 'string' && /^[a-zA-Z0-9\-]{3,20}$/.test(username);
-}
-
-export function validatePassword(password: string): boolean {
- return typeof password == 'string' && password != '';
-}
-
-export function isValidName(name: string): boolean {
- return typeof name == 'string' && name.length < 30 && name.trim() != '';
-}
-
-export function isValidDescription(description: string): boolean {
- return typeof description == 'string' && description.length < 500 && description.trim() != '';
-}
-
-export function isValidLocation(location: string): boolean {
- return typeof location == 'string' && location.length < 50 && location.trim() != '';
-}
-
-export function isValidBirthday(birthday: string): boolean {
- return typeof birthday == 'string' && /^([0-9]{4})\-([0-9]{2})-([0-9]{2})$/.test(birthday);
-}
-
-export type IUser = {
- _id: mongo.ObjectID;
- created_at: Date;
- email: string;
- followers_count: number;
- following_count: number;
- links: string[];
- name: string;
- password: string;
- posts_count: number;
- drive_capacity: number;
- username: string;
- username_lower: string;
- token: string;
- avatar_id: mongo.ObjectID;
- banner_id: mongo.ObjectID;
- data: any;
- twitter: {
- access_token: string;
- access_token_secret: string;
- user_id: string;
- screen_name: string;
- };
- line: {
- user_id: string;
- };
- description: string;
- profile: {
- location: string;
- birthday: string; // 'YYYY-MM-DD'
- tags: string[];
- };
- last_used_at: Date;
- latest_post: IPost;
- pinned_post_id: mongo.ObjectID;
- is_pro: boolean;
- is_suspended: boolean;
- keywords: string[];
- two_factor_secret: string;
- two_factor_enabled: boolean;
-};
-
-export function init(user): IUser {
- user._id = new mongo.ObjectID(user._id);
- user.avatar_id = new mongo.ObjectID(user.avatar_id);
- user.banner_id = new mongo.ObjectID(user.banner_id);
- user.pinned_post_id = new mongo.ObjectID(user.pinned_post_id);
- return user;
-}