フォローしているユーザーからのフォローを自動承認するオプション (#3780)
This commit is contained in:
		
							parent
							
								
									65a82f32be
								
							
						
					
					
						commit
						8823a6c1a1
					
				
					 5 changed files with 35 additions and 3 deletions
				
			
		| 
						 | 
					@ -518,6 +518,7 @@ common/views/components/profile-editor.vue:
 | 
				
			||||||
  is-bot: "このアカウントはBotです"
 | 
					  is-bot: "このアカウントはBotです"
 | 
				
			||||||
  is-locked: "フォローを承認制にする"
 | 
					  is-locked: "フォローを承認制にする"
 | 
				
			||||||
  careful-bot: "Botからのフォローだけ承認制にする"
 | 
					  careful-bot: "Botからのフォローだけ承認制にする"
 | 
				
			||||||
 | 
					  auto-accept-followed: "フォローしているユーザーからのフォローを自動承認する"
 | 
				
			||||||
  advanced: "その他"
 | 
					  advanced: "その他"
 | 
				
			||||||
  privacy: "プライバシー"
 | 
					  privacy: "プライバシー"
 | 
				
			||||||
  save: "保存"
 | 
					  save: "保存"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,6 +70,7 @@
 | 
				
			||||||
		<div>
 | 
							<div>
 | 
				
			||||||
			<ui-switch v-model="isLocked" @change="save(false)">{{ $t('is-locked') }}</ui-switch>
 | 
								<ui-switch v-model="isLocked" @change="save(false)">{{ $t('is-locked') }}</ui-switch>
 | 
				
			||||||
			<ui-switch v-model="carefulBot" @change="save(false)">{{ $t('careful-bot') }}</ui-switch>
 | 
								<ui-switch v-model="carefulBot" @change="save(false)">{{ $t('careful-bot') }}</ui-switch>
 | 
				
			||||||
 | 
								<ui-switch v-model="autoAcceptFollowed" @change="save(false)">{{ $t('auto-accept-followed') }}</ui-switch>
 | 
				
			||||||
		</div>
 | 
							</div>
 | 
				
			||||||
	</section>
 | 
						</section>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -118,6 +119,7 @@ export default Vue.extend({
 | 
				
			||||||
			isBot: false,
 | 
								isBot: false,
 | 
				
			||||||
			isLocked: false,
 | 
								isLocked: false,
 | 
				
			||||||
			carefulBot: false,
 | 
								carefulBot: false,
 | 
				
			||||||
 | 
								autoAcceptFollowed: false,
 | 
				
			||||||
			saving: false,
 | 
								saving: false,
 | 
				
			||||||
			avatarUploading: false,
 | 
								avatarUploading: false,
 | 
				
			||||||
			bannerUploading: false
 | 
								bannerUploading: false
 | 
				
			||||||
| 
						 | 
					@ -156,6 +158,7 @@ export default Vue.extend({
 | 
				
			||||||
		this.isBot = this.$store.state.i.isBot;
 | 
							this.isBot = this.$store.state.i.isBot;
 | 
				
			||||||
		this.isLocked = this.$store.state.i.isLocked;
 | 
							this.isLocked = this.$store.state.i.isLocked;
 | 
				
			||||||
		this.carefulBot = this.$store.state.i.carefulBot;
 | 
							this.carefulBot = this.$store.state.i.carefulBot;
 | 
				
			||||||
 | 
							this.autoAcceptFollowed = this.$store.state.i.autoAcceptFollowed;
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	methods: {
 | 
						methods: {
 | 
				
			||||||
| 
						 | 
					@ -217,7 +220,8 @@ export default Vue.extend({
 | 
				
			||||||
				isCat: !!this.isCat,
 | 
									isCat: !!this.isCat,
 | 
				
			||||||
				isBot: !!this.isBot,
 | 
									isBot: !!this.isBot,
 | 
				
			||||||
				isLocked: !!this.isLocked,
 | 
									isLocked: !!this.isLocked,
 | 
				
			||||||
				carefulBot: !!this.carefulBot
 | 
									carefulBot: !!this.carefulBot,
 | 
				
			||||||
 | 
									autoAcceptFollowed: !!this.autoAcceptFollowed
 | 
				
			||||||
			}).then(i => {
 | 
								}).then(i => {
 | 
				
			||||||
				this.saving = false;
 | 
									this.saving = false;
 | 
				
			||||||
				this.$store.state.i.avatarId = i.avatarId;
 | 
									this.$store.state.i.avatarId = i.avatarId;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,6 +69,11 @@ type IUserBase = {
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	carefulBot: boolean;
 | 
						carefulBot: boolean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * フォローしているユーザーからのフォローリクエストを自動承認するか
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						autoAcceptFollowed: boolean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * このアカウントに届いているフォローリクエストの数
 | 
						 * このアカウントに届いているフォローリクエストの数
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,6 +94,13 @@ export const meta = {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							autoAcceptFollowed: {
 | 
				
			||||||
 | 
								validator: $.bool.optional,
 | 
				
			||||||
 | 
								desc: {
 | 
				
			||||||
 | 
									'ja-JP': 'フォローしているユーザーからのフォローリクエストを自動承認するか'
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		isBot: {
 | 
							isBot: {
 | 
				
			||||||
			validator: $.bool.optional,
 | 
								validator: $.bool.optional,
 | 
				
			||||||
			desc: {
 | 
								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.isLocked == 'boolean') updates.isLocked = ps.isLocked;
 | 
				
			||||||
	if (typeof ps.isBot == 'boolean') updates.isBot = ps.isBot;
 | 
						if (typeof ps.isBot == 'boolean') updates.isBot = ps.isBot;
 | 
				
			||||||
	if (typeof ps.carefulBot == 'boolean') updates.carefulBot = ps.carefulBot;
 | 
						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.isCat == 'boolean') updates.isCat = ps.isCat;
 | 
				
			||||||
	if (typeof ps.autoWatch == 'boolean') updates['settings.autoWatch'] = ps.autoWatch;
 | 
						if (typeof ps.autoWatch == 'boolean') updates['settings.autoWatch'] = ps.autoWatch;
 | 
				
			||||||
	if (typeof ps.alwaysMarkNsfw == 'boolean') updates['settings.alwaysMarkNsfw'] = ps.alwaysMarkNsfw;
 | 
						if (typeof ps.alwaysMarkNsfw == 'boolean') updates['settings.alwaysMarkNsfw'] = ps.alwaysMarkNsfw;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,9 +45,23 @@ export default async function(follower: IUser, followee: IUser, requestId?: stri
 | 
				
			||||||
	// フォロワーがローカルユーザーであり、フォロー対象がリモートユーザーである
 | 
						// フォロワーがローカルユーザーであり、フォロー対象がリモートユーザーである
 | 
				
			||||||
	// 上記のいずれかに当てはまる場合はすぐフォローせずにフォローリクエストを発行しておく
 | 
						// 上記のいずれかに当てはまる場合はすぐフォローせずにフォローリクエストを発行しておく
 | 
				
			||||||
	if (followee.isLocked || (followee.carefulBot && follower.isBot) || (isLocalUser(follower) && isRemoteUser(followee))) {
 | 
						if (followee.isLocked || (followee.carefulBot && follower.isBot) || (isLocalUser(follower) && isRemoteUser(followee))) {
 | 
				
			||||||
 | 
							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);
 | 
								await createFollowRequest(follower, followee, requestId);
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	await Following.insert({
 | 
						await Following.insert({
 | 
				
			||||||
		createdAt: new Date(),
 | 
							createdAt: new Date(),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue