summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-24 18:13:06 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-24 18:13:06 +0900
commit7602e8f9383be37c0f7d9359f862c366b7f2fa00 (patch)
tree013dc2467b4a2e028371d4cf94f42a138d2eb4d5 /src/models
parentBetter japanese (diff)
downloadmisskey-7602e8f9383be37c0f7d9359f862c366b7f2fa00.tar.gz
misskey-7602e8f9383be37c0f7d9359f862c366b7f2fa00.tar.bz2
misskey-7602e8f9383be37c0f7d9359f862c366b7f2fa00.zip
cafy 5.xに移行
Diffstat (limited to 'src/models')
-rw-r--r--src/models/note-reaction.ts2
-rw-r--r--src/models/user-list.ts27
2 files changed, 28 insertions, 1 deletions
diff --git a/src/models/note-reaction.ts b/src/models/note-reaction.ts
index 7891ebdf17..f78b0d9d01 100644
--- a/src/models/note-reaction.ts
+++ b/src/models/note-reaction.ts
@@ -1,5 +1,5 @@
import * as mongo from 'mongodb';
-import $ from 'cafy';
+import $ from 'cafy'; import ID from '../../../../cafy-id';
import deepcopy = require('deepcopy');
import db from '../db/mongodb';
import Reaction from './note-reaction';
diff --git a/src/models/user-list.ts b/src/models/user-list.ts
index 66e2afe213..7100fced7e 100644
--- a/src/models/user-list.ts
+++ b/src/models/user-list.ts
@@ -1,4 +1,5 @@
import * as mongo from 'mongodb';
+import deepcopy = require('deepcopy');
import db from '../db/mongodb';
const UserList = db.get<IUserList>('userList');
@@ -38,3 +39,29 @@ export async function deleteUserList(userList: string | mongo.ObjectID | IUserLi
_id: u._id
});
}
+
+export const pack = (
+ userList: string | mongo.ObjectID | IUserList
+) => new Promise<any>(async (resolve, reject) => {
+ let _userList: any;
+
+ if (mongo.ObjectID.prototype.isPrototypeOf(userList)) {
+ _userList = await UserList.findOne({
+ _id: userList
+ });
+ } else if (typeof userList === 'string') {
+ _userList = await UserList.findOne({
+ _id: new mongo.ObjectID(userList)
+ });
+ } else {
+ _userList = deepcopy(userList);
+ }
+
+ if (!_userList) throw `invalid userList arg ${userList}`;
+
+ // Rename _id to id
+ _userList.id = _userList._id;
+ delete _userList._id;
+
+ resolve(_userList);
+});