This commit is contained in:
syuilo
2018-03-05 08:07:09 +09:00
parent 5daa9262f6
commit cb0d237b6a
7 changed files with 38 additions and 11 deletions

View File

@@ -51,6 +51,11 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re
if (isBotErr) return rej('invalid is_bot param');
if (isBot != null) user.is_bot = 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.settings.auto_watch = autoWatch;
await User.update(user._id, {
$set: {
name: user.name,
@@ -58,7 +63,8 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re
avatar_id: user.avatar_id,
banner_id: user.banner_id,
profile: user.profile,
is_bot: user.is_bot
is_bot: user.is_bot,
settings: user.settings
}
});

View File

@@ -377,9 +377,9 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
});
// この投稿をWatchする
// TODO: ユーザーが「返信したときに自動でWatchする」設定を
// オフにしていた場合はしない
watch(user._id, reply);
if (user.settings.auto_watch !== false) {
watch(user._id, reply);
}
// Add mention
addMention(reply.user_id, 'reply');

View File

@@ -100,9 +100,9 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
});
// この投稿をWatchする
// TODO: ユーザーが「投票したときに自動でWatchする」設定を
// オフにしていた場合はしない
watch(user._id, post);
if (user.settings.auto_watch !== false) {
watch(user._id, post);
}
});
function findWithAttr(array, attr, value) {

View File

@@ -116,7 +116,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
});
// この投稿をWatchする
// TODO: ユーザーが「リアクションしたときに自動でWatchする」設定を
// オフにしていた場合はしない
watch(user._id, post);
if (user.settings.auto_watch !== false) {
watch(user._id, post);
}
});

View File

@@ -81,6 +81,8 @@ export type IUser = {
keywords: string[];
two_factor_secret: string;
two_factor_enabled: boolean;
client_settings: any;
settings: any;
};
export function init(user): IUser {

View File

@@ -132,7 +132,9 @@ export default async (req: express.Request, res: express.Response) => {
location: null,
weight: null
},
settings: {},
settings: {
auto_watch: true
},
client_settings: {
home: homeData,
show_donation: false