diff --git a/src/api/endpoints/i/update.ts b/src/api/endpoints/i/update.ts
index 2a5dce64a..76bad2d15 100644
--- a/src/api/endpoints/i/update.ts
+++ b/src/api/endpoints/i/update.ts
@@ -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
}
});
diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts
index 57f98fa81..a9d52fd12 100644
--- a/src/api/endpoints/posts/create.ts
+++ b/src/api/endpoints/posts/create.ts
@@ -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');
diff --git a/src/api/endpoints/posts/polls/vote.ts b/src/api/endpoints/posts/polls/vote.ts
index 5a4fd1c26..8222fe532 100644
--- a/src/api/endpoints/posts/polls/vote.ts
+++ b/src/api/endpoints/posts/polls/vote.ts
@@ -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) {
diff --git a/src/api/endpoints/posts/reactions/create.ts b/src/api/endpoints/posts/reactions/create.ts
index 0b0e0e294..93d9756d0 100644
--- a/src/api/endpoints/posts/reactions/create.ts
+++ b/src/api/endpoints/posts/reactions/create.ts
@@ -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);
+ }
});
diff --git a/src/api/models/user.ts b/src/api/models/user.ts
index 278b949db..2fea0566b 100644
--- a/src/api/models/user.ts
+++ b/src/api/models/user.ts
@@ -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 {
diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts
index 19e331475..1e3e9fb45 100644
--- a/src/api/private/signup.ts
+++ b/src/api/private/signup.ts
@@ -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
diff --git a/src/web/app/desktop/views/components/settings.vue b/src/web/app/desktop/views/components/settings.vue
index a0ffc4e0a..0eb18770a 100644
--- a/src/web/app/desktop/views/components/settings.vue
+++ b/src/web/app/desktop/views/components/settings.vue
@@ -62,6 +62,13 @@
+
+ 通知
+
+ リアクションしたり返信したりした投稿に関する通知を自動的に受け取るようにします。
+
+
+
%i18n:desktop.tags.mk-settings.drive%
@@ -173,6 +180,7 @@ export default Vue.extend({
version,
latestVersion: undefined,
checkingForUpdate: false,
+ autoWatch: true,
enableSounds: localStorage.getItem('enableSounds') == 'true',
lang: localStorage.getItem('lang') || '',
preventUpdate: localStorage.getItem('preventUpdate') == 'true',
@@ -206,12 +214,21 @@ export default Vue.extend({
(this as any).os.getMeta().then(meta => {
this.meta = meta;
});
+
+ if ((this as any).os.i.settings.auto_watch != null) {
+ this.autoWatch = (this as any).os.i.settings.auto_watch;
+ }
},
methods: {
customizeHome() {
this.$router.push('/i/customize-home');
this.$emit('done');
},
+ onChangeAutoWatch(v) {
+ (this as any).api('i/update', {
+ auto_watch: v
+ });
+ },
onChangeShowPostFormOnTopOfTl(v) {
(this as any).api('i/update_client_setting', {
name: 'showPostFormOnTopOfTl',