2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2021-04-22 15:29:33 +02:00
|
|
|
<template>
|
2022-06-20 10:38:49 +02:00
|
|
|
<MkStickyContainer>
|
2023-03-02 12:47:24 +01:00
|
|
|
<template #header><XHeader :tabs="headerTabs"/></template>
|
2023-05-19 13:52:15 +02:00
|
|
|
<MkSpacer :contentMax="700" :marginMin="16" :marginMax="32">
|
2022-06-20 10:38:49 +02:00
|
|
|
<FormSuspense :p="init">
|
2023-01-06 05:40:17 +01:00
|
|
|
<div class="_gaps_m">
|
2023-01-07 06:59:54 +01:00
|
|
|
<MkSwitch v-model="enableEmail">
|
2022-06-21 12:48:28 +02:00
|
|
|
<template #label>{{ i18n.ts.enableEmail }} ({{ i18n.ts.recommended }})</template>
|
2022-06-20 10:38:49 +02:00
|
|
|
<template #caption>{{ i18n.ts.emailConfigInfo }}</template>
|
2023-01-07 06:59:54 +01:00
|
|
|
</MkSwitch>
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
<template v-if="enableEmail">
|
2023-01-07 07:09:46 +01:00
|
|
|
<MkInput v-model="email" type="email">
|
2022-06-20 10:38:49 +02:00
|
|
|
<template #label>{{ i18n.ts.emailAddress }}</template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkInput>
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ i18n.ts.smtpConfig }}</template>
|
2023-01-05 13:04:56 +01:00
|
|
|
|
2023-01-06 05:40:17 +01:00
|
|
|
<div class="_gaps_m">
|
2023-05-19 13:52:15 +02:00
|
|
|
<FormSplit :minWidth="280">
|
2023-01-07 07:09:46 +01:00
|
|
|
<MkInput v-model="smtpHost">
|
2023-01-05 13:04:56 +01:00
|
|
|
<template #label>{{ i18n.ts.smtpHost }}</template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="smtpPort" type="number">
|
2023-01-05 13:04:56 +01:00
|
|
|
<template #label>{{ i18n.ts.smtpPort }}</template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkInput>
|
2023-01-05 13:04:56 +01:00
|
|
|
</FormSplit>
|
2023-05-19 13:52:15 +02:00
|
|
|
<FormSplit :minWidth="280">
|
2023-01-07 07:09:46 +01:00
|
|
|
<MkInput v-model="smtpUser">
|
2023-01-05 13:04:56 +01:00
|
|
|
<template #label>{{ i18n.ts.smtpUser }}</template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkInput>
|
|
|
|
<MkInput v-model="smtpPass" type="password">
|
2023-01-05 13:04:56 +01:00
|
|
|
<template #label>{{ i18n.ts.smtpPass }}</template>
|
2023-01-07 07:09:46 +01:00
|
|
|
</MkInput>
|
2023-01-05 13:04:56 +01:00
|
|
|
</FormSplit>
|
|
|
|
<FormInfo>{{ i18n.ts.emptyToDisableSmtpAuth }}</FormInfo>
|
2023-01-07 06:59:54 +01:00
|
|
|
<MkSwitch v-model="smtpSecure">
|
2023-01-05 13:04:56 +01:00
|
|
|
<template #label>{{ i18n.ts.smtpSecure }}</template>
|
|
|
|
<template #caption>{{ i18n.ts.smtpSecureInfo }}</template>
|
2023-01-07 06:59:54 +01:00
|
|
|
</MkSwitch>
|
2023-01-05 13:04:56 +01:00
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
</FormSection>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</FormSuspense>
|
|
|
|
</MkSpacer>
|
2023-03-02 12:47:24 +01:00
|
|
|
<template #footer>
|
|
|
|
<div :class="$style.footer">
|
2023-05-19 13:52:15 +02:00
|
|
|
<MkSpacer :contentMax="700" :marginMin="16" :marginMax="16">
|
2023-03-02 12:47:24 +01:00
|
|
|
<div class="_buttons">
|
|
|
|
<MkButton primary rounded @click="save"><i class="ti ti-check"></i> {{ i18n.ts.save }}</MkButton>
|
|
|
|
<MkButton rounded @click="testEmail"><i class="ti ti-send"></i> {{ i18n.ts.testEmail }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-06-20 10:38:49 +02:00
|
|
|
</MkStickyContainer>
|
2021-04-22 15:29:33 +02:00
|
|
|
</template>
|
|
|
|
|
2022-05-14 14:36:12 +02:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 06:42:09 +01:00
|
|
|
import { ref, computed } from 'vue';
|
2022-06-20 10:38:49 +02:00
|
|
|
import XHeader from './_header_.vue';
|
2023-01-07 06:59:54 +01:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2023-01-07 07:09:46 +01:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
2022-09-06 11:21:49 +02:00
|
|
|
import FormInfo from '@/components/MkInfo.vue';
|
2021-12-30 13:47:48 +01:00
|
|
|
import FormSuspense from '@/components/form/suspense.vue';
|
|
|
|
import FormSplit from '@/components/form/split.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 10:32:46 +01:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { fetchInstance, instance } from '@/instance.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2023-03-02 12:47:24 +01:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const enableEmail = ref<boolean>(false);
|
2023-12-26 06:19:35 +01:00
|
|
|
const email = ref<string | null>(null);
|
2023-12-07 06:42:09 +01:00
|
|
|
const smtpSecure = ref<boolean>(false);
|
|
|
|
const smtpHost = ref<string>('');
|
|
|
|
const smtpPort = ref<number>(0);
|
|
|
|
const smtpUser = ref<string>('');
|
|
|
|
const smtpPass = ref<string>('');
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2022-05-14 14:36:12 +02:00
|
|
|
async function init() {
|
2024-01-04 10:32:46 +01:00
|
|
|
const meta = await misskeyApi('admin/meta');
|
2023-12-07 06:42:09 +01:00
|
|
|
enableEmail.value = meta.enableEmail;
|
|
|
|
email.value = meta.email;
|
|
|
|
smtpSecure.value = meta.smtpSecure;
|
|
|
|
smtpHost.value = meta.smtpHost;
|
|
|
|
smtpPort.value = meta.smtpPort;
|
|
|
|
smtpUser.value = meta.smtpUser;
|
|
|
|
smtpPass.value = meta.smtpPass;
|
2022-05-14 14:36:12 +02:00
|
|
|
}
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2022-05-14 14:36:12 +02:00
|
|
|
async function testEmail() {
|
|
|
|
const { canceled, result: destination } = await os.inputText({
|
|
|
|
title: i18n.ts.destination,
|
|
|
|
type: 'email',
|
2023-04-27 12:43:00 +02:00
|
|
|
default: instance.maintainerEmail ?? '',
|
|
|
|
placeholder: 'test@example.com',
|
|
|
|
minLength: 1,
|
2022-05-14 14:36:12 +02:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
os.apiWithDialog('admin/send-email', {
|
|
|
|
to: destination,
|
|
|
|
subject: 'Test email',
|
2022-06-20 10:38:49 +02:00
|
|
|
text: 'Yo',
|
2022-05-14 14:36:12 +02:00
|
|
|
});
|
|
|
|
}
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2022-05-14 14:36:12 +02:00
|
|
|
function save() {
|
|
|
|
os.apiWithDialog('admin/update-meta', {
|
2023-12-07 06:42:09 +01:00
|
|
|
enableEmail: enableEmail.value,
|
|
|
|
email: email.value,
|
|
|
|
smtpSecure: smtpSecure.value,
|
|
|
|
smtpHost: smtpHost.value,
|
|
|
|
smtpPort: smtpPort.value,
|
|
|
|
smtpUser: smtpUser.value,
|
|
|
|
smtpPass: smtpPass.value,
|
2022-05-14 14:36:12 +02:00
|
|
|
}).then(() => {
|
|
|
|
fetchInstance();
|
|
|
|
});
|
|
|
|
}
|
2021-04-22 15:29:33 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const headerTabs = computed(() => []);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.emailServer,
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-mail',
|
2021-04-22 15:29:33 +02:00
|
|
|
});
|
|
|
|
</script>
|
2023-03-02 12:47:24 +01:00
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.footer {
|
|
|
|
-webkit-backdrop-filter: var(--blur, blur(15px));
|
|
|
|
backdrop-filter: var(--blur, blur(15px));
|
|
|
|
}
|
|
|
|
</style>
|