summaryrefslogtreecommitdiff
path: root/src/api/endpoints/channels/create.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-11-01 19:33:08 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-11-01 19:33:08 +0900
commitd6b03c43eb818a5e13a8ad1ec69697e4600c5c2c (patch)
tree20302f7974e7939f2e498b07bd11c86bea4f7e82 /src/api/endpoints/channels/create.ts
parentv2799 (diff)
downloadsharkey-d6b03c43eb818a5e13a8ad1ec69697e4600c5c2c.tar.gz
sharkey-d6b03c43eb818a5e13a8ad1ec69697e4600c5c2c.tar.bz2
sharkey-d6b03c43eb818a5e13a8ad1ec69697e4600c5c2c.zip
Implement Channel Watching
Diffstat (limited to 'src/api/endpoints/channels/create.ts')
-rw-r--r--src/api/endpoints/channels/create.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/api/endpoints/channels/create.ts b/src/api/endpoints/channels/create.ts
index e0c0e0192a..a8d7c29dc1 100644
--- a/src/api/endpoints/channels/create.ts
+++ b/src/api/endpoints/channels/create.ts
@@ -3,6 +3,7 @@
*/
import $ from 'cafy';
import Channel from '../../models/channel';
+import Watching from '../../models/channel-watching';
import serialize from '../../serializers/channel';
/**
@@ -22,9 +23,17 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
created_at: new Date(),
user_id: user._id,
title: title,
- index: 0
+ index: 0,
+ watching_count: 1
});
// Response
res(await serialize(channel));
+
+ // Create Watching
+ await Watching.insert({
+ created_at: new Date(),
+ user_id: user._id,
+ channel_id: channel._id
+ });
});