From 8823a6c1a1ffebe96c3646896ae84cfc91eeadf4 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Fri, 28 Dec 2018 21:36:58 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=AD=E3=83=BC=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=82=8B=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=81=8B=E3=82=89=E3=81=AE=E3=83=95=E3=82=A9=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=82=92=E8=87=AA=E5=8B=95=E6=89=BF=E8=AA=8D=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=20(#3780)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 1 + .../common/views/components/profile-editor.vue | 6 +++++- src/models/user.ts | 5 +++++ src/server/api/endpoints/i/update.ts | 8 ++++++++ src/services/following/create.ts | 18 ++++++++++++++++-- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 49d6a836d..ea7922f26 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -518,6 +518,7 @@ common/views/components/profile-editor.vue: is-bot: "このアカウントはBotです" is-locked: "フォローを承認制にする" careful-bot: "Botからのフォローだけ承認制にする" + auto-accept-followed: "フォローしているユーザーからのフォローを自動承認する" advanced: "その他" privacy: "プライバシー" save: "保存" diff --git a/src/client/app/common/views/components/profile-editor.vue b/src/client/app/common/views/components/profile-editor.vue index 5f462a258..75d14236c 100644 --- a/src/client/app/common/views/components/profile-editor.vue +++ b/src/client/app/common/views/components/profile-editor.vue @@ -70,6 +70,7 @@
{{ $t('is-locked') }} {{ $t('careful-bot') }} + {{ $t('auto-accept-followed') }}
@@ -118,6 +119,7 @@ export default Vue.extend({ isBot: false, isLocked: false, carefulBot: false, + autoAcceptFollowed: false, saving: false, avatarUploading: false, bannerUploading: false @@ -156,6 +158,7 @@ export default Vue.extend({ this.isBot = this.$store.state.i.isBot; this.isLocked = this.$store.state.i.isLocked; this.carefulBot = this.$store.state.i.carefulBot; + this.autoAcceptFollowed = this.$store.state.i.autoAcceptFollowed; }, methods: { @@ -217,7 +220,8 @@ export default Vue.extend({ isCat: !!this.isCat, isBot: !!this.isBot, isLocked: !!this.isLocked, - carefulBot: !!this.carefulBot + carefulBot: !!this.carefulBot, + autoAcceptFollowed: !!this.autoAcceptFollowed }).then(i => { this.saving = false; this.$store.state.i.avatarId = i.avatarId; diff --git a/src/models/user.ts b/src/models/user.ts index 19291a2cb..61fb7244e 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -69,6 +69,11 @@ type IUserBase = { */ carefulBot: boolean; + /** + * フォローしているユーザーからのフォローリクエストを自動承認するか + */ + autoAcceptFollowed: boolean; + /** * このアカウントに届いているフォローリクエストの数 */ diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index 7bdd52883..ec6aaa04d 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -94,6 +94,13 @@ export const meta = { } }, + autoAcceptFollowed: { + validator: $.bool.optional, + desc: { + 'ja-JP': 'フォローしているユーザーからのフォローリクエストを自動承認するか' + } + }, + isBot: { validator: $.bool.optional, desc: { @@ -140,6 +147,7 @@ export default define(meta, (ps, user, app) => new Promise(async (res, rej) => { if (typeof ps.isLocked == 'boolean') updates.isLocked = ps.isLocked; if (typeof ps.isBot == 'boolean') updates.isBot = ps.isBot; if (typeof ps.carefulBot == 'boolean') updates.carefulBot = ps.carefulBot; + if (typeof ps.autoAcceptFollowed == 'boolean') updates.autoAcceptFollowed = ps.autoAcceptFollowed; if (typeof ps.isCat == 'boolean') updates.isCat = ps.isCat; if (typeof ps.autoWatch == 'boolean') updates['settings.autoWatch'] = ps.autoWatch; if (typeof ps.alwaysMarkNsfw == 'boolean') updates['settings.alwaysMarkNsfw'] = ps.alwaysMarkNsfw; diff --git a/src/services/following/create.ts b/src/services/following/create.ts index 46b818f8b..fac53c40a 100644 --- a/src/services/following/create.ts +++ b/src/services/following/create.ts @@ -45,8 +45,22 @@ export default async function(follower: IUser, followee: IUser, requestId?: stri // フォロワーがローカルユーザーであり、フォロー対象がリモートユーザーである // 上記のいずれかに当てはまる場合はすぐフォローせずにフォローリクエストを発行しておく if (followee.isLocked || (followee.carefulBot && follower.isBot) || (isLocalUser(follower) && isRemoteUser(followee))) { - await createFollowRequest(follower, followee, requestId); - return; + let autoAccept = false; + + // フォローしているユーザーは自動承認オプション + if (isLocalUser(followee) && followee.autoAcceptFollowed) { + const followed = await Following.findOne({ + followerId: followee._id, + followeeId: follower._id + }); + + if (followed) autoAccept = true; + } + + if (!autoAccept) { + await createFollowRequest(follower, followee, requestId); + return; + } } await Following.insert({