summaryrefslogtreecommitdiff
path: root/src/api/models/user.ts
diff options
context:
space:
mode:
authorこぴなたみぽ <Syuilotan@yahoo.co.jp>2017-11-06 19:11:23 +0900
committerGitHub <noreply@github.com>2017-11-06 19:11:23 +0900
commitcb7e70dee3aa47807d33757d4ecd07e2793540d0 (patch)
treec6795a6c0aa200195748c364d4ab990c6a160150 /src/api/models/user.ts
parentchore(package): update @types/rimraf to version 2.0.2 (diff)
parentMerge pull request #871 from syuilo/greenkeeper/@types/elasticsearch-5.0.17 (diff)
downloadmisskey-cb7e70dee3aa47807d33757d4ecd07e2793540d0.tar.gz
misskey-cb7e70dee3aa47807d33757d4ecd07e2793540d0.tar.bz2
misskey-cb7e70dee3aa47807d33757d4ecd07e2793540d0.zip
Merge branch 'master' into greenkeeper/@types/rimraf-2.0.2
Diffstat (limited to 'src/api/models/user.ts')
-rw-r--r--src/api/models/user.ts53
1 files changed, 50 insertions, 3 deletions
diff --git a/src/api/models/user.ts b/src/api/models/user.ts
index cd16459891..b2f3af09fa 100644
--- a/src/api/models/user.ts
+++ b/src/api/models/user.ts
@@ -1,9 +1,12 @@
+import * as mongo from 'mongodb';
+
import db from '../../db/mongodb';
+import { IPost } from './post';
const collection = db.get('users');
-(collection as any).index('username'); // fuck type definition
-(collection as any).index('token'); // fuck type definition
+(collection as any).createIndex('username'); // fuck type definition
+(collection as any).createIndex('token'); // fuck type definition
export default collection as any; // fuck type definition
@@ -31,6 +34,50 @@ export function isValidBirthday(birthday: string): boolean {
return typeof birthday == 'string' && /^([0-9]{4})\-([0-9]{2})-([0-9]{2})$/.test(birthday);
}
-export interface IUser {
+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[];
+};
+
+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;
}