This commit is contained in:
syuilo 2019-07-04 21:07:02 +09:00
parent f379a721f1
commit 16b81fff38
4 changed files with 56 additions and 0 deletions

View file

@ -129,6 +129,7 @@
<ui-input v-model="smtpPass" type="password" :with-password-toggle="true" :disabled="!enableEmail || !smtpAuth">{{ $t('smtp-pass') }}</ui-input>
</ui-horizon-group>
<ui-switch v-model="smtpSecure" :disabled="!enableEmail">{{ $t('smtp-secure') }}<template #desc>{{ $t('smtp-secure-info') }}</template></ui-switch>
<ui-button @click="testEmail()">{{ $t('test-email') }}</ui-button>
</template>
</section>
<section>
@ -424,6 +425,32 @@ export default Vue.extend({
});
},
async testEmail() {
const { canceled, result: to } = await this.$root.dialog({
title: this.$t('test-email-to'),
input: {
type: 'email',
},
showCancelButton: true
});
if (canceled) return;
this.$root.api('admin/send-email', {
to: to,
subject: 'Test email',
text: 'Yo'
}).then(x => {
this.$root.dialog({
type: 'success',
splash: true
});
}).catch(e => {
this.$root.dialog({
type: 'error',
text: e
});
});
},
updateMeta() {
this.$root.api('admin/update-meta', {
maintainerName: this.maintainerName,

View file

@ -0,0 +1,26 @@
import $ from 'cafy';
import define from '../../define';
import { sendEmail } from '../../../../services/send-email';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
params: {
to: {
validator: $.str,
},
subject: {
validator: $.str,
},
text: {
validator: $.str,
},
}
};
export default define(meta, async (ps) => {
await sendEmail(ps.to, ps.subject, ps.text);
});