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 (isBotErr) return rej('invalid is_bot param');
if (isBot != null) user.is_bot = isBot; 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, { await User.update(user._id, {
$set: { $set: {
name: user.name, name: user.name,
@ -58,7 +63,8 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re
avatar_id: user.avatar_id, avatar_id: user.avatar_id,
banner_id: user.banner_id, banner_id: user.banner_id,
profile: user.profile, 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する // この投稿をWatchする
// TODO: ユーザーが「返信したときに自動でWatchする」設定を if (user.settings.auto_watch !== false) {
// オフにしていた場合はしない watch(user._id, reply);
watch(user._id, reply); }
// Add mention // Add mention
addMention(reply.user_id, 'reply'); addMention(reply.user_id, 'reply');

View file

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

View file

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

View file

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

View file

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

View file

@ -62,6 +62,13 @@
</div> </div>
</section> </section>
<section class="notification" v-show="page == 'notification'">
<h1>通知</h1>
<mk-switch v-model="autoWatch" @change="onChangeAutoWatch" text="投稿の自動ウォッチ">
<span>リアクションしたり返信したりした投稿に関する通知を自動的に受け取るようにします</span>
</mk-switch>
</section>
<section class="drive" v-show="page == 'drive'"> <section class="drive" v-show="page == 'drive'">
<h1>%i18n:desktop.tags.mk-settings.drive%</h1> <h1>%i18n:desktop.tags.mk-settings.drive%</h1>
<mk-drive-setting/> <mk-drive-setting/>
@ -173,6 +180,7 @@ export default Vue.extend({
version, version,
latestVersion: undefined, latestVersion: undefined,
checkingForUpdate: false, checkingForUpdate: false,
autoWatch: true,
enableSounds: localStorage.getItem('enableSounds') == 'true', enableSounds: localStorage.getItem('enableSounds') == 'true',
lang: localStorage.getItem('lang') || '', lang: localStorage.getItem('lang') || '',
preventUpdate: localStorage.getItem('preventUpdate') == 'true', preventUpdate: localStorage.getItem('preventUpdate') == 'true',
@ -206,12 +214,21 @@ export default Vue.extend({
(this as any).os.getMeta().then(meta => { (this as any).os.getMeta().then(meta => {
this.meta = 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: { methods: {
customizeHome() { customizeHome() {
this.$router.push('/i/customize-home'); this.$router.push('/i/customize-home');
this.$emit('done'); this.$emit('done');
}, },
onChangeAutoWatch(v) {
(this as any).api('i/update', {
auto_watch: v
});
},
onChangeShowPostFormOnTopOfTl(v) { onChangeShowPostFormOnTopOfTl(v) {
(this as any).api('i/update_client_setting', { (this as any).api('i/update_client_setting', {
name: 'showPostFormOnTopOfTl', name: 'showPostFormOnTopOfTl',