This commit is contained in:
parent
fb09710b62
commit
c378e5fc94
|
@ -21,13 +21,13 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct query
|
// Construct query
|
||||||
|
@ -40,9 +40,9 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,13 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get 'channel_id' parameter
|
// Get 'channel_id' parameter
|
||||||
|
@ -58,9 +58,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//#endregion Construct query
|
//#endregion Construct query
|
||||||
|
|
|
@ -22,13 +22,13 @@ module.exports = async (params, user, app) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) throw 'invalid since_id param';
|
if (sinceIdErr) throw 'invalid since_id param';
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) throw 'invalid max_id param';
|
if (untilIdErr) throw 'invalid until_id param';
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
throw 'cannot set since_id and max_id';
|
throw 'cannot set since_id and until_id';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get 'folder_id' parameter
|
// Get 'folder_id' parameter
|
||||||
|
@ -52,9 +52,9 @@ module.exports = async (params, user, app) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (type) {
|
if (type) {
|
||||||
|
|
|
@ -22,13 +22,13 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get 'folder_id' parameter
|
// Get 'folder_id' parameter
|
||||||
|
@ -48,9 +48,9 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,13 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get 'type' parameter
|
// Get 'type' parameter
|
||||||
|
@ -46,9 +46,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (type) {
|
if (type) {
|
||||||
|
|
|
@ -36,13 +36,13 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
|
@ -73,9 +73,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,13 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
|
@ -43,9 +43,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,13 +44,13 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
|
@ -72,9 +72,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,13 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct query
|
// Construct query
|
||||||
|
@ -55,9 +55,9 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,13 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct query
|
// Construct query
|
||||||
|
@ -58,9 +58,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup post
|
// Lookup post
|
||||||
|
@ -55,9 +55,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,21 +25,21 @@ module.exports = async (params, user, app) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) throw 'invalid since_id param';
|
if (sinceIdErr) throw 'invalid since_id param';
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) throw 'invalid max_id param';
|
if (untilIdErr) throw 'invalid until_id param';
|
||||||
|
|
||||||
// Get 'since_date' parameter
|
// Get 'since_date' parameter
|
||||||
const [sinceDate, sinceDateErr] = $(params.since_date).optional.number().$;
|
const [sinceDate, sinceDateErr] = $(params.since_date).optional.number().$;
|
||||||
if (sinceDateErr) throw 'invalid since_date param';
|
if (sinceDateErr) throw 'invalid since_date param';
|
||||||
|
|
||||||
// Get 'max_date' parameter
|
// Get 'until_date' parameter
|
||||||
const [maxDate, maxDateErr] = $(params.max_date).optional.number().$;
|
const [untilDate, untilDateErr] = $(params.until_date).optional.number().$;
|
||||||
if (maxDateErr) throw 'invalid max_date param';
|
if (untilDateErr) throw 'invalid until_date param';
|
||||||
|
|
||||||
// Check if only one of since_id, max_id, since_date, max_date specified
|
// Check if only one of since_id, until_id, since_date, until_date specified
|
||||||
if ([sinceId, maxId, sinceDate, maxDate].filter(x => x != null).length > 1) {
|
if ([sinceId, untilId, sinceDate, untilDate].filter(x => x != null).length > 1) {
|
||||||
throw 'only one of since_id, max_id, since_date, max_date can be specified';
|
throw 'only one of since_id, until_id, since_date, until_date can be specified';
|
||||||
}
|
}
|
||||||
|
|
||||||
const { followingIds, watchingChannelIds } = await rap({
|
const { followingIds, watchingChannelIds } = await rap({
|
||||||
|
@ -85,18 +85,18 @@ module.exports = async (params, user, app) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
} else if (sinceDate) {
|
} else if (sinceDate) {
|
||||||
sort._id = 1;
|
sort._id = 1;
|
||||||
query.created_at = {
|
query.created_at = {
|
||||||
$gt: new Date(sinceDate)
|
$gt: new Date(sinceDate)
|
||||||
};
|
};
|
||||||
} else if (maxDate) {
|
} else if (untilDate) {
|
||||||
query.created_at = {
|
query.created_at = {
|
||||||
$lt: new Date(maxDate)
|
$lt: new Date(untilDate)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
|
@ -21,13 +21,13 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Check if both of since_id and max_id is specified
|
// Check if both of since_id and until_id is specified
|
||||||
if (sinceId && maxId) {
|
if (sinceId && untilId) {
|
||||||
return rej('cannot set since_id and max_id');
|
return rej('cannot set since_id and until_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct query
|
// Construct query
|
||||||
|
@ -40,9 +40,9 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,21 +42,21 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||||
if (sinceIdErr) return rej('invalid since_id param');
|
if (sinceIdErr) return rej('invalid since_id param');
|
||||||
|
|
||||||
// Get 'max_id' parameter
|
// Get 'until_id' parameter
|
||||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
|
||||||
if (maxIdErr) return rej('invalid max_id param');
|
if (untilIdErr) return rej('invalid until_id param');
|
||||||
|
|
||||||
// Get 'since_date' parameter
|
// Get 'since_date' parameter
|
||||||
const [sinceDate, sinceDateErr] = $(params.since_date).optional.number().$;
|
const [sinceDate, sinceDateErr] = $(params.since_date).optional.number().$;
|
||||||
if (sinceDateErr) throw 'invalid since_date param';
|
if (sinceDateErr) throw 'invalid since_date param';
|
||||||
|
|
||||||
// Get 'max_date' parameter
|
// Get 'until_date' parameter
|
||||||
const [maxDate, maxDateErr] = $(params.max_date).optional.number().$;
|
const [untilDate, untilDateErr] = $(params.until_date).optional.number().$;
|
||||||
if (maxDateErr) throw 'invalid max_date param';
|
if (untilDateErr) throw 'invalid until_date param';
|
||||||
|
|
||||||
// Check if only one of since_id, max_id, since_date, max_date specified
|
// Check if only one of since_id, until_id, since_date, until_date specified
|
||||||
if ([sinceId, maxId, sinceDate, maxDate].filter(x => x != null).length > 1) {
|
if ([sinceId, untilId, sinceDate, untilDate].filter(x => x != null).length > 1) {
|
||||||
throw 'only one of since_id, max_id, since_date, max_date can be specified';
|
throw 'only one of since_id, until_id, since_date, until_date can be specified';
|
||||||
}
|
}
|
||||||
|
|
||||||
const q = userId !== undefined
|
const q = userId !== undefined
|
||||||
|
@ -88,18 +88,18 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
query._id = {
|
query._id = {
|
||||||
$gt: sinceId
|
$gt: sinceId
|
||||||
};
|
};
|
||||||
} else if (maxId) {
|
} else if (untilId) {
|
||||||
query._id = {
|
query._id = {
|
||||||
$lt: maxId
|
$lt: untilId
|
||||||
};
|
};
|
||||||
} else if (sinceDate) {
|
} else if (sinceDate) {
|
||||||
sort._id = 1;
|
sort._id = 1;
|
||||||
query.created_at = {
|
query.created_at = {
|
||||||
$gt: new Date(sinceDate)
|
$gt: new Date(sinceDate)
|
||||||
};
|
};
|
||||||
} else if (maxDate) {
|
} else if (untilDate) {
|
||||||
query.created_at = {
|
query.created_at = {
|
||||||
$lt: new Date(maxDate)
|
$lt: new Date(untilDate)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,7 @@
|
||||||
this.api('messaging/messages', {
|
this.api('messaging/messages', {
|
||||||
user_id: this.user.id,
|
user_id: this.user.id,
|
||||||
limit: max + 1,
|
limit: max + 1,
|
||||||
max_id: this.moreMessagesIsInStock ? this.messages[0].id : undefined
|
until_id: this.moreMessagesIsInStock ? this.messages[0].id : undefined
|
||||||
}).then(messages => {
|
}).then(messages => {
|
||||||
if (messages.length == max + 1) {
|
if (messages.length == max + 1) {
|
||||||
this.moreMessagesIsInStock = true;
|
this.moreMessagesIsInStock = true;
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
});
|
});
|
||||||
this.api('posts/mentions', {
|
this.api('posts/mentions', {
|
||||||
following: this.mode == 'following',
|
following: this.mode == 'following',
|
||||||
max_id: this.refs.timeline.tail().id
|
until_id: this.refs.timeline.tail().id
|
||||||
}).then(posts => {
|
}).then(posts => {
|
||||||
this.update({
|
this.update({
|
||||||
moreLoading: false
|
moreLoading: false
|
||||||
|
|
|
@ -86,7 +86,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
this.api('posts/timeline', {
|
this.api('posts/timeline', {
|
||||||
max_date: this.date ? this.date.getTime() : undefined
|
until_date: this.date ? this.date.getTime() : undefined
|
||||||
}).then(posts => {
|
}).then(posts => {
|
||||||
this.update({
|
this.update({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
moreLoading: true
|
moreLoading: true
|
||||||
});
|
});
|
||||||
this.api('posts/timeline', {
|
this.api('posts/timeline', {
|
||||||
max_id: this.refs.timeline.tail().id
|
until_id: this.refs.timeline.tail().id
|
||||||
}).then(posts => {
|
}).then(posts => {
|
||||||
this.update({
|
this.update({
|
||||||
moreLoading: false
|
moreLoading: false
|
||||||
|
|
|
@ -283,7 +283,7 @@
|
||||||
|
|
||||||
this.api('i/notifications', {
|
this.api('i/notifications', {
|
||||||
limit: max + 1,
|
limit: max + 1,
|
||||||
max_id: this.notifications[this.notifications.length - 1].id
|
until_id: this.notifications[this.notifications.length - 1].id
|
||||||
}).then(notifications => {
|
}).then(notifications => {
|
||||||
if (notifications.length == max + 1) {
|
if (notifications.length == max + 1) {
|
||||||
this.moreNotifications = true;
|
this.moreNotifications = true;
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
this.fetch = cb => {
|
this.fetch = cb => {
|
||||||
this.api('users/posts', {
|
this.api('users/posts', {
|
||||||
user_id: this.user.id,
|
user_id: this.user.id,
|
||||||
max_date: this.date ? this.date.getTime() : undefined,
|
until_date: this.date ? this.date.getTime() : undefined,
|
||||||
with_replies: this.mode == 'with-replies'
|
with_replies: this.mode == 'with-replies'
|
||||||
}).then(posts => {
|
}).then(posts => {
|
||||||
this.update({
|
this.update({
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
this.api('users/posts', {
|
this.api('users/posts', {
|
||||||
user_id: this.user.id,
|
user_id: this.user.id,
|
||||||
with_replies: this.mode == 'with-replies',
|
with_replies: this.mode == 'with-replies',
|
||||||
max_id: this.refs.timeline.tail().id
|
until_id: this.refs.timeline.tail().id
|
||||||
}).then(posts => {
|
}).then(posts => {
|
||||||
this.update({
|
this.update({
|
||||||
moreLoading: false
|
moreLoading: false
|
||||||
|
|
|
@ -430,7 +430,7 @@
|
||||||
this.api('drive/files', {
|
this.api('drive/files', {
|
||||||
folder_id: this.folder ? this.folder.id : null,
|
folder_id: this.folder ? this.folder.id : null,
|
||||||
limit: max + 1,
|
limit: max + 1,
|
||||||
max_id: this.files[this.files.length - 1].id
|
until_id: this.files[this.files.length - 1].id
|
||||||
}).then(files => {
|
}).then(files => {
|
||||||
if (files.length == max + 1) {
|
if (files.length == max + 1) {
|
||||||
this.moreFiles = true;
|
this.moreFiles = true;
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
this.more = () => {
|
this.more = () => {
|
||||||
return this.api('posts/timeline', {
|
return this.api('posts/timeline', {
|
||||||
max_id: this.refs.timeline.tail().id
|
until_id: this.refs.timeline.tail().id
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@
|
||||||
|
|
||||||
this.api('i/notifications', {
|
this.api('i/notifications', {
|
||||||
limit: max + 1,
|
limit: max + 1,
|
||||||
max_id: this.notifications[this.notifications.length - 1].id
|
until_id: this.notifications[this.notifications.length - 1].id
|
||||||
}).then(notifications => {
|
}).then(notifications => {
|
||||||
if (notifications.length == max + 1) {
|
if (notifications.length == max + 1) {
|
||||||
this.moreNotifications = true;
|
this.moreNotifications = true;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
return this.api('users/posts', {
|
return this.api('users/posts', {
|
||||||
user_id: this.user.id,
|
user_id: this.user.id,
|
||||||
with_media: this.withMedia,
|
with_media: this.withMedia,
|
||||||
max_id: this.refs.timeline.tail().id
|
until_id: this.refs.timeline.tail().id
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -15,7 +15,7 @@ params:
|
||||||
optional: true
|
optional: true
|
||||||
desc:
|
desc:
|
||||||
ja: "指定すると、この投稿を基点としてより新しい投稿を取得します"
|
ja: "指定すると、この投稿を基点としてより新しい投稿を取得します"
|
||||||
- name: "max_id"
|
- name: "until_id"
|
||||||
type: "id(Post)"
|
type: "id(Post)"
|
||||||
optional: true
|
optional: true
|
||||||
desc:
|
desc:
|
||||||
|
@ -25,7 +25,7 @@ params:
|
||||||
optional: true
|
optional: true
|
||||||
desc:
|
desc:
|
||||||
ja: "指定した時間を基点としてより新しい投稿を取得します。数値は、1970 年 1 月 1 日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。"
|
ja: "指定した時間を基点としてより新しい投稿を取得します。数値は、1970 年 1 月 1 日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。"
|
||||||
- name: "max_date"
|
- name: "until_date"
|
||||||
type: "number"
|
type: "number"
|
||||||
optional: true
|
optional: true
|
||||||
desc:
|
desc:
|
||||||
|
|
Loading…
Reference in a new issue