Skip to content

Commit

Permalink
Merge branch 'feat/show-remote-user-required-login' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
4ster1sk committed Dec 30, 2024
2 parents 2f14920 + 7cd77f2 commit caded61
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 1 deletion.
4 changes: 4 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10644,6 +10644,10 @@ export interface Locale extends ILocale {
* Signupの無効化
*/
"disableSignup": string;
/**
* リモートユーザーの表示はログインを必須にする
*/
"requireSigninToViewRemoteUsers": string;
};
"_remoteLookupErrors": {
"_federationNotAllowed": {
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2839,6 +2839,7 @@ _followRequest:
_customizeFeature:
title: "独自機能"
disableSignup: "Signupの無効化"
requireSigninToViewRemoteUsers: "リモートユーザーの表示はログインを必須にする"

_remoteLookupErrors:
_federationNotAllowed:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* SPDX-FileCopyrightText: 4sterisk
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class RequireSigninToViewRemoteUsers1735564157872 {
name = 'RequireSigninToViewRemoteUsers1735564157872'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "requireSigninToViewRemoteUsers" boolean NOT NULL DEFAULT false`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "requireSigninToViewRemoteUsers"`);
}
}
1 change: 1 addition & 0 deletions packages/backend/src/core/entities/MetaEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export class MetaEntityService {
swPublickey: instance.swPublicKey,
themeColor: instance.themeColor,
disableSignup: instance.disableSignup,
requireSigninToViewRemoteUsers: instance.requireSigninToViewRemoteUsers,
mascotImageUrl: instance.mascotImageUrl ?? '/assets/ai.png',
bannerUrl: instance.bannerUrl,
infoImageUrl: instance.infoImageUrl,
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,4 +668,9 @@ export class MiMeta {
default: false,
})
public disableSignup: boolean;

@Column('boolean', {
default: false,
})
public requireSigninToViewRemoteUsers: boolean;
}
4 changes: 4 additions & 0 deletions packages/backend/src/models/json-schema/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export const packedMetaLiteSchema = {
type: 'boolean',
optional: false, nullable: false,
},
requireSigninToViewRemoteUsers: {
type: 'boolean',
optional: false, nullable: false,
},
emailRequiredForSignup: {
type: 'boolean',
optional: false, nullable: false,
Expand Down
5 changes: 5 additions & 0 deletions packages/backend/src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export const meta = {
type: 'boolean',
optional: false, nullable: false,
},
requireSigninToViewRemoteUsers: {
type: 'boolean',
optional: false, nullable: false,
},
cacheRemoteFiles: {
type: 'boolean',
optional: false, nullable: false,
Expand Down Expand Up @@ -572,6 +576,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
privacyPolicyUrl: instance.privacyPolicyUrl,
inquiryUrl: instance.inquiryUrl,
disableSignup: instance.disableSignup,
requireSigninToViewRemoteUsers: instance.requireSigninToViewRemoteUsers,
disableRegistration: instance.disableRegistration,
emailRequiredForSignup: instance.emailRequiredForSignup,
enableHcaptcha: instance.enableHcaptcha,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export const paramDef = {
},
},
disableSignup: { type: 'boolean' },
requireSigninToViewRemoteUsers: { type: 'boolean' },
mismatchUriHosts: {
type: 'array',
items: {
Expand Down Expand Up @@ -318,6 +319,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
set.disableSignup = ps.disableSignup;
}

if (ps.requireSigninToViewRemoteUsers !== undefined) {
set.requireSigninToViewRemoteUsers = ps.requireSigninToViewRemoteUsers;
}

if (ps.cacheRemoteSensitiveFiles !== undefined) {
set.cacheRemoteSensitiveFiles = ps.cacheRemoteSensitiveFiles;
}
Expand Down
7 changes: 7 additions & 0 deletions packages/backend/src/server/api/endpoints/users/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
}

if (me == null && this.serverSettings.requireSigninToViewRemoteUsers) {
const user = await this.cacheService.findUserById(ps.userId);
if (user.host != null) {
return [];
}
}

if (!this.serverSettings.enableFanoutTimeline) {
const timeline = await this.getFromDb({
untilId,
Expand Down
5 changes: 5 additions & 0 deletions packages/frontend/src/pages/admin/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkSwitch v-model="customFeatureForm.state.disableSignup">
<template #label>{{ i18n.ts._customizeFeature.disableSignup }}<span v-if="customFeatureForm.modifiedStates.disableSignup" class="_modified">{{ i18n.ts.modified }}</span></template>
</MkSwitch>
<MkSwitch v-model="customFeatureForm.state.requireSigninToViewRemoteUsers">
<template #label>{{ i18n.ts._customizeFeature.requireSigninToViewRemoteUsers }}<span v-if="customFeatureForm.modifiedStates.requireSigninToViewRemoteUsers" class="_modified">{{ i18n.ts.modified }}</span></template>
</MkSwitch>
</div>
</MkFolder>
</div>
Expand Down Expand Up @@ -345,9 +348,11 @@ const filesForm = useForm({

const customFeatureForm = useForm({
disableSignup: meta.disableSignup,
requireSigninToViewRemoteUsers: meta.requireSigninToViewRemoteUsers,
}, async (state) => {
await os.apiWithDialog('admin/update-meta', {
disableSignup: state.disableSignup,
requireSigninToViewRemoteUsers: state.requireSigninToViewRemoteUsers,
});
fetchInstance(true);
});
Expand Down
2 changes: 2 additions & 0 deletions packages/misskey-js/src/autogen/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ export type UsersSearchRequest = operations['users___search']['requestBody']['co
export type UsersSearchResponse = operations['users___search']['responses']['200']['content']['application/json'];
export type UsersShowRequest = operations['users___show']['requestBody']['content']['application/json'];
export type UsersShowResponse = operations['users___show']['responses']['200']['content']['application/json'];
export type UsersStatsRequest = operations['users___stats']['requestBody']['content']['application/json'];
export type UsersStatsResponse = operations['users___stats']['responses']['200']['content']['application/json'];
export type UsersAchievementsRequest = operations['users___achievements']['requestBody']['content']['application/json'];
export type UsersAchievementsResponse = operations['users___achievements']['responses']['200']['content']['application/json'];
export type UsersUpdateMemoRequest = operations['users___update-memo']['requestBody']['content']['application/json'];
Expand Down
96 changes: 95 additions & 1 deletion packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3547,6 +3547,15 @@ export type paths = {
*/
post: operations['users___show'];
};
'/users/stats': {
/**
* users/stats
* @description Show statistics about a user.
*
* **Credential required**: *No*
*/
post: operations['users___stats'];
};
'/users/achievements': {
/**
* users/achievements
Expand Down Expand Up @@ -4977,6 +4986,7 @@ export type components = {
defaultLightTheme: string | null;
disableRegistration: boolean;
disableSignup: boolean;
requireSigninToViewRemoteUsers: boolean;
emailRequiredForSignup: boolean;
enableHcaptcha: boolean;
hcaptchaSiteKey: string | null;
Expand Down Expand Up @@ -5107,6 +5117,7 @@ export type operations = {
content: {
'application/json': {
disableSignup: boolean;
requireSigninToViewRemoteUsers: boolean;
cacheRemoteFiles: boolean;
cacheRemoteSensitiveFiles: boolean;
emailRequiredForSignup: boolean;
Expand Down Expand Up @@ -9607,6 +9618,7 @@ export type operations = {
federation?: 'all' | 'none' | 'specified';
federationHosts?: string[];
disableSignup?: boolean;
requireSigninToViewRemoteUsers?: boolean;
mismatchUriHosts?: string[];
};
};
Expand Down Expand Up @@ -13974,6 +13986,8 @@ export type operations = {
type?: string | null;
/** @enum {string|null} */
sort?: '+createdAt' | '-createdAt' | '+name' | '-name' | '+size' | '-size' | null;
/** @default */
searchQuery?: string;
};
};
};
Expand Down Expand Up @@ -14573,6 +14587,8 @@ export type operations = {
* @default null
*/
folderId?: string | null;
/** @default */
searchQuery?: string;
};
};
};
Expand Down Expand Up @@ -27102,14 +27118,92 @@ export type operations = {
username?: string;
/** @description The local host is represented with `null`. */
host?: string | null;
/** @default true */
detailed?: boolean;
};
};
};
responses: {
/** @description OK (with results) */
200: {
content: {
'application/json': components['schemas']['UserDetailed'] | components['schemas']['UserDetailed'][];
'application/json': components['schemas']['UserLite'] | components['schemas']['UserDetailed'] | components['schemas']['UserLite'][] | components['schemas']['UserDetailed'][];
};
};
/** @description Client error */
400: {
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description Authentication error */
401: {
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description Forbidden error */
403: {
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description I'm Ai */
418: {
content: {
'application/json': components['schemas']['Error'];
};
};
/** @description Internal server error */
500: {
content: {
'application/json': components['schemas']['Error'];
};
};
};
};
/**
* users/stats
* @description Show statistics about a user.
*
* **Credential required**: *No*
*/
users___stats: {
requestBody: {
content: {
'application/json': {
/** Format: misskey:id */
userId: string;
};
};
};
responses: {
/** @description OK (with results) */
200: {
content: {
'application/json': {
notesCount: number;
repliesCount: number;
renotesCount: number;
repliedCount: number;
renotedCount: number;
pollVotesCount: number;
pollVotedCount: number;
localFollowingCount: number;
remoteFollowingCount: number;
localFollowersCount: number;
remoteFollowersCount: number;
followingCount: number;
followersCount: number;
sentReactionsCount: number;
receivedReactionsCount: number;
noteFavoritesCount: number;
pageLikesCount: number;
pageLikedCount: number;
driveFilesCount: number;
/** @description Drive usage in bytes */
driveUsage: number;
};
};
};
/** @description Client error */
Expand Down

0 comments on commit caded61

Please sign in to comment.