Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
40d224e8
You need to sign in or sign up before continuing.
Commit
40d224e8
authored
Jun 08, 2019
by
Nick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: admin mail - send test email
parent
17f9f0ba
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
114 additions
and
32 deletions
+114
-32
admin-mail.vue
client/components/admin/admin-mail.vue
+30
-3
admin-pages.vue
client/components/admin/admin-pages.vue
+1
-1
admin-users-create.vue
client/components/admin/admin-users-create.vue
+3
-3
mail-mutation-sendtest.gql
client/graph/admin/mail/mail-mutation-sendtest.gql
+12
-0
mail.js
server/core/mail.js
+1
-1
mail.js
server/graph/resolvers/mail.js
+25
-2
mail.graphql
server/graph/schemas/mail.graphql
+4
-0
error.js
server/helpers/error.js
+38
-22
test.html
server/templates/test.html
+0
-0
No files found.
client/components/admin/admin-mail.vue
View file @
40d224e8
...
...
@@ -136,11 +136,11 @@
:label='$t(`admin:mail.testRecipient`)'
:counter='255'
prepend-icon='mail'
disabled
:disabled='testLoading'
)
v-card-chin
v-spacer
v-btn(color='teal',
:dark='false', disabled
)
{{
$t
(
'admin:mail.testSend'
)
}}
v-btn(color='teal',
dark, @click='sendTest', :loading='testLoading'
)
{{
$t
(
'admin:mail.testSend'
)
}}
</
template
>
...
...
@@ -149,6 +149,7 @@ import _ from 'lodash'
import
{
get
}
from
'vuex-pathify'
import
mailConfigQuery
from
'gql/admin/mail/mail-query-config.gql'
import
mailUpdateConfigMutation
from
'gql/admin/mail/mail-mutation-save-config.gql'
import
mailTestMutation
from
'gql/admin/mail/mail-mutation-sendtest.gql'
export
default
{
data
()
{
...
...
@@ -166,7 +167,8 @@ export default {
dkimKeySelector
:
''
,
dkimPrivateKey
:
''
},
testEmail
:
''
testEmail
:
''
,
testLoading
:
false
}
},
computed
:
{
...
...
@@ -202,6 +204,31 @@ export default {
}
catch
(
err
)
{
this
.
$store
.
commit
(
'pushGraphError'
,
err
)
}
},
async
sendTest
()
{
try
{
const
resp
=
await
this
.
$apollo
.
mutate
({
mutation
:
mailTestMutation
,
variables
:
{
recipientEmail
:
this
.
testEmail
},
watchLoading
(
isLoading
)
{
this
.
$store
.
commit
(
`loading
${
isLoading
?
'Start'
:
'Stop'
}
`
,
'admin-mail-test'
)
}
})
if
(
!
_
.
get
(
resp
,
'data.mail.sendTest.responseResult.succeeded'
,
false
))
{
throw
new
Error
(
_
.
get
(
resp
,
'data.mail.sendTest.responseResult.message'
,
'An unexpected error occured.'
))
}
this
.
testEmail
=
''
this
.
$store
.
commit
(
'showNotification'
,
{
style
:
'success'
,
message
:
this
.
$t
(
'admin:mail.sendTestSuccess'
),
icon
:
'check'
})
}
catch
(
err
)
{
this
.
$store
.
commit
(
'pushGraphError'
,
err
)
}
}
},
apollo
:
{
...
...
client/components/admin/admin-pages.vue
View file @
40d224e8
...
...
@@ -14,7 +14,7 @@
v-icon(left) add
span New Page
v-card.wiki-form.mt-3
v-toolbar(flat, :color='$vuetify.dark ? `grey darken-3-d5` : `
white
`', height='80')
v-toolbar(flat, :color='$vuetify.dark ? `grey darken-3-d5` : `
grey lighten-5
`', height='80')
v-spacer
v-text-field(
outline
...
...
client/components/admin/admin-users-create.vue
View file @
40d224e8
...
...
@@ -64,8 +64,8 @@
v-card-chin
v-spacer
v-btn(flat, @click='isShown = false') Cancel
v-btn(color='primary', @click='newUser') Create
v-btn(color='primary', @click='newUser') Create and Close
v-btn(color='primary', @click='newUser
(true)
') Create
v-btn(color='primary', @click='newUser
(false)
') Create and Close
</
template
>
<
script
>
...
...
@@ -111,7 +111,7 @@ export default {
},
methods
:
{
async
newUser
()
{
this
.
isShown
=
false
},
generatePwd
()
{
this
.
password
=
uuidv4
().
slice
(
-
12
)
...
...
client/graph/admin/mail/mail-mutation-sendtest.gql
0 → 100644
View file @
40d224e8
mutation
(
$recipientEmail
:
String
!)
{
mail
{
sendTest
(
recipientEmail
:
$recipientEmail
)
{
responseResult
{
succeeded
errorCode
slug
message
}
}
}
}
server/core/mail.js
View file @
40d224e8
...
...
@@ -44,7 +44,7 @@ module.exports = {
async
send
(
opts
)
{
if
(
!
this
.
transport
)
{
WIKI
.
logger
.
warn
(
'Cannot send email because mail is not setup in the administration area!'
)
throw
new
WIKI
.
Error
.
MailNot
Setup
()
throw
new
WIKI
.
Error
.
MailNot
Configured
()
}
await
this
.
loadTemplate
(
opts
.
template
)
return
this
.
transport
.
sendMail
({
...
...
server/graph/resolvers/mail.js
View file @
40d224e8
...
...
@@ -16,6 +16,29 @@ module.exports = {
}
},
MailMutation
:
{
async
sendTest
(
obj
,
args
,
context
)
{
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
{
responseResult
:
graphHelper
.
generateSuccess
(
'Test email sent successfully.'
)
}
}
catch
(
err
)
{
return
graphHelper
.
generateError
(
err
)
}
},
async
updateConfig
(
obj
,
args
,
context
)
{
try
{
WIKI
.
config
.
mail
=
{
...
...
@@ -29,14 +52,14 @@ module.exports = {
useDKIM
:
args
.
useDKIM
,
dkimDomainName
:
args
.
dkimDomainName
,
dkimKeySelector
:
args
.
dkimKeySelector
,
dkimPrivateKey
:
args
.
dkimPrivateKey
,
dkimPrivateKey
:
args
.
dkimPrivateKey
}
await
WIKI
.
configSvc
.
saveToDb
([
'mail'
])
WIKI
.
mail
.
init
()
return
{
responseResult
:
graphHelper
.
generateSuccess
(
'Mail configuration updated successfully'
)
responseResult
:
graphHelper
.
generateSuccess
(
'Mail configuration updated successfully
.
'
)
}
}
catch
(
err
)
{
return
graphHelper
.
generateError
(
err
)
...
...
server/graph/schemas/mail.graphql
View file @
40d224e8
...
...
@@ -23,6 +23,10 @@ type MailQuery {
# -----------------------------------------------
type
MailMutation
{
sendTest
(
recipientEmail
:
String
!
):
DefaultResponse
@
auth
(
requires
:
[
"
manage
:
system
"
])
updateConfig
(
senderName
:
String
!
senderEmail
:
String
!
...
...
server/helpers/error.js
View file @
40d224e8
...
...
@@ -10,7 +10,7 @@ module.exports = {
code
:
2002
}),
AssetGenericError
:
CustomError
(
'AssetGenericError'
,
{
message
:
'An unexpected error occured during asset
change
.'
,
message
:
'An unexpected error occured during asset
operation
.'
,
code
:
2001
}),
AssetInvalid
:
CustomError
(
'AssetInvalid'
,
{
...
...
@@ -39,11 +39,15 @@ module.exports = {
}),
AuthAccountBanned
:
CustomError
(
'AuthAccountBanned'
,
{
message
:
'Your account has been disabled.'
,
code
:
1016
code
:
1013
}),
AuthAccountAlreadyExists
:
CustomError
(
'AuthAccountAlreadyExists'
,
{
message
:
'An account already exists using this email address.'
,
code
:
1004
}),
AuthAccountNotVerified
:
CustomError
(
'AuthAccountNotVerified'
,
{
message
:
'You must verify your account before your can login.'
,
code
:
101
7
code
:
101
4
}),
AuthGenericError
:
CustomError
(
'AuthGenericError'
,
{
message
:
'An unexpected error occured during login.'
,
...
...
@@ -57,17 +61,13 @@ module.exports = {
message
:
'Invalid authentication provider.'
,
code
:
1003
}),
AuthAccountAlreadyExists
:
CustomError
(
'AuthAccountAlreadyExists'
,
{
message
:
'An account already exists using this email address.'
,
code
:
1004
}),
AuthRegistrationDisabled
:
CustomError
(
'AuthRegistrationDisabled'
,
{
message
:
'Registration is disabled. Contact your system administrator.'
,
code
:
101
1
code
:
101
0
}),
AuthRegistrationDomainUnauthorized
:
CustomError
(
'AuthRegistrationDomainUnauthorized'
,
{
message
:
'You are not authorized to register.
Must use a whitelisted domain
.'
,
code
:
101
2
message
:
'You are not authorized to register.
Your domain is not whitelisted
.'
,
code
:
101
1
}),
AuthTFAFailed
:
CustomError
(
'AuthTFAFailed'
,
{
message
:
'Incorrect TFA Security Code.'
,
...
...
@@ -79,7 +79,7 @@ module.exports = {
}),
AuthValidationTokenInvalid
:
CustomError
(
'AuthValidationTokenInvalid'
,
{
message
:
'Invalid validation token.'
,
code
:
101
8
code
:
101
5
}),
BruteInstanceIsInvalid
:
CustomError
(
'BruteInstanceIsInvalid'
,
{
message
:
'Invalid Brute Force Instance.'
,
...
...
@@ -91,26 +91,42 @@ module.exports = {
}),
InputInvalid
:
CustomError
(
'InputInvalid'
,
{
message
:
'Input data is invalid.'
,
code
:
1013
}),
MailNotSetup
:
CustomError
(
'MailNotSetup'
,
{
message
:
'Mail is not setup yet.'
,
code
:
1014
code
:
1012
}),
MailTemplateFailed
:
CustomError
(
'MailTemplateFailed
'
,
{
message
:
'
Mail template failed to load
.'
,
code
:
1015
LocaleGenericError
:
CustomError
(
'LocaleGenericError
'
,
{
message
:
'
An unexpected error occured during locale operation
.'
,
code
:
5001
}),
LocaleInvalidNamespace
:
CustomError
(
'LocaleInvalidNamespace'
,
{
message
:
'Invalid locale or namespace.'
,
code
:
1009
code
:
5002
}),
MailGenericError
:
CustomError
(
'MailGenericError'
,
{
message
:
'An unexpected error occured during mail operation.'
,
code
:
3001
}),
MailInvalidRecipient
:
CustomError
(
'MailInvalidRecipient'
,
{
message
:
'The recipient email address is invalid.'
,
code
:
3004
}),
MailNotConfigured
:
CustomError
(
'MailNotConfigured'
,
{
message
:
'The mail configuration is incomplete or invalid.'
,
code
:
3002
}),
MailTemplateFailed
:
CustomError
(
'MailTemplateFailed'
,
{
message
:
'Mail template failed to load.'
,
code
:
3003
}),
SearchActivationFailed
:
CustomError
(
'SearchActivationFailed'
,
{
message
:
'Search Engine activation failed.'
,
code
:
1019
code
:
4002
}),
SearchGenericError
:
CustomError
(
'SearchGenericError'
,
{
message
:
'An unexpected error occured during search operation.'
,
code
:
4001
}),
UserCreationFailed
:
CustomError
(
'UserCreationFailed'
,
{
message
:
'An unexpected error occured during user creation.'
,
code
:
10
10
code
:
10
09
})
}
server/templates/test.html
0 → 100644
View file @
40d224e8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment