|
@@ -320,6 +320,27 @@ module.exports = (crowi) => {
|
|
|
await sendMailPromiseWrapper(smtpClient, mailOptions);
|
|
await sendMailPromiseWrapper(smtpClient, mailOptions);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const updateMailSettinConfig = async function(requestMailSettingParams) {
|
|
|
|
|
+ const {
|
|
|
|
|
+ configManager,
|
|
|
|
|
+ mailService,
|
|
|
|
|
+ } = crowi;
|
|
|
|
|
+
|
|
|
|
|
+ // update config without publishing S2sMessage
|
|
|
|
|
+ await configManager.updateConfigsInTheSameNamespace('crowi', requestMailSettingParams, true);
|
|
|
|
|
+
|
|
|
|
|
+ await mailService.initialize();
|
|
|
|
|
+ mailService.publishUpdatedMessage();
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ fromAddress: configManager.getConfig('crowi', 'mail:from'),
|
|
|
|
|
+ smtpHost: configManager.getConfig('crowi', 'mail:smtpHost'),
|
|
|
|
|
+ smtpPort: configManager.getConfig('crowi', 'mail:smtpPort'),
|
|
|
|
|
+ smtpUser: configManager.getConfig('crowi', 'mail:smtpUser'),
|
|
|
|
|
+ smtpPassword: configManager.getConfig('crowi', 'mail:smtpPassword'),
|
|
|
|
|
+ };
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @swagger
|
|
* @swagger
|
|
|
*
|
|
*
|
|
@@ -327,7 +348,7 @@ module.exports = (crowi) => {
|
|
|
* put:
|
|
* put:
|
|
|
* tags: [AppSettings]
|
|
* tags: [AppSettings]
|
|
|
* operationId: updateAppSettingMailSetting
|
|
* operationId: updateAppSettingMailSetting
|
|
|
- * summary: /app-settings/site-url-setting
|
|
|
|
|
|
|
+ * summary: /app-settings/mail-setting
|
|
|
* description: Update mail setting
|
|
* description: Update mail setting
|
|
|
* requestBody:
|
|
* requestBody:
|
|
|
* required: true
|
|
* required: true
|
|
@@ -364,21 +385,7 @@ module.exports = (crowi) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- const { configManager, mailService } = crowi;
|
|
|
|
|
-
|
|
|
|
|
- // update config without publishing S2sMessage
|
|
|
|
|
- await configManager.updateConfigsInTheSameNamespace('crowi', requestMailSettingParams, true);
|
|
|
|
|
-
|
|
|
|
|
- await mailService.initialize();
|
|
|
|
|
- mailService.publishUpdatedMessage();
|
|
|
|
|
-
|
|
|
|
|
- const mailSettingParams = {
|
|
|
|
|
- fromAddress: configManager.getConfig('crowi', 'mail:from'),
|
|
|
|
|
- smtpHost: configManager.getConfig('crowi', 'mail:smtpHost'),
|
|
|
|
|
- smtpPort: configManager.getConfig('crowi', 'mail:smtpPort'),
|
|
|
|
|
- smtpUser: configManager.getConfig('crowi', 'mail:smtpUser'),
|
|
|
|
|
- smtpPassword: configManager.getConfig('crowi', 'mail:smtpPassword'),
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ const mailSettingParams = await updateMailSettinConfig(requestMailSettingParams);
|
|
|
return res.apiv3({ mailSettingParams });
|
|
return res.apiv3({ mailSettingParams });
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
@@ -388,6 +395,48 @@ module.exports = (crowi) => {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @swagger
|
|
|
|
|
+ *
|
|
|
|
|
+ * /app-settings/mail-setting:
|
|
|
|
|
+ * delete:
|
|
|
|
|
+ * tags: [AppSettings]
|
|
|
|
|
+ * operationId: deleteAppSettingMailSetting
|
|
|
|
|
+ * summary: /app-settings/mail-setting
|
|
|
|
|
+ * description: delete mail setting
|
|
|
|
|
+ * requestBody:
|
|
|
|
|
+ * required: true
|
|
|
|
|
+ * content:
|
|
|
|
|
+ * application/json:
|
|
|
|
|
+ * schema:
|
|
|
|
|
+ * $ref: '#/components/schemas/MailSettingParams'
|
|
|
|
|
+ * responses:
|
|
|
|
|
+ * 200:
|
|
|
|
|
+ * description: Succeeded to delete mail setting
|
|
|
|
|
+ * content:
|
|
|
|
|
+ * application/json:
|
|
|
|
|
+ * schema:
|
|
|
|
|
+ * $ref: '#/components/schemas/MailSettingParams'
|
|
|
|
|
+ */
|
|
|
|
|
+ router.delete('/mail-setting', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
|
|
|
|
|
+ const requestMailSettingParams = {
|
|
|
|
|
+ 'mail:from': null,
|
|
|
|
|
+ 'mail:smtpHost': null,
|
|
|
|
|
+ 'mail:smtpPort': null,
|
|
|
|
|
+ 'mail:smtpUser': null,
|
|
|
|
|
+ 'mail:smtpPassword': null,
|
|
|
|
|
+ };
|
|
|
|
|
+ try {
|
|
|
|
|
+ const mailSettingParams = await updateMailSettinConfig(requestMailSettingParams);
|
|
|
|
|
+ return res.apiv3({ mailSettingParams });
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ const msg = 'Error occurred in initializing mail setting';
|
|
|
|
|
+ logger.error('Error', err);
|
|
|
|
|
+ return res.apiv3Err(new ErrorV3(msg, 'initialize-mailSetting-failed'));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @swagger
|
|
* @swagger
|
|
|
*
|
|
*
|