|
|
@ -25,18 +25,18 @@ func (app *appContext) GetCustomContent(gc *gin.Context) {
|
|
|
|
adminLang = app.storage.lang.chosenAdminLang
|
|
|
|
adminLang = app.storage.lang.chosenAdminLang
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list := emailListDTO{
|
|
|
|
list := emailListDTO{
|
|
|
|
"UserCreated": {Name: app.storage.lang.Email[lang].UserCreated["name"], Enabled: app.storage.customEmails.UserCreated.Enabled},
|
|
|
|
"UserCreated": {Name: app.storage.lang.Email[lang].UserCreated["name"], Enabled: app.storage.MustGetCustomContentKey("UserCreated").Enabled},
|
|
|
|
"InviteExpiry": {Name: app.storage.lang.Email[lang].InviteExpiry["name"], Enabled: app.storage.customEmails.InviteExpiry.Enabled},
|
|
|
|
"InviteExpiry": {Name: app.storage.lang.Email[lang].InviteExpiry["name"], Enabled: app.storage.MustGetCustomContentKey("InviteExpiry").Enabled},
|
|
|
|
"PasswordReset": {Name: app.storage.lang.Email[lang].PasswordReset["name"], Enabled: app.storage.customEmails.PasswordReset.Enabled},
|
|
|
|
"PasswordReset": {Name: app.storage.lang.Email[lang].PasswordReset["name"], Enabled: app.storage.MustGetCustomContentKey("PasswordReset").Enabled},
|
|
|
|
"UserDeleted": {Name: app.storage.lang.Email[lang].UserDeleted["name"], Enabled: app.storage.customEmails.UserDeleted.Enabled},
|
|
|
|
"UserDeleted": {Name: app.storage.lang.Email[lang].UserDeleted["name"], Enabled: app.storage.MustGetCustomContentKey("UserDeleted").Enabled},
|
|
|
|
"UserDisabled": {Name: app.storage.lang.Email[lang].UserDisabled["name"], Enabled: app.storage.customEmails.UserDisabled.Enabled},
|
|
|
|
"UserDisabled": {Name: app.storage.lang.Email[lang].UserDisabled["name"], Enabled: app.storage.MustGetCustomContentKey("UserDisabled").Enabled},
|
|
|
|
"UserEnabled": {Name: app.storage.lang.Email[lang].UserEnabled["name"], Enabled: app.storage.customEmails.UserEnabled.Enabled},
|
|
|
|
"UserEnabled": {Name: app.storage.lang.Email[lang].UserEnabled["name"], Enabled: app.storage.MustGetCustomContentKey("UserEnabled").Enabled},
|
|
|
|
"InviteEmail": {Name: app.storage.lang.Email[lang].InviteEmail["name"], Enabled: app.storage.customEmails.InviteEmail.Enabled},
|
|
|
|
"InviteEmail": {Name: app.storage.lang.Email[lang].InviteEmail["name"], Enabled: app.storage.MustGetCustomContentKey("InviteEmail").Enabled},
|
|
|
|
"WelcomeEmail": {Name: app.storage.lang.Email[lang].WelcomeEmail["name"], Enabled: app.storage.customEmails.WelcomeEmail.Enabled},
|
|
|
|
"WelcomeEmail": {Name: app.storage.lang.Email[lang].WelcomeEmail["name"], Enabled: app.storage.MustGetCustomContentKey("WelcomeEmail").Enabled},
|
|
|
|
"EmailConfirmation": {Name: app.storage.lang.Email[lang].EmailConfirmation["name"], Enabled: app.storage.customEmails.EmailConfirmation.Enabled},
|
|
|
|
"EmailConfirmation": {Name: app.storage.lang.Email[lang].EmailConfirmation["name"], Enabled: app.storage.MustGetCustomContentKey("EmailConfirmation").Enabled},
|
|
|
|
"UserExpired": {Name: app.storage.lang.Email[lang].UserExpired["name"], Enabled: app.storage.customEmails.UserExpired.Enabled},
|
|
|
|
"UserExpired": {Name: app.storage.lang.Email[lang].UserExpired["name"], Enabled: app.storage.MustGetCustomContentKey("UserExpired").Enabled},
|
|
|
|
"UserLogin": {Name: app.storage.lang.Admin[adminLang].Strings["userPageLogin"], Enabled: app.storage.userPage.Login.Enabled},
|
|
|
|
"UserLogin": {Name: app.storage.lang.Admin[adminLang].Strings["userPageLogin"], Enabled: app.storage.MustGetCustomContentKey("Login").Enabled},
|
|
|
|
"UserPage": {Name: app.storage.lang.Admin[adminLang].Strings["userPagePage"], Enabled: app.storage.userPage.Page.Enabled},
|
|
|
|
"UserPage": {Name: app.storage.lang.Admin[adminLang].Strings["userPagePage"], Enabled: app.storage.MustGetCustomContentKey("Page").Enabled},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
filter := gc.Query("filter")
|
|
|
|
filter := gc.Query("filter")
|
|
|
@ -50,10 +50,11 @@ func (app *appContext) GetCustomContent(gc *gin.Context) {
|
|
|
|
gc.JSON(200, list)
|
|
|
|
gc.JSON(200, list)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (app *appContext) getCustomMessage(id string) *customContent {
|
|
|
|
// No longer needed, these are stored by string keys in the database now.
|
|
|
|
|
|
|
|
/* func (app *appContext) getCustomMessage(id string) *CustomContent {
|
|
|
|
switch id {
|
|
|
|
switch id {
|
|
|
|
case "Announcement":
|
|
|
|
case "Announcement":
|
|
|
|
return &customContent{}
|
|
|
|
return &CustomContent{}
|
|
|
|
case "UserCreated":
|
|
|
|
case "UserCreated":
|
|
|
|
return &app.storage.customEmails.UserCreated
|
|
|
|
return &app.storage.customEmails.UserCreated
|
|
|
|
case "InviteExpiry":
|
|
|
|
case "InviteExpiry":
|
|
|
@ -80,45 +81,38 @@ func (app *appContext) getCustomMessage(id string) *customContent {
|
|
|
|
return &app.storage.userPage.Page
|
|
|
|
return &app.storage.userPage.Page
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
|
|
// @Summary Sets the corresponding custom email.
|
|
|
|
// @Summary Sets the corresponding custom content.
|
|
|
|
// @Produce json
|
|
|
|
// @Produce json
|
|
|
|
// @Param customEmails body customEmails true "Content = email (in markdown)."
|
|
|
|
// @Param CustomContent body CustomContent true "Content = email (in markdown)."
|
|
|
|
// @Success 200 {object} boolResponse
|
|
|
|
// @Success 200 {object} boolResponse
|
|
|
|
// @Failure 400 {object} boolResponse
|
|
|
|
// @Failure 400 {object} boolResponse
|
|
|
|
// @Failure 500 {object} boolResponse
|
|
|
|
// @Failure 500 {object} boolResponse
|
|
|
|
// @Param id path string true "ID of email"
|
|
|
|
// @Param id path string true "ID of content"
|
|
|
|
// @Router /config/emails/{id} [post]
|
|
|
|
// @Router /config/emails/{id} [post]
|
|
|
|
// @Security Bearer
|
|
|
|
// @Security Bearer
|
|
|
|
// @tags Configuration
|
|
|
|
// @tags Configuration
|
|
|
|
func (app *appContext) SetCustomMessage(gc *gin.Context) {
|
|
|
|
func (app *appContext) SetCustomMessage(gc *gin.Context) {
|
|
|
|
var req customContent
|
|
|
|
var req CustomContent
|
|
|
|
gc.BindJSON(&req)
|
|
|
|
gc.BindJSON(&req)
|
|
|
|
id := gc.Param("id")
|
|
|
|
id := gc.Param("id")
|
|
|
|
if req.Content == "" {
|
|
|
|
if req.Content == "" {
|
|
|
|
respondBool(400, false, gc)
|
|
|
|
respondBool(400, false, gc)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
message := app.getCustomMessage(id)
|
|
|
|
message, ok := app.storage.GetCustomContentKey(id)
|
|
|
|
if message == nil {
|
|
|
|
if !ok {
|
|
|
|
respondBool(400, false, gc)
|
|
|
|
respondBool(400, false, gc)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
message.Content = req.Content
|
|
|
|
message.Content = req.Content
|
|
|
|
message.Enabled = true
|
|
|
|
message.Enabled = true
|
|
|
|
if app.storage.storeCustomEmails() != nil {
|
|
|
|
app.storage.SetCustomContentKey(id, message)
|
|
|
|
respondBool(500, false, gc)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if app.storage.storeUserPageContent() != nil {
|
|
|
|
|
|
|
|
respondBool(500, false, gc)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
respondBool(200, true, gc)
|
|
|
|
respondBool(200, true, gc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Summary Enable/Disable custom email.
|
|
|
|
// @Summary Enable/Disable custom content.
|
|
|
|
// @Produce json
|
|
|
|
// @Produce json
|
|
|
|
// @Success 200 {object} boolResponse
|
|
|
|
// @Success 200 {object} boolResponse
|
|
|
|
// @Failure 400 {object} boolResponse
|
|
|
|
// @Failure 400 {object} boolResponse
|
|
|
@ -137,24 +131,17 @@ func (app *appContext) SetCustomMessageState(gc *gin.Context) {
|
|
|
|
} else if s != "disable" {
|
|
|
|
} else if s != "disable" {
|
|
|
|
respondBool(400, false, gc)
|
|
|
|
respondBool(400, false, gc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
message := app.getCustomMessage(id)
|
|
|
|
message, ok := app.storage.GetCustomContentKey(id)
|
|
|
|
if message == nil {
|
|
|
|
if !ok {
|
|
|
|
respondBool(400, false, gc)
|
|
|
|
respondBool(400, false, gc)
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
message.Enabled = enabled
|
|
|
|
message.Enabled = enabled
|
|
|
|
if app.storage.storeCustomEmails() != nil {
|
|
|
|
app.storage.SetCustomContentKey(id, message)
|
|
|
|
respondBool(500, false, gc)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if app.storage.storeUserPageContent() != nil {
|
|
|
|
|
|
|
|
respondBool(500, false, gc)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
respondBool(200, true, gc)
|
|
|
|
respondBool(200, true, gc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Summary Returns the custom email/message (generating it if not set) and list of used variables in it.
|
|
|
|
// @Summary Returns the custom content/message (generating it if not set) and list of used variables in it.
|
|
|
|
// @Produce json
|
|
|
|
// @Produce json
|
|
|
|
// @Success 200 {object} customEmailDTO
|
|
|
|
// @Success 200 {object} customEmailDTO
|
|
|
|
// @Failure 400 {object} boolResponse
|
|
|
|
// @Failure 400 {object} boolResponse
|
|
|
@ -174,8 +161,8 @@ func (app *appContext) GetCustomMessageTemplate(gc *gin.Context) {
|
|
|
|
var values map[string]interface{}
|
|
|
|
var values map[string]interface{}
|
|
|
|
username := app.storage.lang.Email[lang].Strings.get("username")
|
|
|
|
username := app.storage.lang.Email[lang].Strings.get("username")
|
|
|
|
emailAddress := app.storage.lang.Email[lang].Strings.get("emailAddress")
|
|
|
|
emailAddress := app.storage.lang.Email[lang].Strings.get("emailAddress")
|
|
|
|
customMessage := app.getCustomMessage(id)
|
|
|
|
customMessage, ok := app.storage.GetCustomContentKey(id)
|
|
|
|
if customMessage == nil {
|
|
|
|
if !ok {
|
|
|
|
app.err.Printf("Failed to get custom message with ID \"%s\"", id)
|
|
|
|
app.err.Printf("Failed to get custom message with ID \"%s\"", id)
|
|
|
|
respondBool(400, false, gc)
|
|
|
|
respondBool(400, false, gc)
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -280,13 +267,7 @@ func (app *appContext) GetCustomMessageTemplate(gc *gin.Context) {
|
|
|
|
if variables == nil {
|
|
|
|
if variables == nil {
|
|
|
|
variables = []string{}
|
|
|
|
variables = []string{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if app.storage.storeCustomEmails() != nil {
|
|
|
|
app.storage.SetCustomContentKey(id, customMessage)
|
|
|
|
respondBool(500, false, gc)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if app.storage.storeUserPageContent() != nil {
|
|
|
|
|
|
|
|
respondBool(500, false, gc)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var mail *Message
|
|
|
|
var mail *Message
|
|
|
|
if id != "UserLogin" && id != "UserPage" {
|
|
|
|
if id != "UserLogin" && id != "UserPage" {
|
|
|
|
mail, err = app.email.constructTemplate("", "<div class=\"preview-content\"></div>", app)
|
|
|
|
mail, err = app.email.constructTemplate("", "<div class=\"preview-content\"></div>", app)
|
|
|
|