mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.8 KiB
67 lines
1.8 KiB
2 years ago
|
import _ from 'lodash-es'
|
||
|
import { generateError, generateSuccess } from '../../helpers/graph.mjs'
|
||
6 years ago
|
|
||
2 years ago
|
export default {
|
||
6 years ago
|
Query: {
|
||
3 years ago
|
async mailConfig(obj, args, context, info) {
|
||
5 years ago
|
return {
|
||
|
...WIKI.config.mail,
|
||
|
pass: WIKI.config.mail.pass.length > 0 ? '********' : ''
|
||
|
}
|
||
6 years ago
|
}
|
||
|
},
|
||
3 years ago
|
Mutation: {
|
||
|
async sendMailTest(obj, args, context) {
|
||
6 years ago
|
try {
|
||
|
if (_.isEmpty(args.recipientEmail) || args.recipientEmail.length < 6) {
|
||
|
throw new WIKI.Error.MailInvalidRecipient()
|
||
|
}
|
||
|
|
||
|
await WIKI.mail.send({
|
||
|
template: 'test',
|
||
|
to: args.recipientEmail,
|
||
|
subject: 'A test email from your wiki',
|
||
|
text: 'This is a test email sent from your wiki.',
|
||
|
data: {
|
||
|
preheadertext: 'This is a test email sent from your wiki.'
|
||
|
}
|
||
|
})
|
||
|
|
||
|
return {
|
||
2 years ago
|
operation: generateSuccess('Test email sent successfully.')
|
||
6 years ago
|
}
|
||
|
} catch (err) {
|
||
2 years ago
|
return generateError(err)
|
||
6 years ago
|
}
|
||
|
},
|
||
3 years ago
|
async updateMailConfig(obj, args, context) {
|
||
6 years ago
|
try {
|
||
|
WIKI.config.mail = {
|
||
|
senderName: args.senderName,
|
||
|
senderEmail: args.senderEmail,
|
||
|
host: args.host,
|
||
|
port: args.port,
|
||
2 years ago
|
name: args.name,
|
||
6 years ago
|
secure: args.secure,
|
||
5 years ago
|
verifySSL: args.verifySSL,
|
||
6 years ago
|
user: args.user,
|
||
5 years ago
|
pass: (args.pass === '********') ? WIKI.config.mail.pass : args.pass,
|
||
6 years ago
|
useDKIM: args.useDKIM,
|
||
|
dkimDomainName: args.dkimDomainName,
|
||
|
dkimKeySelector: args.dkimKeySelector,
|
||
6 years ago
|
dkimPrivateKey: args.dkimPrivateKey
|
||
6 years ago
|
}
|
||
|
await WIKI.configSvc.saveToDb(['mail'])
|
||
|
|
||
|
WIKI.mail.init()
|
||
|
|
||
|
return {
|
||
2 years ago
|
operation: generateSuccess('Mail configuration updated successfully.')
|
||
6 years ago
|
}
|
||
|
} catch (err) {
|
||
2 years ago
|
return generateError(err)
|
||
6 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|