Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Server rules #10660

Merged
merged 32 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3c74109
enhance(frontend): サーバールールのデザイン調整
EbiseLutica Apr 14, 2023
6adc7de
enhance(frontend): i18n
EbiseLutica Apr 14, 2023
555fe1c
enhance(frontend): 利用規約URLの設定を「モデレーション」ページへ移動
EbiseLutica Apr 14, 2023
65034a9
enhance(frontend): サーバールールのデザイン調整
EbiseLutica Apr 14, 2023
9579de9
Update CHANGELOG.md
EbiseLutica Apr 14, 2023
9f7b30e
不要な差分を削除
EbiseLutica Apr 14, 2023
1e89887
fix(frontend): lint
EbiseLutica Apr 14, 2023
b3705fd
Merge branch 'develop' into feature/serverRules
EbiseLutica Apr 16, 2023
8f7bb03
Merge branch 'develop' into pr/10633
syuilo Apr 17, 2023
6e6af04
ui tweak
syuilo Apr 17, 2023
d243ccf
test: add stories
acid-chicken Apr 17, 2023
c847381
tweak
syuilo Apr 17, 2023
d1d5ae4
Merge branch 'server-rules' of https://github.com/misskey-dev/misskey…
syuilo Apr 17, 2023
37e45d1
test: bind args
acid-chicken Apr 17, 2023
317a552
Merge branch 'server-rules' of https://github.com/misskey-dev/misskey…
acid-chicken Apr 17, 2023
99fb538
test: add interaction tests
acid-chicken Apr 17, 2023
15b8b95
fix bug
syuilo Apr 17, 2023
a78b5fb
Update packages/frontend/src/pages/admin/server-rules.vue
syuilo Apr 17, 2023
021cb5d
Update misskey-js.api.md
syuilo Apr 19, 2023
82cdce1
chore: windowを明示
syuilo Apr 19, 2023
13dbedd
Merge branch 'develop' into server-rules
syuilo Apr 19, 2023
bdce901
:art:
syuilo Apr 19, 2023
e73607c
refactor
syuilo Apr 19, 2023
d07e523
:art:
syuilo Apr 19, 2023
eb42dd6
:art:
syuilo Apr 19, 2023
180bc27
Merge branch 'develop' into server-rules
syuilo Apr 19, 2023
e30f2b7
fix e2e test
syuilo Apr 19, 2023
286262b
Merge branch 'develop' into server-rules
syuilo Apr 19, 2023
8a6464b
:art:
syuilo Apr 19, 2023
f40bcb0
:art:
syuilo Apr 19, 2023
a81162a
fix icon
syuilo Apr 19, 2023
8ca436b
fix e2e
syuilo Apr 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Node.js 18.6.0以上が必要になりました

### General
- 新規登録前に簡潔なルールをユーザーに表示できる、サーバールール機能を追加
- ユーザーへの自分用メモ機能
* ユーザーに対して、自分だけが見られるメモを追加できるようになりました。
(自分自身に対してもメモを追加できます。)
Expand Down
9 changes: 8 additions & 1 deletion locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,10 @@ noMoreHistory: "これより過去の履歴はありません"
startMessaging: "チャットを開始"
nUsersRead: "{n}人が読みました"
agreeTo: "{0}に同意"
agree: "同意する"
agreeBelow: "下記に同意する"
basicNotesBeforeCreateAccount: "基本的な注意事項"
tos: "利用規約"
termsOfService: "利用規約"
start: "始める"
home: "ホーム"
remoteUserCaution: "リモートユーザーのため、情報が不完全です。"
Expand Down Expand Up @@ -1010,6 +1011,12 @@ stackAxis: "スタック方向"
vertical: "縦"
horizontal: "横"
position: "位置"
serverRules: "サーバールール"
pleaseConfirmBelowBeforeSignup: "このサーバーに登録する前に、以下を確認してください。"
continue: "続ける"

_serverRules:
description: "新規登録前に表示する、サーバーの簡潔なルールを設定します。内容は利用規約の要約とすることを推奨します。"

_accountMigration:
moveTo: "このアカウントを新しいアカウントに引っ越す"
Expand Down
11 changes: 11 additions & 0 deletions packages/backend/migration/1681400427971-serverRules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class ServerRules1681400427971 {
name = 'ServerRules1681400427971'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "serverRules" character varying(280) array NOT NULL DEFAULT '{}'`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "serverRules"`);
}
}
7 changes: 7 additions & 0 deletions packages/backend/src/models/entities/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,11 @@ export class Meta {
default: { },
})
public policies: Record<string, any>;

@Column('varchar', {
length: 280,
array: true,
default: '{}',
})
public serverRules: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const paramDef = {
enableActiveEmailValidation: { type: 'boolean' },
enableChartsForRemoteUser: { type: 'boolean' },
enableChartsForFederatedInstances: { type: 'boolean' },
serverRules: { type: 'array', items: { type: 'string' } },
},
required: [],
} as const;
Expand Down Expand Up @@ -387,6 +388,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
set.enableChartsForFederatedInstances = ps.enableChartsForFederatedInstances;
}

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

await this.metaService.update(set);
this.moderationLogService.insertModerationLog(me, 'updateMeta');
});
Expand Down
2 changes: 2 additions & 0 deletions packages/backend/src/server/api/endpoints/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {

translatorAvailable: instance.deeplAuthKey != null,

serverRules: instance.serverRules,

policies: { ...DEFAULT_POLICIES, ...instance.policies },

mediaProxy: this.config.mediaProxy,
Expand Down
9 changes: 0 additions & 9 deletions packages/frontend/src/components/MkSignup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@
<span v-if="passwordRetypeState == 'not-match'" style="color: var(--error)"><i class="ti ti-alert-triangle ti-fw"></i> {{ i18n.ts.passwordNotMatched }}</span>
</template>
</MkInput>
<MkSwitch v-model="ToSAgreement" class="tou">
<template #label>{{ i18n.ts.agreeBelow }}</template>
</MkSwitch>
<ul style="margin: 0; padding-left: 2em;">
<li v-if="instance.tosUrl"><a :href="instance.tosUrl" class="_link" target="_blank">{{ i18n.ts.tos }}</a></li>
<li><a href="https://misskey-hub.net/docs/notes.html" class="_link" target="_blank">{{ i18n.ts.basicNotesBeforeCreateAccount }}</a></li>
</ul>
<MkCaptcha v-if="instance.enableHcaptcha" ref="hcaptcha" v-model="hCaptchaResponse" class="captcha" provider="hcaptcha" :sitekey="instance.hcaptchaSiteKey"/>
<MkCaptcha v-if="instance.enableRecaptcha" ref="recaptcha" v-model="reCaptchaResponse" class="captcha" provider="recaptcha" :sitekey="instance.recaptchaSiteKey"/>
<MkCaptcha v-if="instance.enableTurnstile" ref="turnstile" v-model="turnstileResponse" class="captcha" provider="turnstile" :sitekey="instance.turnstileSiteKey"/>
Expand Down Expand Up @@ -106,7 +99,6 @@ let emailState: null | 'wait' | 'ok' | 'unavailable:used' | 'unavailable:format'
let passwordStrength: '' | 'low' | 'medium' | 'high' = $ref('');
let passwordRetypeState: null | 'match' | 'not-match' = $ref(null);
let submitting: boolean = $ref(false);
let ToSAgreement: boolean = $ref(false);
let hCaptchaResponse = $ref(null);
let reCaptchaResponse = $ref(null);
let turnstileResponse = $ref(null);
Expand All @@ -115,7 +107,6 @@ let emailAbortController: null | AbortController = $ref(null);

const shouldDisableSubmitting = $computed((): boolean => {
return submitting ||
instance.tosUrl && !ToSAgreement ||
instance.enableHcaptcha && !hCaptchaResponse ||
instance.enableRecaptcha && !reCaptchaResponse ||
instance.enableTurnstile && !turnstileResponse ||
Expand Down
12 changes: 9 additions & 3 deletions packages/frontend/src/components/MkSignupDialog.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
<template>
<MkModalWindow
ref="dialog"
:width="366"
:height="500"
:width="500"
:height="600"
@close="dialog.close()"
@closed="$emit('closed')"
>
<template #header>{{ i18n.ts.signup }}</template>

<MkSpacer :margin-min="20" :margin-max="28">
<XSignup :auto-set="autoSet" @signup="onSignup" @signup-email-pending="onSignupEmailPending"/>
<XServerRules v-if="!isAcceptedServerRule" @accept="isAcceptedServerRule = true"/>
<XSignup v-else :auto-set="autoSet" @signup="onSignup" @signup-email-pending="onSignupEmailPending"/>
</MkSpacer>
</MkModalWindow>
</template>

<script lang="ts" setup>
import { } from 'vue';
import { $ref } from 'vue/macros';
import XSignup from '@/components/MkSignup.vue';
import XServerRules from '@/components/MkSignupServerRules.vue';
import MkModalWindow from '@/components/MkModalWindow.vue';
import { i18n } from '@/i18n';
import { instance } from '@/instance';

const props = withDefaults(defineProps<{
autoSet?: boolean;
Expand All @@ -33,6 +37,8 @@ const emit = defineEmits<{

const dialog = $shallowRef<InstanceType<typeof MkModalWindow>>();

const isAcceptedServerRule = $ref(false);

function onSignup(res) {
emit('done', res);
dialog.close();
Expand Down
85 changes: 85 additions & 0 deletions packages/frontend/src/components/MkSignupServerRules.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>
<div class="_gaps_m">
<div style="text-align: center;">{{ i18n.ts.pleaseConfirmBelowBeforeSignup }}</div>

<MkFolder :default-open="true">
<template #label>{{ i18n.ts.serverRules }}</template>

<ol class="_gaps_s" :class="$style.rules">
<li v-for="(item, index) in instance.serverRules" :key="index" :class="$style.rule" v-html="item"></li>
</ol>

<MkSwitch v-model="agreeServerRules" style="margin-top: 16px;">{{ i18n.ts.agree }}</MkSwitch>
</MkFolder>

<MkFolder v-if="instance.tosUrl">
<template #label>{{ i18n.ts.termsOfService }}</template>

<a :href="instance.tosUrl" class="_link" target="_blank">{{ i18n.ts.termsOfService }}</a>

<MkSwitch v-model="agreeTos" style="margin-top: 16px;">{{ i18n.ts.agree }}</MkSwitch>
</MkFolder>

<MkFolder>
<template #label>{{ i18n.ts.basicNotesBeforeCreateAccount }}</template>

<a href="https://misskey-hub.net/docs/notes.html" class="_link" target="_blank">{{ i18n.ts.basicNotesBeforeCreateAccount }}</a>

<MkSwitch v-model="agreeNote" style="margin-top: 16px;">{{ i18n.ts.agree }}</MkSwitch>
</MkFolder>

<MkButton primary rounded style="margin: 0 auto;" :disabled="!agreed" @click="emit('accept')">{{ i18n.ts.continue }}</MkButton>
</div>
</template>

<script lang="ts" setup>
import { computed, ref } from 'vue';
import { instance } from '@/instance';
import { i18n } from '@/i18n';
import MkButton from '@/components/MkButton.vue';
import MkFolder from '@/components/MkFolder.vue';
import MkSwitch from '@/components/MkSwitch.vue';

const agreeServerRules = ref(false);
const agreeTos = ref(false);
const agreeNote = ref(false);

const agreed = computed(() => {
return agreeServerRules.value && agreeTos.value && agreeNote.value;
syuilo marked this conversation as resolved.
Show resolved Hide resolved
});

const emit = defineEmits<{
(ev: 'accept'): void;
}>();
</script>

<style lang="scss" module>
.rules {
counter-reset: item;
list-style: none;
padding: 0;
margin: 0;
}

.rule {
display: flex;
align-items: center;
gap: 8px;

&::before {
display: flex;
counter-increment: item;
content: counter(item);
width: 32px;
height: 32px;
line-height: 32px;
background-color: var(--accentedBg);
color: var(--accent);
font-size: 13px;
font-weight: bold;
align-items: center;
justify-content: center;
border-radius: 999px;
}
}
</style>
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/about.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<template #value>{{ instance.maintainerEmail }}</template>
</MkKeyValue>
</FormSplit>
<FormLink v-if="instance.tosUrl" :to="instance.tosUrl" external>{{ i18n.ts.tos }}</FormLink>
<FormLink v-if="instance.tosUrl" :to="instance.tosUrl" external>{{ i18n.ts.termsOfService }}</FormLink>
</div>
</FormSection>

Expand Down
9 changes: 9 additions & 0 deletions packages/frontend/src/pages/admin/moderation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
<MkStickyContainer>
<template #header><XHeader :tabs="headerTabs"/></template>
<MkSpacer :content-max="700" :margin-min="16" :margin-max="32">
<FormLink to="/admin/server-rules">{{ i18n.ts.serverRules }}</FormLink>
<FormSuspense :p="init">
<div class="_gaps_m">
<FormSection first>
<div class="_gaps_m">
<MkInput v-model="tosUrl">
<template #prefix><i class="ti ti-link"></i></template>
<template #label>{{ i18n.ts.tosUrl }}</template>
</MkInput>
<MkTextarea v-model="sensitiveWords">
<template #label>{{ i18n.ts.sensitiveWords }}</template>
<template #caption>{{ i18n.ts.sensitiveWordsDescription }}</template>
Expand Down Expand Up @@ -41,16 +46,20 @@ import { fetchInstance } from '@/instance';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import MkButton from '@/components/MkButton.vue';
import FormLink from "@/components/form/link.vue";

let sensitiveWords: string = $ref('');
let tosUrl: string | null = $ref(null);

async function init() {
const meta = await os.api('admin/meta');
sensitiveWords = meta.sensitiveWords.join('\n');
tosUrl = meta.tosUrl;
}

function save() {
os.apiWithDialog('admin/update-meta', {
tosUrl,
sensitiveWords: sensitiveWords.split('\n'),
}).then(() => {
fetchInstance();
Expand Down
Loading