Resolve conflicts

This commit is contained in:
syuilo
2018-03-29 14:48:47 +09:00
parent 281b388e39
commit bfc193d8cd
308 changed files with 3045 additions and 3200 deletions

View File

@ -12,12 +12,12 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
const _token = token.replace(/\s/g, '');
if (user.two_factor_temp_secret == null) {
if (user.twoFactorTempSecret == null) {
return rej('二段階認証の設定が開始されていません');
}
const verified = (speakeasy as any).totp.verify({
secret: user.two_factor_temp_secret,
secret: user.twoFactorTempSecret,
encoding: 'base32',
token: _token
});
@ -28,8 +28,8 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
await User.update(user._id, {
$set: {
'account.two_factor_secret': user.two_factor_temp_secret,
'account.two_factor_enabled': true
'account.twoFactorSecret': user.twoFactorTempSecret,
'account.twoFactorEnabled': true
}
});

View File

@ -27,7 +27,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
await User.update(user._id, {
$set: {
two_factor_temp_secret: secret.base32
twoFactorTempSecret: secret.base32
}
});

View File

@ -19,8 +19,8 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
await User.update(user._id, {
$set: {
'account.two_factor_secret': null,
'account.two_factor_enabled': false
'account.twoFactorSecret': null,
'account.twoFactorEnabled': false
}
});

View File

@ -25,8 +25,8 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
select[`data.${key}`] = true;
}
const appdata = await Appdata.findOne({
app_id: app._id,
user_id: user._id
appId: app._id,
userId: user._id
}, {
fields: select
});

View File

@ -43,11 +43,11 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
}
await Appdata.update({
app_id: app._id,
user_id: user._id
appId: app._id,
userId: user._id
}, Object.assign({
app_id: app._id,
user_id: user._id
appId: app._id,
userId: user._id
}, {
$set: set
}), {

View File

@ -28,7 +28,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Get tokens
const tokens = await AccessToken
.find({
user_id: user._id
userId: user._id
}, {
limit: limit,
skip: offset,
@ -39,5 +39,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(tokens.map(async token =>
await pack(token.app_id))));
await pack(token.appId))));
});

View File

@ -13,13 +13,13 @@ import User from '../../models/user';
* @return {Promise<any>}
*/
module.exports = async (params, user) => new Promise(async (res, rej) => {
// Get 'current_password' parameter
const [currentPassword, currentPasswordErr] = $(params.current_password).string().$;
if (currentPasswordErr) return rej('invalid current_password param');
// Get 'currentPasword' parameter
const [currentPassword, currentPasswordErr] = $(params.currentPasword).string().$;
if (currentPasswordErr) return rej('invalid currentPasword param');
// Get 'new_password' parameter
const [newPassword, newPasswordErr] = $(params.new_password).string().$;
if (newPasswordErr) return rej('invalid new_password param');
// Get 'newPassword' parameter
const [newPassword, newPasswordErr] = $(params.newPassword).string().$;
if (newPasswordErr) return rej('invalid newPassword param');
// Compare password
const same = await bcrypt.compare(currentPassword, user.account.password);

View File

@ -28,7 +28,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Get favorites
const favorites = await Favorite
.find({
user_id: user._id
userId: user._id
}, {
limit: limit,
skip: offset,
@ -39,6 +39,6 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(favorites.map(async favorite =>
await pack(favorite.post)
await pack(favorite.postId)
)));
});

View File

@ -21,9 +21,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
$(params.following).optional.boolean().$;
if (followingError) return rej('invalid following param');
// Get 'mark_as_read' parameter
const [markAsRead = true, markAsReadErr] = $(params.mark_as_read).optional.boolean().$;
if (markAsReadErr) return rej('invalid mark_as_read param');
// Get 'markAsRead' parameter
const [markAsRead = true, markAsReadErr] = $(params.markAsRead).optional.boolean().$;
if (markAsReadErr) return rej('invalid markAsRead param');
// Get 'type' parameter
const [type, typeErr] = $(params.type).optional.array('string').unique().$;
@ -33,29 +33,29 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
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');
}
const mute = await Mute.find({
muter_id: user._id,
deleted_at: { $exists: false }
muterId: user._id,
deletedAt: { $exists: false }
});
const query = {
notifiee_id: user._id,
notifieeId: user._id,
$and: [{
notifier_id: {
$nin: mute.map(m => m.mutee_id)
notifierId: {
$nin: mute.map(m => m.muteeId)
}
}]
} as any;
@ -69,7 +69,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
const followingIds = await getFriends(user._id);
query.$and.push({
notifier_id: {
notifierId: {
$in: followingIds
}
});

View File

@ -14,14 +14,14 @@ import { pack } from '../../models/user';
* @return {Promise<any>}
*/
module.exports = async (params, user) => new Promise(async (res, rej) => {
// Get 'post_id' parameter
const [postId, postIdErr] = $(params.post_id).id().$;
if (postIdErr) return rej('invalid post_id param');
// Get 'postId' parameter
const [postId, postIdErr] = $(params.postId).id().$;
if (postIdErr) return rej('invalid postId param');
// Fetch pinee
const post = await Post.findOne({
_id: postId,
user_id: user._id
userId: user._id
});
if (post === null) {
@ -30,7 +30,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
await User.update(user._id, {
$set: {
pinned_post_id: post._id
pinnedPostId: post._id
}
});

View File

@ -16,21 +16,21 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
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');
}
const query = {
user_id: user._id
userId: user._id
} as any;
const sort = {

View File

@ -36,34 +36,34 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re
if (birthdayErr) return rej('invalid birthday param');
if (birthday !== undefined) user.account.profile.birthday = birthday;
// Get 'avatar_id' parameter
const [avatarId, avatarIdErr] = $(params.avatar_id).optional.id().$;
if (avatarIdErr) return rej('invalid avatar_id param');
if (avatarId) user.avatar_id = avatarId;
// Get 'avatarId' parameter
const [avatarId, avatarIdErr] = $(params.avatarId).optional.id().$;
if (avatarIdErr) return rej('invalid avatarId param');
if (avatarId) user.avatarId = avatarId;
// Get 'banner_id' parameter
const [bannerId, bannerIdErr] = $(params.banner_id).optional.id().$;
if (bannerIdErr) return rej('invalid banner_id param');
if (bannerId) user.banner_id = bannerId;
// Get 'bannerId' parameter
const [bannerId, bannerIdErr] = $(params.bannerId).optional.id().$;
if (bannerIdErr) return rej('invalid bannerId param');
if (bannerId) user.bannerId = bannerId;
// Get 'is_bot' parameter
const [isBot, isBotErr] = $(params.is_bot).optional.boolean().$;
if (isBotErr) return rej('invalid is_bot param');
if (isBot != null) user.account.is_bot = isBot;
// Get 'isBot' parameter
const [isBot, isBotErr] = $(params.isBot).optional.boolean().$;
if (isBotErr) return rej('invalid isBot param');
if (isBot != null) user.account.isBot = isBot;
// Get 'auto_watch' parameter
const [autoWatch, autoWatchErr] = $(params.auto_watch).optional.boolean().$;
if (autoWatchErr) return rej('invalid auto_watch param');
if (autoWatch != null) user.account.settings.auto_watch = autoWatch;
// Get 'autoWatch' parameter
const [autoWatch, autoWatchErr] = $(params.autoWatch).optional.boolean().$;
if (autoWatchErr) return rej('invalid autoWatch param');
if (autoWatch != null) user.account.settings.autoWatch = autoWatch;
await User.update(user._id, {
$set: {
name: user.name,
description: user.description,
avatar_id: user.avatar_id,
banner_id: user.banner_id,
avatarId: user.avatarId,
bannerId: user.bannerId,
'account.profile': user.account.profile,
'account.is_bot': user.account.is_bot,
'account.isBot': user.account.isBot,
'account.settings': user.account.settings
}
});

View File

@ -22,14 +22,14 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
if (valueErr) return rej('invalid value param');
const x = {};
x[`account.client_settings.${name}`] = value;
x[`account.clientSettings.${name}`] = value;
await User.update(user._id, {
$set: x
});
// Serialize
user.account.client_settings[name] = value;
user.account.clientSettings[name] = value;
const iObj = await pack(user, user, {
detail: true,
includeSecrets: true

View File

@ -26,7 +26,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
if (home) {
await User.update(user._id, {
$set: {
'account.client_settings.home': home
'account.clientSettings.home': home
}
});
@ -38,7 +38,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
} else {
if (id == null && data == null) return rej('you need to set id and data params if home param unset');
const _home = user.account.client_settings.home;
const _home = user.account.clientSettings.home;
const widget = _home.find(w => w.id == id);
if (widget == null) return rej('widget not found');
@ -47,7 +47,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
await User.update(user._id, {
$set: {
'account.client_settings.home': _home
'account.clientSettings.home': _home
}
});

View File

@ -25,7 +25,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
if (home) {
await User.update(user._id, {
$set: {
'account.client_settings.mobile_home': home
'account.clientSettings.mobile_home': home
}
});
@ -37,7 +37,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
} else {
if (id == null && data == null) return rej('you need to set id and data params if home param unset');
const _home = user.account.client_settings.mobile_home || [];
const _home = user.account.clientSettings.mobile_home || [];
const widget = _home.find(w => w.id == id);
if (widget == null) return rej('widget not found');
@ -46,7 +46,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
await User.update(user._id, {
$set: {
'account.client_settings.mobile_home': _home
'account.clientSettings.mobile_home': _home
}
});