summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/endpoints/i/update.ts8
-rw-r--r--src/api/endpoints/posts/create.ts6
-rw-r--r--src/api/endpoints/posts/polls/vote.ts6
-rw-r--r--src/api/endpoints/posts/reactions/create.ts6
-rw-r--r--src/api/models/user.ts2
-rw-r--r--src/api/private/signup.ts4
6 files changed, 21 insertions, 11 deletions
diff --git a/src/api/endpoints/i/update.ts b/src/api/endpoints/i/update.ts
index 2a5dce64a8..76bad2d156 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 57f98fa811..a9d52fd128 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 5a4fd1c268..8222fe5326 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 0b0e0e294d..93d9756d02 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 278b949db5..2fea0566ba 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 19e3314756..1e3e9fb45f 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