feat: デフォルトでフォローするユーザーを指定できるように
This commit is contained in:
parent
825d218692
commit
e06a6a1f19
32
locales/index.d.ts
vendored
32
locales/index.d.ts
vendored
|
@ -5190,6 +5190,38 @@ export interface Locale extends ILocale {
|
||||||
* 名前に禁止されている文字列が含まれています。この名前を使用したい場合は、サーバー管理者にお問い合わせください。
|
* 名前に禁止されている文字列が含まれています。この名前を使用したい場合は、サーバー管理者にお問い合わせください。
|
||||||
*/
|
*/
|
||||||
"yourNameContainsProhibitedWordsDescription": string;
|
"yourNameContainsProhibitedWordsDescription": string;
|
||||||
|
/**
|
||||||
|
* デフォルトでフォローするユーザー
|
||||||
|
*/
|
||||||
|
"defaultFollowedUsers": string;
|
||||||
|
/**
|
||||||
|
* 今後アカウントが作成された際に自動でフォローされるユーザー(解除可能)を改行区切りで指定します。
|
||||||
|
*/
|
||||||
|
"defaultFollowedUsersDescription": string;
|
||||||
|
/**
|
||||||
|
* 交流を断てないユーザー
|
||||||
|
*/
|
||||||
|
"permanentFollowedUsers": string;
|
||||||
|
/**
|
||||||
|
* 今後アカウントが作成された際には自動でフォローされ、フォローの解除やミュート・ブロックができないユーザーを改行区切りで指定します。
|
||||||
|
*/
|
||||||
|
"permanentFollowedUsersDescription": string;
|
||||||
|
/**
|
||||||
|
* 「デフォルトでフォローするユーザー」と「交流を絶てないユーザー」が重複しています。
|
||||||
|
*/
|
||||||
|
"defaultFollowedUsersDuplicated": string;
|
||||||
|
/**
|
||||||
|
* サーバー管理者はこのユーザーをフォロー解除することを禁止しています。
|
||||||
|
*/
|
||||||
|
"unfollowThisUserIsProhibited": string;
|
||||||
|
/**
|
||||||
|
* サーバー管理者はこのユーザーをブロックすることを禁止しています。
|
||||||
|
*/
|
||||||
|
"blockThisUserIsProhibited": string;
|
||||||
|
/**
|
||||||
|
* サーバー管理者はこのユーザーをミュートすることを禁止しています。
|
||||||
|
*/
|
||||||
|
"muteThisUserIsProhibited": string;
|
||||||
"_abuseUserReport": {
|
"_abuseUserReport": {
|
||||||
/**
|
/**
|
||||||
* 転送
|
* 転送
|
||||||
|
|
|
@ -1293,6 +1293,14 @@ prohibitedWordsForNameOfUser: "禁止ワード(ユーザーの名前)"
|
||||||
prohibitedWordsForNameOfUserDescription: "このリストに含まれる文字列がユーザーの名前に含まれる場合、ユーザーの名前の変更を拒否します。モデレーター権限を持つユーザーはこの制限の影響を受けません。"
|
prohibitedWordsForNameOfUserDescription: "このリストに含まれる文字列がユーザーの名前に含まれる場合、ユーザーの名前の変更を拒否します。モデレーター権限を持つユーザーはこの制限の影響を受けません。"
|
||||||
yourNameContainsProhibitedWords: "変更しようとした名前に禁止された文字列が含まれています"
|
yourNameContainsProhibitedWords: "変更しようとした名前に禁止された文字列が含まれています"
|
||||||
yourNameContainsProhibitedWordsDescription: "名前に禁止されている文字列が含まれています。この名前を使用したい場合は、サーバー管理者にお問い合わせください。"
|
yourNameContainsProhibitedWordsDescription: "名前に禁止されている文字列が含まれています。この名前を使用したい場合は、サーバー管理者にお問い合わせください。"
|
||||||
|
defaultFollowedUsers: "デフォルトでフォローするユーザー"
|
||||||
|
defaultFollowedUsersDescription: "今後アカウントが作成された際に自動でフォローされるユーザー(解除可能)を改行区切りで指定します。"
|
||||||
|
permanentFollowedUsers: "交流を断てないユーザー"
|
||||||
|
permanentFollowedUsersDescription: "今後アカウントが作成された際には自動でフォローされ、フォローの解除やミュート・ブロックができないユーザーを改行区切りで指定します。"
|
||||||
|
defaultFollowedUsersDuplicated: "「デフォルトでフォローするユーザー」と「交流を絶てないユーザー」が重複しています。"
|
||||||
|
unfollowThisUserIsProhibited: "サーバー管理者はこのユーザーをフォロー解除することを禁止しています。"
|
||||||
|
blockThisUserIsProhibited: "サーバー管理者はこのユーザーをブロックすることを禁止しています。"
|
||||||
|
muteThisUserIsProhibited: "サーバー管理者はこのユーザーをミュートすることを禁止しています。"
|
||||||
|
|
||||||
_abuseUserReport:
|
_abuseUserReport:
|
||||||
forward: "転送"
|
forward: "転送"
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class DefaultFollowUsers1728986848483 {
|
||||||
|
name = 'defaultFollowUsers1728986848483'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "defaultFollowedUsers" character varying(1024) array NOT NULL DEFAULT '{}'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" ADD "permanentFollowedUsers" character varying(1024) array NOT NULL DEFAULT '{}'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "permanentFollowedUsers"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "defaultFollowedUsers"`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import { bindThis } from '@/decorators.js';
|
||||||
import UsersChart from '@/core/chart/charts/users.js';
|
import UsersChart from '@/core/chart/charts/users.js';
|
||||||
import { UtilityService } from '@/core/UtilityService.js';
|
import { UtilityService } from '@/core/UtilityService.js';
|
||||||
import { UserService } from '@/core/UserService.js';
|
import { UserService } from '@/core/UserService.js';
|
||||||
|
import { UserFollowingService } from '@/core/UserFollowingService.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SignupService {
|
export class SignupService {
|
||||||
|
@ -39,6 +40,7 @@ export class SignupService {
|
||||||
|
|
||||||
private utilityService: UtilityService,
|
private utilityService: UtilityService,
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
|
private userFollowingService: UserFollowingService,
|
||||||
private userEntityService: UserEntityService,
|
private userEntityService: UserEntityService,
|
||||||
private idService: IdService,
|
private idService: IdService,
|
||||||
private instanceActorService: InstanceActorService,
|
private instanceActorService: InstanceActorService,
|
||||||
|
@ -151,6 +153,23 @@ export class SignupService {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.usersChart.update(account, true);
|
this.usersChart.update(account, true);
|
||||||
|
|
||||||
|
//#region Default following
|
||||||
|
if (
|
||||||
|
!isTheFirstUser &&
|
||||||
|
(this.meta.defaultFollowedUsers.length > 0 || this.meta.permanentFollowedUsers.length > 0)
|
||||||
|
) {
|
||||||
|
const userIdsToFollow = [
|
||||||
|
...this.meta.defaultFollowedUsers,
|
||||||
|
...this.meta.permanentFollowedUsers,
|
||||||
|
];
|
||||||
|
|
||||||
|
await Promise.allSettled(userIdsToFollow.map(async userId => {
|
||||||
|
await this.userFollowingService.follow(account, { id: userId });
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
this.userService.notifySystemWebhook(account, 'userCreated');
|
this.userService.notifySystemWebhook(account, 'userCreated');
|
||||||
|
|
||||||
return { account, secret };
|
return { account, secret };
|
||||||
|
|
|
@ -61,6 +61,22 @@ export class MiMeta {
|
||||||
})
|
})
|
||||||
public pinnedUsers: string[];
|
public pinnedUsers: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* アカウント作成の段階でデフォルトでフォローしているユーザー(あとから解除可能)
|
||||||
|
*/
|
||||||
|
@Column('varchar', {
|
||||||
|
length: 1024, array: true, default: '{}',
|
||||||
|
})
|
||||||
|
public defaultFollowedUsers: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* デフォルトでフォローしていて、フォロー解除・ブロック・ミュートができないユーザー
|
||||||
|
*/
|
||||||
|
@Column('varchar', {
|
||||||
|
length: 1024, array: true, default: '{}',
|
||||||
|
})
|
||||||
|
public permanentFollowedUsers: string[];
|
||||||
|
|
||||||
@Column('varchar', {
|
@Column('varchar', {
|
||||||
length: 1024, array: true, default: '{}',
|
length: 1024, array: true, default: '{}',
|
||||||
})
|
})
|
||||||
|
|
|
@ -149,6 +149,20 @@ export const meta = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
defaultFollowedUsers: {
|
||||||
|
type: 'array',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
items: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
permanentFollowedUsers: {
|
||||||
|
type: 'array',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
items: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
},
|
||||||
hiddenTags: {
|
hiddenTags: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
|
@ -591,6 +605,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
cacheRemoteFiles: instance.cacheRemoteFiles,
|
cacheRemoteFiles: instance.cacheRemoteFiles,
|
||||||
cacheRemoteSensitiveFiles: instance.cacheRemoteSensitiveFiles,
|
cacheRemoteSensitiveFiles: instance.cacheRemoteSensitiveFiles,
|
||||||
pinnedUsers: instance.pinnedUsers,
|
pinnedUsers: instance.pinnedUsers,
|
||||||
|
defaultFollowedUsers: instance.defaultFollowedUsers,
|
||||||
|
permanentFollowedUsers: instance.permanentFollowedUsers,
|
||||||
hiddenTags: instance.hiddenTags,
|
hiddenTags: instance.hiddenTags,
|
||||||
blockedHosts: instance.blockedHosts,
|
blockedHosts: instance.blockedHosts,
|
||||||
silencedHosts: instance.silencedHosts,
|
silencedHosts: instance.silencedHosts,
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable, Inject } from '@nestjs/common';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { MiMeta } from '@/models/Meta.js';
|
import type { MiMeta } from '@/models/Meta.js';
|
||||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
|
import { ApiError } from '../../error.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -15,6 +17,14 @@ export const meta = {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireAdmin: true,
|
requireAdmin: true,
|
||||||
kind: 'write:admin:meta',
|
kind: 'write:admin:meta',
|
||||||
|
|
||||||
|
errors: {
|
||||||
|
followedUserDuplicated: {
|
||||||
|
message: 'Some items in "defaultFollowedUsers" and "permanentFollowedUsers" are duplicated.',
|
||||||
|
code: 'FOLLOWED_USER_DUPLICATED',
|
||||||
|
id: 'bcf088ec-fec5-42d0-8b9e-16d3b4797a4d',
|
||||||
|
},
|
||||||
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const paramDef = {
|
export const paramDef = {
|
||||||
|
@ -26,6 +36,16 @@ export const paramDef = {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
defaultFollowedUsers: {
|
||||||
|
type: 'array', nullable: true, items: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
permanentFollowedUsers: {
|
||||||
|
type: 'array', nullable: true, items: {
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
},
|
||||||
hiddenTags: {
|
hiddenTags: {
|
||||||
type: 'array', nullable: true, items: {
|
type: 'array', nullable: true, items: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -192,6 +212,9 @@ export const paramDef = {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||||
constructor(
|
constructor(
|
||||||
|
@Inject(DI.meta)
|
||||||
|
private serverSettings: MiMeta,
|
||||||
|
|
||||||
private metaService: MetaService,
|
private metaService: MetaService,
|
||||||
private moderationLogService: ModerationLogService,
|
private moderationLogService: ModerationLogService,
|
||||||
) {
|
) {
|
||||||
|
@ -206,6 +229,22 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
set.pinnedUsers = ps.pinnedUsers.filter(Boolean);
|
set.pinnedUsers = ps.pinnedUsers.filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(ps.defaultFollowedUsers)) {
|
||||||
|
if (ps.defaultFollowedUsers.some(x => this.serverSettings.permanentFollowedUsers.includes(x) || ps.permanentFollowedUsers?.includes(x))) {
|
||||||
|
throw new ApiError(meta.errors.followedUserDuplicated);
|
||||||
|
}
|
||||||
|
|
||||||
|
set.defaultFollowedUsers = ps.defaultFollowedUsers.filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(ps.permanentFollowedUsers)) {
|
||||||
|
if (ps.permanentFollowedUsers.some(x => this.serverSettings.defaultFollowedUsers.includes(x) || ps.defaultFollowedUsers?.includes(x))) {
|
||||||
|
throw new ApiError(meta.errors.followedUserDuplicated);
|
||||||
|
}
|
||||||
|
|
||||||
|
set.permanentFollowedUsers = ps.permanentFollowedUsers.filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
if (Array.isArray(ps.hiddenTags)) {
|
if (Array.isArray(ps.hiddenTags)) {
|
||||||
set.hiddenTags = ps.hiddenTags.filter(Boolean);
|
set.hiddenTags = ps.hiddenTags.filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,10 @@ import ms from 'ms';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { UsersRepository, BlockingsRepository } from '@/models/_.js';
|
import type { UsersRepository, BlockingsRepository } from '@/models/_.js';
|
||||||
|
import type { MiMeta } from '@/models/Meta.js';
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { UserBlockingService } from '@/core/UserBlockingService.js';
|
import { UserBlockingService } from '@/core/UserBlockingService.js';
|
||||||
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { GetterService } from '@/server/api/GetterService.js';
|
import { GetterService } from '@/server/api/GetterService.js';
|
||||||
import { ApiError } from '../../error.js';
|
import { ApiError } from '../../error.js';
|
||||||
|
@ -43,6 +45,13 @@ export const meta = {
|
||||||
code: 'ALREADY_BLOCKING',
|
code: 'ALREADY_BLOCKING',
|
||||||
id: '787fed64-acb9-464a-82eb-afbd745b9614',
|
id: '787fed64-acb9-464a-82eb-afbd745b9614',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cannotBlockDueToServerPolicy: {
|
||||||
|
message: 'You cannot block that user due to server policy.',
|
||||||
|
code: 'CANNOT_BLOCK_DUE_TO_SERVER_POLICY',
|
||||||
|
id: 'e2f04d25-0d94-4ac3-a4d8-ba401062741b',
|
||||||
|
httpStatusCode: 403,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
|
@ -63,12 +72,16 @@ export const paramDef = {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||||
constructor(
|
constructor(
|
||||||
|
@Inject(DI.meta)
|
||||||
|
private serverSettings: MiMeta,
|
||||||
|
|
||||||
@Inject(DI.usersRepository)
|
@Inject(DI.usersRepository)
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
@Inject(DI.blockingsRepository)
|
@Inject(DI.blockingsRepository)
|
||||||
private blockingsRepository: BlockingsRepository,
|
private blockingsRepository: BlockingsRepository,
|
||||||
|
|
||||||
|
private roleService: RoleService,
|
||||||
private userEntityService: UserEntityService,
|
private userEntityService: UserEntityService,
|
||||||
private getterService: GetterService,
|
private getterService: GetterService,
|
||||||
private userBlockingService: UserBlockingService,
|
private userBlockingService: UserBlockingService,
|
||||||
|
@ -99,6 +112,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
throw new ApiError(meta.errors.alreadyBlocking);
|
throw new ApiError(meta.errors.alreadyBlocking);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.serverSettings.permanentFollowedUsers.includes(blockee.id) &&
|
||||||
|
!await this.roleService.isModerator(blocker)
|
||||||
|
) {
|
||||||
|
throw new ApiError(meta.errors.cannotBlockDueToServerPolicy);
|
||||||
|
}
|
||||||
|
|
||||||
await this.userBlockingService.block(blocker, blockee);
|
await this.userBlockingService.block(blocker, blockee);
|
||||||
|
|
||||||
return await this.userEntityService.pack(blockee.id, blocker, {
|
return await this.userEntityService.pack(blockee.id, blocker, {
|
||||||
|
|
|
@ -7,8 +7,10 @@ import ms from 'ms';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { FollowingsRepository } from '@/models/_.js';
|
import type { FollowingsRepository } from '@/models/_.js';
|
||||||
|
import type { MiMeta } from '@/models/Meta.js';
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { UserFollowingService } from '@/core/UserFollowingService.js';
|
import { UserFollowingService } from '@/core/UserFollowingService.js';
|
||||||
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { GetterService } from '@/server/api/GetterService.js';
|
import { GetterService } from '@/server/api/GetterService.js';
|
||||||
import { ApiError } from '../../error.js';
|
import { ApiError } from '../../error.js';
|
||||||
|
@ -43,6 +45,13 @@ export const meta = {
|
||||||
code: 'NOT_FOLLOWING',
|
code: 'NOT_FOLLOWING',
|
||||||
id: '5dbf82f5-c92b-40b1-87d1-6c8c0741fd09',
|
id: '5dbf82f5-c92b-40b1-87d1-6c8c0741fd09',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cannotUnfollowDueToServerPolicy: {
|
||||||
|
message: 'You cannot unfollow that user due to server policy.',
|
||||||
|
code: 'CANNOT_UNFOLLOW_DUE_TO_SERVER_POLICY',
|
||||||
|
id: '19f25f61-0141-4683-99dc-217a88d633cb',
|
||||||
|
httpStatusCode: 403,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
|
@ -63,9 +72,13 @@ export const paramDef = {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||||
constructor(
|
constructor(
|
||||||
|
@Inject(DI.meta)
|
||||||
|
private serverSettings: MiMeta,
|
||||||
|
|
||||||
@Inject(DI.followingsRepository)
|
@Inject(DI.followingsRepository)
|
||||||
private followingsRepository: FollowingsRepository,
|
private followingsRepository: FollowingsRepository,
|
||||||
|
|
||||||
|
private roleService: RoleService,
|
||||||
private userEntityService: UserEntityService,
|
private userEntityService: UserEntityService,
|
||||||
private getterService: GetterService,
|
private getterService: GetterService,
|
||||||
private userFollowingService: UserFollowingService,
|
private userFollowingService: UserFollowingService,
|
||||||
|
@ -96,6 +109,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
throw new ApiError(meta.errors.notFollowing);
|
throw new ApiError(meta.errors.notFollowing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.serverSettings.permanentFollowedUsers.includes(followee.id) &&
|
||||||
|
!await this.roleService.isModerator(follower)
|
||||||
|
) {
|
||||||
|
throw new ApiError(meta.errors.cannotUnfollowDueToServerPolicy);
|
||||||
|
}
|
||||||
|
|
||||||
await this.userFollowingService.unfollow(follower, followee);
|
await this.userFollowingService.unfollow(follower, followee);
|
||||||
|
|
||||||
return await this.userEntityService.pack(followee.id, me);
|
return await this.userEntityService.pack(followee.id, me);
|
||||||
|
|
|
@ -7,9 +7,11 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||||
import ms from 'ms';
|
import ms from 'ms';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { MutingsRepository } from '@/models/_.js';
|
import type { MutingsRepository } from '@/models/_.js';
|
||||||
|
import type { MiMeta } from '@/models/Meta.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { GetterService } from '@/server/api/GetterService.js';
|
import { GetterService } from '@/server/api/GetterService.js';
|
||||||
import { UserMutingService } from '@/core/UserMutingService.js';
|
import { UserMutingService } from '@/core/UserMutingService.js';
|
||||||
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import { ApiError } from '../../error.js';
|
import { ApiError } from '../../error.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -43,6 +45,13 @@ export const meta = {
|
||||||
code: 'ALREADY_MUTING',
|
code: 'ALREADY_MUTING',
|
||||||
id: '7e7359cb-160c-4956-b08f-4d1c653cd007',
|
id: '7e7359cb-160c-4956-b08f-4d1c653cd007',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cannotMuteDueToServerPolicy: {
|
||||||
|
message: 'You cannot mute that user due to server policy.',
|
||||||
|
code: 'CANNOT_MUTE_DUE_TO_SERVER_POLICY',
|
||||||
|
id: '15273a89-374d-49fa-8df6-8bb3feeea455',
|
||||||
|
httpStatusCode: 403,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -62,9 +71,13 @@ export const paramDef = {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||||
constructor(
|
constructor(
|
||||||
|
@Inject(DI.meta)
|
||||||
|
private serverSettings: MiMeta,
|
||||||
|
|
||||||
@Inject(DI.mutingsRepository)
|
@Inject(DI.mutingsRepository)
|
||||||
private mutingsRepository: MutingsRepository,
|
private mutingsRepository: MutingsRepository,
|
||||||
|
|
||||||
|
private roleService: RoleService,
|
||||||
private getterService: GetterService,
|
private getterService: GetterService,
|
||||||
private userMutingService: UserMutingService,
|
private userMutingService: UserMutingService,
|
||||||
) {
|
) {
|
||||||
|
@ -94,6 +107,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
throw new ApiError(meta.errors.alreadyMuting);
|
throw new ApiError(meta.errors.alreadyMuting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.serverSettings.permanentFollowedUsers.includes(mutee.id) &&
|
||||||
|
!await this.roleService.isModerator(muter)
|
||||||
|
) {
|
||||||
|
throw new ApiError(meta.errors.cannotMuteDueToServerPolicy);
|
||||||
|
}
|
||||||
|
|
||||||
if (ps.expiresAt && ps.expiresAt <= Date.now()) {
|
if (ps.expiresAt && ps.expiresAt <= Date.now()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,10 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { GetterService } from '@/server/api/GetterService.js';
|
import { GetterService } from '@/server/api/GetterService.js';
|
||||||
import { ApiError } from '../../error.js';
|
import { ApiError } from '../../error.js';
|
||||||
import { UserRenoteMutingService } from "@/core/UserRenoteMutingService.js";
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
|
import { UserRenoteMutingService } from '@/core/UserRenoteMutingService.js';
|
||||||
import type { RenoteMutingsRepository } from '@/models/_.js';
|
import type { RenoteMutingsRepository } from '@/models/_.js';
|
||||||
|
import type { MiMeta } from '@/models/Meta.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['account'],
|
tags: ['account'],
|
||||||
|
@ -43,6 +45,13 @@ export const meta = {
|
||||||
code: 'ALREADY_MUTING',
|
code: 'ALREADY_MUTING',
|
||||||
id: 'ccfecbe4-1f1c-4fc2-8a3d-c3ffee61cb7b',
|
id: 'ccfecbe4-1f1c-4fc2-8a3d-c3ffee61cb7b',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cannotMuteDueToServerPolicy: {
|
||||||
|
message: 'You cannot mute that user due to server policy.',
|
||||||
|
code: 'CANNOT_MUTE_DUE_TO_SERVER_POLICY',
|
||||||
|
id: '15273a89-374d-49fa-8df6-8bb3feeea455',
|
||||||
|
httpStatusCode: 403,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -57,9 +66,13 @@ export const paramDef = {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||||
constructor(
|
constructor(
|
||||||
|
@Inject(DI.meta)
|
||||||
|
private serverSettings: MiMeta,
|
||||||
|
|
||||||
@Inject(DI.renoteMutingsRepository)
|
@Inject(DI.renoteMutingsRepository)
|
||||||
private renoteMutingsRepository: RenoteMutingsRepository,
|
private renoteMutingsRepository: RenoteMutingsRepository,
|
||||||
|
|
||||||
|
private roleService: RoleService,
|
||||||
private getterService: GetterService,
|
private getterService: GetterService,
|
||||||
private userRenoteMutingService: UserRenoteMutingService,
|
private userRenoteMutingService: UserRenoteMutingService,
|
||||||
) {
|
) {
|
||||||
|
@ -89,6 +102,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
throw new ApiError(meta.errors.alreadyMuting);
|
throw new ApiError(meta.errors.alreadyMuting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.serverSettings.permanentFollowedUsers.includes(mutee.id) &&
|
||||||
|
!await this.roleService.isModerator(muter)
|
||||||
|
) {
|
||||||
|
throw new ApiError(meta.errors.cannotMuteDueToServerPolicy);
|
||||||
|
}
|
||||||
|
|
||||||
// Create mute
|
// Create mute
|
||||||
await this.userRenoteMutingService.mute(muter, mutee);
|
await this.userRenoteMutingService.mute(muter, mutee);
|
||||||
});
|
});
|
||||||
|
|
|
@ -95,6 +95,14 @@ async function onClick() {
|
||||||
|
|
||||||
await misskeyApi('following/delete', {
|
await misskeyApi('following/delete', {
|
||||||
userId: props.user.id,
|
userId: props.user.id,
|
||||||
|
}).catch((err) => {
|
||||||
|
if (err.id === '19f25f61-0141-4683-99dc-217a88d633cb') {
|
||||||
|
os.alert({
|
||||||
|
type: 'error',
|
||||||
|
title: i18n.ts.permissionDeniedError,
|
||||||
|
text: i18n.ts.unfollowThisUserProhibited,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (defaultStore.state.alwaysConfirmFollow) {
|
if (defaultStore.state.alwaysConfirmFollow) {
|
||||||
|
|
|
@ -33,6 +33,23 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
</MkFolder>
|
</MkFolder>
|
||||||
|
|
||||||
|
<MkFolder>
|
||||||
|
<template #icon><i class="ti ti-user-star"></i></template>
|
||||||
|
<template #label>{{ i18n.ts.defaultFollowedUsers }}</template>
|
||||||
|
|
||||||
|
<div class="_gaps">
|
||||||
|
<MkTextarea v-model="defaultFollowedUsers">
|
||||||
|
<template #label>{{ i18n.ts.defaultFollowedUsers }}</template>
|
||||||
|
<template #caption>{{ i18n.ts.defaultFollowedUsersDescription }}</template>
|
||||||
|
</MkTextarea>
|
||||||
|
<MkTextarea v-model="permanentFollowedUsers">
|
||||||
|
<template #label>{{ i18n.ts.permanentFollowedUsers }}</template>
|
||||||
|
<template #caption>{{ i18n.ts.permanentFollowedUsersDescription }}</template>
|
||||||
|
</MkTextarea>
|
||||||
|
<MkButton primary @click="save_defaultUsers">{{ i18n.ts.save }}</MkButton>
|
||||||
|
</div>
|
||||||
|
</MkFolder>
|
||||||
|
|
||||||
<MkFolder>
|
<MkFolder>
|
||||||
<template #icon><i class="ti ti-message-exclamation"></i></template>
|
<template #icon><i class="ti ti-message-exclamation"></i></template>
|
||||||
<template #label>{{ i18n.ts.sensitiveWords }}</template>
|
<template #label>{{ i18n.ts.sensitiveWords }}</template>
|
||||||
|
@ -146,6 +163,8 @@ const prohibitedWords = ref<string>('');
|
||||||
const prohibitedWordsForNameOfUser = ref<string>('');
|
const prohibitedWordsForNameOfUser = ref<string>('');
|
||||||
const hiddenTags = ref<string>('');
|
const hiddenTags = ref<string>('');
|
||||||
const preservedUsernames = ref<string>('');
|
const preservedUsernames = ref<string>('');
|
||||||
|
const defaultFollowedUsers = ref<string>('');
|
||||||
|
const permanentFollowedUsers = ref<string>('');
|
||||||
const blockedHosts = ref<string>('');
|
const blockedHosts = ref<string>('');
|
||||||
const silencedHosts = ref<string>('');
|
const silencedHosts = ref<string>('');
|
||||||
const mediaSilencedHosts = ref<string>('');
|
const mediaSilencedHosts = ref<string>('');
|
||||||
|
@ -159,6 +178,8 @@ async function init() {
|
||||||
prohibitedWordsForNameOfUser.value = meta.prohibitedWordsForNameOfUser.join('\n');
|
prohibitedWordsForNameOfUser.value = meta.prohibitedWordsForNameOfUser.join('\n');
|
||||||
hiddenTags.value = meta.hiddenTags.join('\n');
|
hiddenTags.value = meta.hiddenTags.join('\n');
|
||||||
preservedUsernames.value = meta.preservedUsernames.join('\n');
|
preservedUsernames.value = meta.preservedUsernames.join('\n');
|
||||||
|
defaultFollowedUsers.value = meta.defaultFollowedUsers.join('\n');
|
||||||
|
permanentFollowedUsers.value = meta.permanentFollowedUsers.join('\n');
|
||||||
blockedHosts.value = meta.blockedHosts.join('\n');
|
blockedHosts.value = meta.blockedHosts.join('\n');
|
||||||
silencedHosts.value = meta.silencedHosts?.join('\n') ?? '';
|
silencedHosts.value = meta.silencedHosts?.join('\n') ?? '';
|
||||||
mediaSilencedHosts.value = meta.mediaSilencedHosts.join('\n');
|
mediaSilencedHosts.value = meta.mediaSilencedHosts.join('\n');
|
||||||
|
@ -188,6 +209,19 @@ function save_preservedUsernames() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function save_defaultUsers() {
|
||||||
|
os.apiWithDialog('admin/update-meta', {
|
||||||
|
defaultFollowedUsers: defaultFollowedUsers.value.split('\n'),
|
||||||
|
permanentFollowedUsers: permanentFollowedUsers.value.split('\n'),
|
||||||
|
}, undefined, {
|
||||||
|
'bcf088ec-fec5-42d0-8b9e-16d3b4797a4d': {
|
||||||
|
text: i18n.ts.defaultFollowedUsersDuplicated,
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
fetchInstance(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function save_sensitiveWords() {
|
function save_sensitiveWords() {
|
||||||
os.apiWithDialog('admin/update-meta', {
|
os.apiWithDialog('admin/update-meta', {
|
||||||
sensitiveWords: sensitiveWords.value.split('\n'),
|
sensitiveWords: sensitiveWords.value.split('\n'),
|
||||||
|
|
|
@ -60,6 +60,11 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
|
||||||
os.apiWithDialog('mute/create', {
|
os.apiWithDialog('mute/create', {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
expiresAt,
|
expiresAt,
|
||||||
|
}, undefined, {
|
||||||
|
'15273a89-374d-49fa-8df6-8bb3feeea455': {
|
||||||
|
title: i18n.ts.permissionDeniedError,
|
||||||
|
text: i18n.ts.muteThisUserIsProhibited,
|
||||||
|
},
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
user.isMuted = true;
|
user.isMuted = true;
|
||||||
});
|
});
|
||||||
|
@ -69,6 +74,11 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
|
||||||
async function toggleRenoteMute() {
|
async function toggleRenoteMute() {
|
||||||
os.apiWithDialog(user.isRenoteMuted ? 'renote-mute/delete' : 'renote-mute/create', {
|
os.apiWithDialog(user.isRenoteMuted ? 'renote-mute/delete' : 'renote-mute/create', {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
}, undefined, {
|
||||||
|
'15273a89-374d-49fa-8df6-8bb3feeea455': {
|
||||||
|
title: i18n.ts.permissionDeniedError,
|
||||||
|
text: i18n.ts.muteThisUserIsProhibited,
|
||||||
|
},
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
user.isRenoteMuted = !user.isRenoteMuted;
|
user.isRenoteMuted = !user.isRenoteMuted;
|
||||||
});
|
});
|
||||||
|
@ -79,6 +89,11 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter
|
||||||
|
|
||||||
os.apiWithDialog(user.isBlocking ? 'blocking/delete' : 'blocking/create', {
|
os.apiWithDialog(user.isBlocking ? 'blocking/delete' : 'blocking/create', {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
}, undefined, {
|
||||||
|
'e2f04d25-0d94-4ac3-a4d8-ba401062741b': {
|
||||||
|
title: i18n.ts.permissionDeniedError,
|
||||||
|
text: i18n.ts.blockThisUserIsProhibited,
|
||||||
|
},
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
user.isBlocking = !user.isBlocking;
|
user.isBlocking = !user.isBlocking;
|
||||||
});
|
});
|
||||||
|
|
|
@ -5120,6 +5120,8 @@ export type operations = {
|
||||||
silencedHosts?: string[];
|
silencedHosts?: string[];
|
||||||
mediaSilencedHosts: string[];
|
mediaSilencedHosts: string[];
|
||||||
pinnedUsers: string[];
|
pinnedUsers: string[];
|
||||||
|
defaultFollowedUsers: string[];
|
||||||
|
permanentFollowedUsers: string[];
|
||||||
hiddenTags: string[];
|
hiddenTags: string[];
|
||||||
blockedHosts: string[];
|
blockedHosts: string[];
|
||||||
sensitiveWords: string[];
|
sensitiveWords: string[];
|
||||||
|
@ -9459,6 +9461,8 @@ export type operations = {
|
||||||
'application/json': {
|
'application/json': {
|
||||||
disableRegistration?: boolean | null;
|
disableRegistration?: boolean | null;
|
||||||
pinnedUsers?: string[] | null;
|
pinnedUsers?: string[] | null;
|
||||||
|
defaultFollowedUsers?: string[] | null;
|
||||||
|
permanentFollowedUsers?: string[] | null;
|
||||||
hiddenTags?: string[] | null;
|
hiddenTags?: string[] | null;
|
||||||
blockedHosts?: string[] | null;
|
blockedHosts?: string[] | null;
|
||||||
sensitiveWords?: string[] | null;
|
sensitiveWords?: string[] | null;
|
||||||
|
|
Loading…
Reference in a new issue