Resolve conflicts
This commit is contained in:
parent
281b388e39
commit
bfc193d8cd
308 changed files with 3045 additions and 3200 deletions
|
|
@ -20,11 +20,11 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
|
|||
|
||||
// Create a channel
|
||||
const channel = await Channel.insert({
|
||||
created_at: new Date(),
|
||||
user_id: user._id,
|
||||
createdAt: new Date(),
|
||||
userId: user._id,
|
||||
title: title,
|
||||
index: 0,
|
||||
watching_count: 1
|
||||
watchingCount: 1
|
||||
});
|
||||
|
||||
// Response
|
||||
|
|
@ -32,8 +32,8 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
|
|||
|
||||
// Create Watching
|
||||
await Watching.insert({
|
||||
created_at: new Date(),
|
||||
user_id: user._id,
|
||||
channel_id: channel._id
|
||||
createdAt: new Date(),
|
||||
userId: user._id,
|
||||
channelId: channel._id
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,22 +17,22 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
const [limit = 1000, limitErr] = $(params.limit).optional.number().range(1, 1000).$;
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'since_id' parameter
|
||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||
if (sinceIdErr) return rej('invalid since_id param');
|
||||
// Get 'sinceId' parameter
|
||||
const [sinceId, sinceIdErr] = $(params.sinceId).optional.id().$;
|
||||
if (sinceIdErr) return rej('invalid sinceId param');
|
||||
|
||||
// Get 'until_id' parameter
|
||||
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||
if (untilIdErr) return rej('invalid until_id param');
|
||||
// Get 'untilId' parameter
|
||||
const [untilId, untilIdErr] = $(params.untilId).optional.id().$;
|
||||
if (untilIdErr) return rej('invalid untilId param');
|
||||
|
||||
// Check if both of since_id and until_id is specified
|
||||
// Check if both of sinceId and untilId is specified
|
||||
if (sinceId && untilId) {
|
||||
return rej('cannot set since_id and until_id');
|
||||
return rej('cannot set sinceId and untilId');
|
||||
}
|
||||
|
||||
// Get 'channel_id' parameter
|
||||
const [channelId, channelIdErr] = $(params.channel_id).id().$;
|
||||
if (channelIdErr) return rej('invalid channel_id param');
|
||||
// Get 'channelId' parameter
|
||||
const [channelId, channelIdErr] = $(params.channelId).id().$;
|
||||
if (channelIdErr) return rej('invalid channelId param');
|
||||
|
||||
// Fetch channel
|
||||
const channel: IChannel = await Channel.findOne({
|
||||
|
|
@ -49,7 +49,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
};
|
||||
|
||||
const query = {
|
||||
channel_id: channel._id
|
||||
channelId: channel._id
|
||||
} as any;
|
||||
|
||||
if (sinceId) {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ import Channel, { IChannel, pack } from '../../models/channel';
|
|||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'channel_id' parameter
|
||||
const [channelId, channelIdErr] = $(params.channel_id).id().$;
|
||||
if (channelIdErr) return rej('invalid channel_id param');
|
||||
// Get 'channelId' parameter
|
||||
const [channelId, channelIdErr] = $(params.channelId).id().$;
|
||||
if (channelIdErr) return rej('invalid channelId param');
|
||||
|
||||
// Fetch channel
|
||||
const channel: IChannel = await Channel.findOne({
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ import Watching from '../../models/channel-watching';
|
|||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'channel_id' parameter
|
||||
const [channelId, channelIdErr] = $(params.channel_id).id().$;
|
||||
if (channelIdErr) return rej('invalid channel_id param');
|
||||
// Get 'channelId' parameter
|
||||
const [channelId, channelIdErr] = $(params.channelId).id().$;
|
||||
if (channelIdErr) return rej('invalid channelId param');
|
||||
|
||||
//#region Fetch channel
|
||||
const channel = await Channel.findOne({
|
||||
|
|
@ -29,9 +29,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
|
||||
//#region Check whether not watching
|
||||
const exist = await Watching.findOne({
|
||||
user_id: user._id,
|
||||
channel_id: channel._id,
|
||||
deleted_at: { $exists: false }
|
||||
userId: user._id,
|
||||
channelId: channel._id,
|
||||
deletedAt: { $exists: false }
|
||||
});
|
||||
|
||||
if (exist === null) {
|
||||
|
|
@ -44,7 +44,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
_id: exist._id
|
||||
}, {
|
||||
$set: {
|
||||
deleted_at: new Date()
|
||||
deletedAt: new Date()
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
// Decrement watching count
|
||||
Channel.update(channel._id, {
|
||||
$inc: {
|
||||
watching_count: -1
|
||||
watchingCount: -1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ import Watching from '../../models/channel-watching';
|
|||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'channel_id' parameter
|
||||
const [channelId, channelIdErr] = $(params.channel_id).id().$;
|
||||
if (channelIdErr) return rej('invalid channel_id param');
|
||||
// Get 'channelId' parameter
|
||||
const [channelId, channelIdErr] = $(params.channelId).id().$;
|
||||
if (channelIdErr) return rej('invalid channelId param');
|
||||
|
||||
//#region Fetch channel
|
||||
const channel = await Channel.findOne({
|
||||
|
|
@ -29,9 +29,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
|
||||
//#region Check whether already watching
|
||||
const exist = await Watching.findOne({
|
||||
user_id: user._id,
|
||||
channel_id: channel._id,
|
||||
deleted_at: { $exists: false }
|
||||
userId: user._id,
|
||||
channelId: channel._id,
|
||||
deletedAt: { $exists: false }
|
||||
});
|
||||
|
||||
if (exist !== null) {
|
||||
|
|
@ -41,9 +41,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
|
||||
// Create Watching
|
||||
await Watching.insert({
|
||||
created_at: new Date(),
|
||||
user_id: user._id,
|
||||
channel_id: channel._id
|
||||
createdAt: new Date(),
|
||||
userId: user._id,
|
||||
channelId: channel._id
|
||||
});
|
||||
|
||||
// Send response
|
||||
|
|
@ -52,7 +52,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
// Increment watching count
|
||||
Channel.update(channel._id, {
|
||||
$inc: {
|
||||
watching_count: 1
|
||||
watchingCount: 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue